Search in sources :

Example 1 with HelloServiceImpl

use of com.alibaba.dubbo.config.spring.impl.HelloServiceImpl in project dubbo by alibaba.

the class ConfigTest method testProtocolRandomPort.

@Test
public void testProtocolRandomPort() throws Exception {
    ServiceConfig<DemoService> demoService = null;
    ServiceConfig<HelloService> helloService = null;
    ApplicationConfig application = new ApplicationConfig();
    application.setName("test-protocol-random-port");
    RegistryConfig registry = new RegistryConfig();
    registry.setAddress("N/A");
    ProtocolConfig protocol = new ProtocolConfig();
    protocol.setName("dubbo");
    protocol.setPort(-1);
    demoService = new ServiceConfig<DemoService>();
    demoService.setInterface(DemoService.class);
    demoService.setRef(new DemoServiceImpl());
    demoService.setApplication(application);
    demoService.setRegistry(registry);
    demoService.setProtocol(protocol);
    helloService = new ServiceConfig<HelloService>();
    helloService.setInterface(HelloService.class);
    helloService.setRef(new HelloServiceImpl());
    helloService.setApplication(application);
    helloService.setRegistry(registry);
    helloService.setProtocol(protocol);
    try {
        demoService.export();
        helloService.export();
        Assert.assertEquals(demoService.getExportedUrls().get(0).getPort(), helloService.getExportedUrls().get(0).getPort());
    } finally {
        unexportService(demoService);
        unexportService(helloService);
    }
}
Also used : RegistryConfig(com.alibaba.dubbo.config.RegistryConfig) ApplicationConfig(com.alibaba.dubbo.config.ApplicationConfig) DemoService(com.alibaba.dubbo.config.spring.api.DemoService) HelloService(com.alibaba.dubbo.config.spring.api.HelloService) HelloServiceImpl(com.alibaba.dubbo.config.spring.impl.HelloServiceImpl) ProtocolConfig(com.alibaba.dubbo.config.ProtocolConfig) DemoServiceImpl(com.alibaba.dubbo.config.spring.impl.DemoServiceImpl) Test(org.junit.Test)

Aggregations

ApplicationConfig (com.alibaba.dubbo.config.ApplicationConfig)1 ProtocolConfig (com.alibaba.dubbo.config.ProtocolConfig)1 RegistryConfig (com.alibaba.dubbo.config.RegistryConfig)1 DemoService (com.alibaba.dubbo.config.spring.api.DemoService)1 HelloService (com.alibaba.dubbo.config.spring.api.HelloService)1 DemoServiceImpl (com.alibaba.dubbo.config.spring.impl.DemoServiceImpl)1 HelloServiceImpl (com.alibaba.dubbo.config.spring.impl.HelloServiceImpl)1 Test (org.junit.Test)1