use of com.alibaba.dubbo.config.ConsumerConfig in project dubbo by alibaba.
the class InvokerSideConfigUrlTest method initRefConf.
// ======================================================
// private helper
// ======================================================
private void initRefConf() {
appConfForConsumer = new ApplicationConfig();
appConfForReference = new ApplicationConfig();
regConfForConsumer = new RegistryConfig();
regConfForReference = new RegistryConfig();
methodConfForReference = new MethodConfig();
refConf = new ReferenceConfig<DemoService>();
consumerConf = new ConsumerConfig();
methodConfForReference.setName("sayName");
regConfForReference.setAddress("127.0.0.1:9090");
regConfForReference.setProtocol("mockregistry");
appConfForReference.setName("ConfigTests");
refConf.setInterface("com.alibaba.dubbo.config.api.DemoService");
refConf.setApplication(appConfForReference);
consumerConf.setApplication(appConfForConsumer);
refConf.setRegistry(regConfForReference);
consumerConf.setRegistry(regConfForConsumer);
refConf.setConsumer(consumerConf);
refConf.setMethods(Arrays.asList(new MethodConfig[] { methodConfForReference }));
refConf.setScope(Constants.SCOPE_REMOTE);
}
use of com.alibaba.dubbo.config.ConsumerConfig in project dubbo by alibaba.
the class ConfigTest method testAppendFilter.
@Test
public void testAppendFilter() throws Exception {
ProviderConfig provider = new ProviderConfig();
provider.setFilter("classloader,monitor");
ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
service.setFilter("accesslog,trace");
service.setProvider(provider);
service.setProtocol(new ProtocolConfig("dubbo", 20880));
service.setApplication(new ApplicationConfig("provider"));
service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
service.setInterface(DemoService.class);
service.setRef(new DemoServiceImpl());
try {
service.export();
List<URL> urls = service.toUrls();
assertNotNull(urls);
assertEquals(1, urls.size());
assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("service.filter"));
ConsumerConfig consumer = new ConsumerConfig();
consumer.setFilter("classloader,monitor");
ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
reference.setFilter("accesslog,trace");
reference.setConsumer(consumer);
reference.setApplication(new ApplicationConfig("consumer"));
reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
reference.setInterface(DemoService.class);
reference.setUrl("dubbo://" + NetUtils.getLocalHost() + ":20880?" + DemoService.class.getName() + "?check=false");
try {
reference.get();
urls = reference.toUrls();
assertNotNull(urls);
assertEquals(1, urls.size());
assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("reference.filter"));
} finally {
reference.destroy();
}
} finally {
service.unexport();
}
}
use of com.alibaba.dubbo.config.ConsumerConfig in project dubbo by alibaba.
the class ConfigTest method testRmiTimeout.
@Test
public void testRmiTimeout() throws Exception {
if (System.getProperty("sun.rmi.transport.tcp.responseTimeout") != null) {
System.setProperty("sun.rmi.transport.tcp.responseTimeout", "");
}
ConsumerConfig consumer = new ConsumerConfig();
consumer.setTimeout(1000);
assertEquals("1000", System.getProperty("sun.rmi.transport.tcp.responseTimeout"));
consumer.setTimeout(2000);
assertEquals("1000", System.getProperty("sun.rmi.transport.tcp.responseTimeout"));
}
Aggregations