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();
}
}
Aggregations