Search in sources :

Example 1 with MockRegistry

use of org.apache.dubbo.config.spring.registry.MockRegistry in project dubbo by alibaba.

the class ConfigTest method testGenericServiceConfig.

@Test
public void testGenericServiceConfig() throws Exception {
    ServiceConfig<GenericService> service = new ServiceConfig<GenericService>();
    service.setRegistry(new RegistryConfig("mock://localhost"));
    service.setInterface(DemoService.class.getName());
    service.setGeneric(GENERIC_SERIALIZATION_BEAN);
    service.setRef((method, parameterTypes, args) -> null);
    DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(new ApplicationConfig("test")).service(service).start();
    try {
        Collection<Registry> collection = MockRegistryFactory.getCachedRegistry();
        MockRegistry registry = (MockRegistry) collection.iterator().next();
        URL url = registry.getRegistered().get(0);
        Assertions.assertEquals(GENERIC_SERIALIZATION_BEAN, url.getParameter(GENERIC_KEY));
    } finally {
        MockRegistryFactory.cleanCachedRegistry();
        bootstrap.stop();
    }
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) GenericService(org.apache.dubbo.rpc.service.GenericService) ServiceConfig(org.apache.dubbo.config.ServiceConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) MockRegistry(org.apache.dubbo.config.spring.registry.MockRegistry) DemoService(org.apache.dubbo.config.spring.api.DemoService) DubboBootstrap(org.apache.dubbo.config.bootstrap.DubboBootstrap) MockRegistry(org.apache.dubbo.config.spring.registry.MockRegistry) Registry(org.apache.dubbo.registry.Registry) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Aggregations

URL (org.apache.dubbo.common.URL)1 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)1 RegistryConfig (org.apache.dubbo.config.RegistryConfig)1 ServiceConfig (org.apache.dubbo.config.ServiceConfig)1 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)1 DemoService (org.apache.dubbo.config.spring.api.DemoService)1 MockRegistry (org.apache.dubbo.config.spring.registry.MockRegistry)1 Registry (org.apache.dubbo.registry.Registry)1 GenericService (org.apache.dubbo.rpc.service.GenericService)1 Test (org.junit.jupiter.api.Test)1