Search in sources :

Example 1 with EchoServiceImpl

use of org.apache.dubbo.config.bootstrap.EchoServiceImpl in project dubbo by alibaba.

the class PublishingServiceDefinitionListenerTest method testOnServiceConfigExportedEvent.

/**
 * Test {@link ServiceConfigExportedEvent} arising
 */
@Test
public void testOnServiceConfigExportedEvent() {
    ServiceConfig<EchoService> serviceConfig = new ServiceConfig<>();
    serviceConfig.setInterface(EchoService.class);
    serviceConfig.setRef(new EchoServiceImpl());
    serviceConfig.setRegistry(new RegistryConfig("N/A"));
    serviceConfig.setProtocol(new ProtocolConfig("dubbo", NetUtils.getAvailablePort(20880 + new Random().nextInt(10000))));
    serviceConfig.export();
    String serviceDefinition = writableMetadataService.getServiceDefinition(EchoService.class.getName());
    ServiceDefinition serviceDefinitionBuild = ServiceDefinitionBuilder.build(serviceConfig.getInterfaceClass());
    assertEquals(serviceDefinition, JSON.toJSONString(serviceDefinitionBuild));
    serviceConfig.unexport();
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) Random(java.util.Random) ServiceConfig(org.apache.dubbo.config.ServiceConfig) EchoService(org.apache.dubbo.config.bootstrap.EchoService) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) EchoServiceImpl(org.apache.dubbo.config.bootstrap.EchoServiceImpl) ServiceDefinition(org.apache.dubbo.metadata.definition.model.ServiceDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

Random (java.util.Random)1 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)1 RegistryConfig (org.apache.dubbo.config.RegistryConfig)1 ServiceConfig (org.apache.dubbo.config.ServiceConfig)1 EchoService (org.apache.dubbo.config.bootstrap.EchoService)1 EchoServiceImpl (org.apache.dubbo.config.bootstrap.EchoServiceImpl)1 ServiceDefinition (org.apache.dubbo.metadata.definition.model.ServiceDefinition)1 Test (org.junit.jupiter.api.Test)1