diff --git a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/xsd/WhateverClass.java b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/xsd/WhateverClass.java new file mode 100644 index 000000000..ec7165469 --- /dev/null +++ b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/xsd/WhateverClass.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alipay.sofa.rpc.boot.test.xsd; + +/** + * @author guaner.zzx + * Created on 2019/12/18 + */ +public class WhateverClass implements WhateverInterface { + @Override + public String say() { + return "whatever"; + } +} diff --git a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/xsd/WhateverInterface.java b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/xsd/WhateverInterface.java new file mode 100644 index 000000000..e45546bf5 --- /dev/null +++ b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/xsd/WhateverInterface.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alipay.sofa.rpc.boot.test.xsd; + +/** + * @author guaner.zzx + * Created on 2019/12/18 + */ +public interface WhateverInterface { + String say(); +} diff --git a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/xsd/XsdTimeoutTest.java b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/xsd/XsdTimeoutTest.java new file mode 100644 index 000000000..90b7d738a --- /dev/null +++ b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/xsd/XsdTimeoutTest.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alipay.sofa.rpc.boot.test.xsd; + +import com.alipay.sofa.rpc.boot.runtime.binding.BoltBinding; +import com.alipay.sofa.rpc.boot.runtime.binding.RpcBinding; +import com.alipay.sofa.rpc.boot.runtime.binding.RpcBindingType; +import com.alipay.sofa.runtime.api.component.ComponentName; +import com.alipay.sofa.runtime.service.component.Reference; +import com.alipay.sofa.runtime.service.component.ReferenceComponent; +import com.alipay.sofa.runtime.service.component.ServiceComponent; +import com.alipay.sofa.runtime.spi.component.ComponentInfo; +import com.alipay.sofa.runtime.spi.component.SofaRuntimeContext; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ImportResource; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.Collection; + +/** + * @author guaner.zzx + * Created on 2019/12/18 + */ +@SpringBootApplication +@RunWith(SpringRunner.class) +@SpringBootTest(classes = XsdTimeoutTest.class, properties = { "timeout=10000" }) +@ImportResource("/spring/xsd.xml") +public class XsdTimeoutTest { + @Autowired + WhateverInterface whatever; + @Autowired + SofaRuntimeContext sofaRuntimeContext; + + @Test + public void testService() { + Assert.assertEquals(whatever.say(), "whatever"); + } + + @Test + public void testServiceTimeout() { + ServiceComponent component = (ServiceComponent) sofaRuntimeContext.getComponentManager() + .getComponentInfo( + new ComponentName(ServiceComponent.SERVICE_COMPONENT_TYPE, WhateverInterface.class + .getName())); + RpcBinding binding = (RpcBinding) component.getService().getBinding( + RpcBindingType.BOLT_BINDING_TYPE); + Assert.assertEquals((long) binding.getRpcBindingParam().getTimeout(), 10000); + } + + @Test + public void testReferenceTimeout() { + ReferenceComponent component = (ReferenceComponent) (sofaRuntimeContext + .getComponentManager() + .getComponentInfosByType(ReferenceComponent.REFERENCE_COMPONENT_TYPE).iterator().next()); + RpcBinding binding = (RpcBinding) component.getReference().getBinding( + RpcBindingType.BOLT_BINDING_TYPE); + Assert.assertEquals((long) binding.getRpcBindingParam().getTimeout(), 10000); + } +} diff --git a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/resources/spring/xsd.xml b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/resources/spring/xsd.xml new file mode 100644 index 000000000..b443e5afc --- /dev/null +++ b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/resources/spring/xsd.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/sofa-boot-project/sofa-boot/src/main/resources/com/alipay/sofa/boot/spring/namespace/schema/rpc.xsd b/sofa-boot-project/sofa-boot/src/main/resources/com/alipay/sofa/boot/spring/namespace/schema/rpc.xsd index 6d7626b15..76f84c80f 100644 --- a/sofa-boot-project/sofa-boot/src/main/resources/com/alipay/sofa/boot/spring/namespace/schema/rpc.xsd +++ b/sofa-boot-project/sofa-boot/src/main/resources/com/alipay/sofa/boot/spring/namespace/schema/rpc.xsd @@ -80,7 +80,7 @@ - + @@ -92,15 +92,15 @@ - + - + - - + + @@ -114,11 +114,11 @@ - + - + @@ -147,7 +147,7 @@ - + @@ -222,7 +222,7 @@ - + @@ -232,23 +232,23 @@ - + - + - - + + - + - + @@ -340,7 +340,7 @@ - + @@ -352,15 +352,15 @@ - + - + - - + + @@ -370,11 +370,11 @@ - + - + @@ -465,7 +465,7 @@ - + @@ -477,12 +477,12 @@ - + - + @@ -497,11 +497,11 @@ - + - +