Search in sources :

Example 1 with MockRegistry

use of com.alibaba.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.setApplication(new ApplicationConfig("test"));
    service.setRegistry(new RegistryConfig("mock://localhost"));
    service.setInterface(DemoService.class.getName());
    service.setGeneric(Constants.GENERIC_SERIALIZATION_BEAN);
    service.setRef(new GenericService() {

        public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException {
            return null;
        }
    });
    try {
        service.export();
        Collection<Registry> collection = MockRegistryFactory.getCachedRegistry();
        MockRegistry registry = (MockRegistry) collection.iterator().next();
        URL url = registry.getRegistered().get(0);
        Assert.assertEquals(Constants.GENERIC_SERIALIZATION_BEAN, url.getParameter(Constants.GENERIC_KEY));
    } finally {
        MockRegistryFactory.cleanCachedRegistry();
        service.unexport();
    }
}
Also used : RegistryConfig(com.alibaba.dubbo.config.RegistryConfig) GenericService(com.alibaba.dubbo.rpc.service.GenericService) MockRegistry(com.alibaba.dubbo.config.spring.registry.MockRegistry) DemoService(com.alibaba.dubbo.config.spring.api.DemoService) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Registry(com.alibaba.dubbo.registry.Registry) MockRegistry(com.alibaba.dubbo.config.spring.registry.MockRegistry) GenericException(com.alibaba.dubbo.rpc.service.GenericException) URL(com.alibaba.dubbo.common.URL) ServiceConfig(com.alibaba.dubbo.config.ServiceConfig) ApplicationConfig(com.alibaba.dubbo.config.ApplicationConfig) Test(org.junit.Test)

Aggregations

URL (com.alibaba.dubbo.common.URL)1 ApplicationConfig (com.alibaba.dubbo.config.ApplicationConfig)1 RegistryConfig (com.alibaba.dubbo.config.RegistryConfig)1 ServiceConfig (com.alibaba.dubbo.config.ServiceConfig)1 DemoService (com.alibaba.dubbo.config.spring.api.DemoService)1 MockRegistry (com.alibaba.dubbo.config.spring.registry.MockRegistry)1 Registry (com.alibaba.dubbo.registry.Registry)1 GenericException (com.alibaba.dubbo.rpc.service.GenericException)1 GenericService (com.alibaba.dubbo.rpc.service.GenericService)1 Test (org.junit.Test)1 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)1