DUBBO-20 增加delay测试用例
git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@270 1a56cb94-b969-4eaa-88fa-be21384802f2
This commit is contained in:
parent
d8cf940891
commit
93bc22bac2
|
|
@ -122,4 +122,45 @@ public class ConfigTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelayFixedTime() throws Exception {
|
||||
SimpleRegistryService registryService = new SimpleRegistryService();
|
||||
Exporter<RegistryService> exporter = SimpleRegistryExporter.export(4548, registryService);
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/delay-fixed-time.xml");
|
||||
ctx.start();
|
||||
try {
|
||||
List<URL> urls = registryService.getRegistered().get("com.alibaba.dubbo.config.api.DemoService");
|
||||
Assert.assertNull(urls);
|
||||
while (urls == null) {
|
||||
urls = registryService.getRegistered().get("com.alibaba.dubbo.config.api.DemoService");
|
||||
Thread.sleep(10);
|
||||
}
|
||||
Assert.assertNotNull(urls);
|
||||
Assert.assertEquals(1, urls.size());
|
||||
Assert.assertEquals("dubbo://" + NetUtils.getLocalHost() + ":20883/com.alibaba.dubbo.config.api.DemoService", urls.get(0).toIdentityString());
|
||||
} finally {
|
||||
ctx.stop();
|
||||
ctx.close();
|
||||
exporter.unexport();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelayOnInitialized() throws Exception {
|
||||
SimpleRegistryService registryService = new SimpleRegistryService();
|
||||
Exporter<RegistryService> exporter = SimpleRegistryExporter.export(4548, registryService);
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/delay-on-initialized.xml");
|
||||
ctx.start();
|
||||
try {
|
||||
List<URL> urls = registryService.getRegistered().get("com.alibaba.dubbo.config.api.DemoService");
|
||||
Assert.assertNotNull(urls);
|
||||
Assert.assertEquals(1, urls.size());
|
||||
Assert.assertEquals("dubbo://" + NetUtils.getLocalHost() + ":20883/com.alibaba.dubbo.config.api.DemoService", urls.get(0).toIdentityString());
|
||||
} finally {
|
||||
ctx.stop();
|
||||
ctx.close();
|
||||
exporter.unexport();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
|
||||
">
|
||||
|
||||
<!-- 当前应用信息配置 -->
|
||||
<dubbo:application name="demo-provider" />
|
||||
|
||||
<!-- 连接注册中心配置 -->
|
||||
<dubbo:registry address="127.0.0.1:4548" />
|
||||
|
||||
<dubbo:protocol name="dubbo" port="20883" />
|
||||
|
||||
<!-- 暴露服务配置 -->
|
||||
<dubbo:service interface="com.alibaba.dubbo.config.api.DemoService" ref="demoService" delay="300" />
|
||||
|
||||
<bean id="demoService" class="com.alibaba.dubbo.config.provider.impl.DemoServiceImpl" />
|
||||
|
||||
</beans>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
|
||||
">
|
||||
|
||||
<!-- 当前应用信息配置 -->
|
||||
<dubbo:application name="demo-provider" />
|
||||
|
||||
<!-- 连接注册中心配置 -->
|
||||
<dubbo:registry address="127.0.0.1:4548" />
|
||||
|
||||
<dubbo:protocol name="dubbo" port="20883" />
|
||||
|
||||
<!-- 暴露服务配置 -->
|
||||
<dubbo:service interface="com.alibaba.dubbo.config.api.DemoService" ref="demoService" delay="-1" />
|
||||
|
||||
<bean id="demoService" class="com.alibaba.dubbo.config.provider.impl.DemoServiceImpl" />
|
||||
|
||||
</beans>
|
||||
Loading…
Reference in New Issue