Search in sources :

Example 6 with RegistryService

use of com.alibaba.dubbo.registry.RegistryService in project dubbo by alibaba.

the class ConfigTest method testDelayFixedTime.

@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.spring.api.DemoService");
        assertNull(urls);
        int i = 0;
        while ((i++) < 60 && urls == null) {
            urls = registryService.getRegistered().get("com.alibaba.dubbo.config.spring.api.DemoService");
            Thread.sleep(10);
        }
        assertNotNull(urls);
        assertEquals(1, urls.size());
        assertEquals("dubbo://" + NetUtils.getLocalHost() + ":20883/com.alibaba.dubbo.config.spring.api.DemoService", urls.get(0).toIdentityString());
    } finally {
        ctx.stop();
        ctx.close();
        exporter.unexport();
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) RegistryService(com.alibaba.dubbo.registry.RegistryService) URL(com.alibaba.dubbo.common.URL) Test(org.junit.Test)

Aggregations

RegistryService (com.alibaba.dubbo.registry.RegistryService)6 URL (com.alibaba.dubbo.common.URL)5 Test (org.junit.Test)5 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)5 AnnotationAction (com.alibaba.dubbo.config.spring.annotation.consumer.AnnotationAction)1 RegistryDirectory (com.alibaba.dubbo.registry.integration.RegistryDirectory)1 ArrayList (java.util.ArrayList)1 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)1