use of org.apache.dubbo.config.RegistryConfig in project dubbo by alibaba.
the class ConfigTest method testForks.
@Test
public void testForks() {
ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
reference.setApplication(new ApplicationConfig("consumer"));
reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
reference.setInterface(DemoService.class);
reference.setUrl("dubbo://127.0.0.1:20881");
int forks = 10;
reference.setForks(forks);
String str = reference.toString();
assertTrue(str.contains("forks=\"" + forks + "\""));
}
use of org.apache.dubbo.config.RegistryConfig in project dubbo by alibaba.
the class ConfigTest method testAppendFilter.
@Test
public void testAppendFilter() throws Exception {
ApplicationConfig application = new ApplicationConfig("provider");
ProviderConfig provider = new ProviderConfig();
provider.setFilter("classloader,monitor");
ConsumerConfig consumer = new ConsumerConfig();
consumer.setFilter("classloader,monitor");
ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
service.setFilter("accesslog,trace");
service.setProvider(provider);
service.setProtocol(new ProtocolConfig("dubbo", 20880));
service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
service.setInterface(DemoService.class);
service.setRef(new DemoServiceImpl());
ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
reference.setFilter("accesslog,trace");
reference.setConsumer(consumer);
reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
reference.setInterface(DemoService.class);
reference.setUrl("dubbo://" + NetUtils.getLocalHost() + ":20880?" + DemoService.class.getName() + "?check=false");
DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(application).provider(provider).service(service).reference(reference).start();
try {
List<URL> urls = service.getExportedUrls();
assertNotNull(urls);
assertEquals(1, urls.size());
assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("service.filter"));
urls = reference.getExportedUrls();
assertNotNull(urls);
assertEquals(1, urls.size());
assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("reference.filter"));
} finally {
bootstrap.stop();
}
}
use of org.apache.dubbo.config.RegistryConfig in project dubbo by alibaba.
the class ConfigTest method refer.
private DemoService refer(String url) {
ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
reference.setInterface(DemoService.class);
reference.setUrl(url);
DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(new ApplicationConfig("consumer")).reference(reference).start();
return bootstrap.getCache().get(reference);
}
use of org.apache.dubbo.config.RegistryConfig in project dubbo by alibaba.
the class ConfigTest method testSystemPropertyOverrideReferenceConfig.
@Test
public void testSystemPropertyOverrideReferenceConfig() throws Exception {
System.setProperty("dubbo.reference.retries", "5");
try {
ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
service.setInterface(DemoService.class);
service.setRef(new DemoServiceImpl());
ProtocolConfig protocolConfig = new ProtocolConfig("injvm");
ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
reference.setInterface(DemoService.class);
reference.setInjvm(true);
reference.setRetries(2);
DubboBootstrap.getInstance().application(new ApplicationConfig("testSystemPropertyOverrideReferenceConfig")).registry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)).protocol(protocolConfig).service(service).reference(reference).start();
assertEquals(Integer.valueOf(5), reference.getRetries());
} finally {
System.setProperty("dubbo.reference.retries", "");
}
}
use of org.apache.dubbo.config.RegistryConfig in project dubbo by alibaba.
the class ConfigTest method testServiceAnnotation.
@Test
public void testServiceAnnotation() {
AnnotationConfigApplicationContext providerContext = new AnnotationConfigApplicationContext();
providerContext.register(ProviderConfiguration.class);
providerContext.refresh();
ReferenceConfig<HelloService> reference = new ReferenceConfig<HelloService>();
reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
reference.setInterface(HelloService.class);
reference.setUrl("dubbo://127.0.0.1:12345");
DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(new ApplicationConfig("consumer")).reference(reference).start();
HelloService helloService = bootstrap.getCache().get(reference);
String hello = helloService.sayHello("hello");
assertEquals("Hello, hello", hello);
}
Aggregations