Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 <a href="mailto:[email protected]">guaner.zzx</a>
* Created on 2019/12/18
*/
public class WhateverClass implements WhateverInterface {
@Override
public String say() {
return "whatever";
}
}
Original file line number Diff line number Diff line change
@@ -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 <a href="mailto:[email protected]">guaner.zzx</a>
* Created on 2019/12/18
*/
public interface WhateverInterface {
String say();
}
Original file line number Diff line number Diff line change
@@ -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 <a href="mailto:[email protected]">guaner.zzx</a>
* 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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sofa="http://sofastack.io/schema/sofaboot"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://sofastack.io/schema/sofaboot http://sofastack.io/schema/sofaboot.xsd">
<bean id="whateverBean" class="com.alipay.sofa.rpc.boot.test.xsd.WhateverClass" />
<sofa:service ref="whateverBean" interface="com.alipay.sofa.rpc.boot.test.xsd.WhateverInterface">
<sofa:binding.bolt>
<sofa:global-attrs timeout="${timeout}" />
</sofa:binding.bolt>
</sofa:service>

<sofa:reference id="whatever" jvm-first="false" interface="com.alipay.sofa.rpc.boot.test.xsd.WhateverInterface">
<sofa:binding.bolt>
<sofa:global-attrs timeout="${timeout}" />
</sofa:binding.bolt>
</sofa:reference>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<xsd:complexType name="BBindingTRRefMethod">
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="type" type="BInvokeMode" use="optional"/>
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="callback-class" type="xsd:string" use="optional"/>
<xsd:attribute name="callback-ref" type="xsd:string" use="optional"/>
</xsd:complexType>
Expand All @@ -92,15 +92,15 @@

<!-- global-attrs in reference binding.bolt -->
<xsd:complexType name="BBindingTRRefAttr">
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="type" type="BInvokeMode" use="optional"/>
<xsd:attribute name="address-wait-time" type="xsd:int" use="optional"/>
<xsd:attribute name="callback-class" type="xsd:string" use="optional"/>
<xsd:attribute name="callback-ref" type="xsd:string" use="optional"/>
<xsd:attribute name="connect.timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="connect.timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="connect.num" type="xsd:int" use="optional"/>
<xsd:attribute name="idle.timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="idle.timeout.read" type="xsd:int" use="optional"/>
<xsd:attribute name="idle.timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="idle.timeout.read" type="xsd:string" use="optional"/>
<xsd:attribute name="generic-interface" type="xsd:string" use="optional"/>
<xsd:attribute name="filter" type="xsd:string" use="optional"/>
<xsd:attribute name="retries" type="xsd:int" use="optional"/>
Expand All @@ -114,11 +114,11 @@
<!-- method in service binding.bolt -->
<xsd:complexType name="BBindingTRSerMethod">
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
</xsd:complexType>
<!-- global-attrs in service binding.bolt -->
<xsd:complexType name="BBindingTRSerAttr">
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="weight" type="xsd:int" use="optional" />
<xsd:attribute name="warm-up-weight" type="xsd:int" use="optional" />
<xsd:attribute name="warm-up-time" type="xsd:int" use="optional" />
Expand Down Expand Up @@ -147,7 +147,7 @@
</xsd:complexType>
<!--jvm service-->
<xsd:complexType name="BBindingJvmService">
<xsd:attribute name="serialize" type="xsd:boolean" default="true" use="optional"/>
<xsd:attribute name="serialize" type="xsd:boolean" default="true" use="optional"/>
</xsd:complexType>
<!-- binding.bolt in service -->
<xsd:complexType name="BBindingTRService">
Expand Down Expand Up @@ -222,7 +222,7 @@
<xsd:complexType name="RestBindingTRRefMethod">
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="type" type="RestInvokeMode" use="optional"/>
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
</xsd:complexType>

<!-- route in reference binding.rest-->
Expand All @@ -232,23 +232,23 @@

<!-- global-attrs in reference binding.rest -->
<xsd:complexType name="RestBindingTRRefAttr">
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="type" type="RestInvokeMode" use="optional"/>
<xsd:attribute name="address-wait-time" type="xsd:int" use="optional"/>
<xsd:attribute name="connect.timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="connect.timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="connect.num" type="xsd:int" use="optional"/>
<xsd:attribute name="idle.timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="idle.timeout.read" type="xsd:int" use="optional"/>
<xsd:attribute name="idle.timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="idle.timeout.read" type="xsd:string" use="optional"/>
</xsd:complexType>

<!-- method in service binding.rest -->
<xsd:complexType name="RestBindingTRSerMethod">
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
</xsd:complexType>
<!-- global-attrs in service binding.rest -->
<xsd:complexType name="RestBindingTRSerAttr">
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
</xsd:complexType>
<!-- binding.rest in reference -->
<xsd:complexType name="RestBindingTRReference">
Expand Down Expand Up @@ -340,7 +340,7 @@
<xsd:complexType name="DubboBindingTRRefMethod">
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="type" type="DubboInvokeMode" use="optional"/>
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="callback-class" type="xsd:string" use="optional"/>
<xsd:attribute name="callback-ref" type="xsd:string" use="optional"/>
</xsd:complexType>
Expand All @@ -352,15 +352,15 @@

<!-- global-attrs in reference binding.dubbo -->
<xsd:complexType name="DubboBindingTRRefAttr">
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="type" type="DubboInvokeMode" use="optional"/>
<xsd:attribute name="address-wait-time" type="xsd:int" use="optional"/>
<xsd:attribute name="callback-class" type="xsd:string" use="optional"/>
<xsd:attribute name="callback-ref" type="xsd:string" use="optional"/>
<xsd:attribute name="connect.timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="connect.timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="connect.num" type="xsd:int" use="optional"/>
<xsd:attribute name="idle.timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="idle.timeout.read" type="xsd:int" use="optional"/>
<xsd:attribute name="idle.timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="idle.timeout.read" type="xsd:string" use="optional"/>
<xsd:attribute name="retries" type="xsd:int" use="optional"/>
<xsd:attribute name="lazy" type="xsd:boolean" use="optional"/>
<xsd:attribute name="check" type="xsd:boolean" use="optional"/>
Expand All @@ -370,11 +370,11 @@
<!-- method in service binding.dubbo -->
<xsd:complexType name="DubboBindingTRSerMethod">
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
</xsd:complexType>
<!-- global-attrs in service binding.dubbo -->
<xsd:complexType name="DubboBindingTRSerAttr">
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
</xsd:complexType>
<!-- binding.dubbo in reference -->
<xsd:complexType name="DubboBindingTRReference">
Expand Down Expand Up @@ -465,7 +465,7 @@
<xsd:complexType name="H2cBindingRefMethod">
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="type" type="H2cInvokeMode" use="optional"/>
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="callback-class" type="xsd:string" use="optional"/>
<xsd:attribute name="callback-ref" type="xsd:string" use="optional"/>
</xsd:complexType>
Expand All @@ -477,12 +477,12 @@

<!-- global-attrs in reference binding.h2c -->
<xsd:complexType name="H2cBindingRefAttr">
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="type" type="BInvokeMode" use="optional"/>
<xsd:attribute name="address-wait-time" type="xsd:int" use="optional"/>
<xsd:attribute name="callback-class" type="xsd:string" use="optional"/>
<xsd:attribute name="callback-ref" type="xsd:string" use="optional"/>
<xsd:attribute name="connect.timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="connect.timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="connect.num" type="xsd:int" use="optional"/>
<xsd:attribute name="generic-interface" type="xsd:string" use="optional"/>
<xsd:attribute name="filter" type="xsd:string" use="optional"/>
Expand All @@ -497,11 +497,11 @@
<!-- method in service binding.h2c -->
<xsd:complexType name="H2cBindingSerMethod">
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
</xsd:complexType>
<!-- global-attrs in service binding.h2c -->
<xsd:complexType name="H2cBindingSerAttr">
<xsd:attribute name="timeout" type="xsd:int" use="optional"/>
<xsd:attribute name="timeout" type="xsd:string" use="optional"/>
<xsd:attribute name="weight" type="xsd:int" use="optional" />
<xsd:attribute name="warm-up-weight" type="xsd:int" use="optional" />
<xsd:attribute name="warm-up-time" type="xsd:int" use="optional" />
Expand Down