use of org.apache.dubbo.config.ProtocolConfig in project dubbo by alibaba.
the class GenericServiceTest method testGenericReferenceException.
@SuppressWarnings("unchecked")
@Test
public void testGenericReferenceException() {
ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
service.setInterface(DemoService.class.getName());
service.setRef(new DemoServiceImpl());
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
reference.setInterface(DemoService.class);
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote&timeout=3000");
reference.setGeneric(true);
DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(new ApplicationConfig("generic-test")).registry(new RegistryConfig("N/A")).protocol(new ProtocolConfig("dubbo", 29581)).service(service).reference(reference);
bootstrap.start();
try {
GenericService genericService = ReferenceConfigCache.getCache().get(reference);
List<Map<String, Object>> users = new ArrayList<Map<String, Object>>();
Map<String, Object> user = new HashMap<String, Object>();
user.put("class", "org.apache.dubbo.config.api.User");
user.put("name", "actual.provider");
users.add(user);
users = (List<Map<String, Object>>) genericService.$invoke("getUsers", new String[] { List.class.getName() }, new Object[] { users });
Assertions.assertEquals(1, users.size());
Assertions.assertEquals("actual.provider", users.get(0).get("name"));
} finally {
bootstrap.stop();
}
}
use of org.apache.dubbo.config.ProtocolConfig in project incubator-dubbo-spring-boot-project by apache.
the class BinderDubboConfigBinderTest method testBinder.
@Test
public void testBinder() {
ApplicationConfig applicationConfig = new ApplicationConfig();
Map<String, Object> properties = getSubProperties(environment.getPropertySources(), "dubbo.application");
dubboConfigBinder.bind(properties, true, true, applicationConfig);
Assert.assertEquals("hello", applicationConfig.getName());
Assert.assertEquals("world", applicationConfig.getOwner());
RegistryConfig registryConfig = new RegistryConfig();
properties = getSubProperties(environment.getPropertySources(), "dubbo.registry");
dubboConfigBinder.bind(properties, true, true, registryConfig);
Assert.assertEquals("10.20.153.17", registryConfig.getAddress());
ProtocolConfig protocolConfig = new ProtocolConfig();
properties = getSubProperties(environment.getPropertySources(), "dubbo.protocol");
dubboConfigBinder.bind(properties, true, true, protocolConfig);
Assert.assertEquals(Integer.valueOf(20881), protocolConfig.getPort());
}
Aggregations