use of org.apache.dubbo.config.ConsumerConfig in project dubbo by alibaba.
the class ReferenceBuilderTest method build.
@Test
void build() {
ConsumerConfig consumer = new ConsumerConfig();
MethodConfig method = new MethodConfig();
ReferenceBuilder<DemoService> builder = new ReferenceBuilder<>();
builder.id("id").interfaceClass(DemoService.class).protocol("protocol").client("client").url("url").consumer(consumer).addMethod(method).services("test-service", "test-service2");
ReferenceConfig config = builder.build();
ReferenceConfig config2 = builder.build();
Assertions.assertEquals("org.apache.dubbo.config.api.DemoService", config.getInterface());
Assertions.assertEquals(DemoService.class, config.getInterfaceClass());
Assertions.assertEquals("protocol", config.getProtocol());
Assertions.assertEquals("client", config.getClient());
Assertions.assertEquals("url", config.getUrl());
Assertions.assertEquals(consumer, config.getConsumer());
Assertions.assertEquals("test-service,test-service2", config.getServices());
Assertions.assertEquals(ofSet("test-service", "test-service2"), config.getSubscribedServices());
Assertions.assertTrue(config.getMethods().contains(method));
Assertions.assertEquals(1, config.getMethods().size());
Assertions.assertNotSame(config, config2);
}
use of org.apache.dubbo.config.ConsumerConfig in project dubbo by alibaba.
the class ConfigManagerTest method testConsumerConfig.
// Test ConsumerConfig correlative methods
@Test
public void testConsumerConfig() {
ConsumerConfig config = new ConsumerConfig();
configManager.addConsumers(asList(config, null));
Collection<ConsumerConfig> configs = configManager.getConsumers();
assertEquals(1, configs.size());
assertEquals(config, configs.iterator().next());
assertTrue(configManager.getDefaultConsumer().isPresent());
config.setId(DEFAULT_KEY);
configManager.addConsumer(config);
assertTrue(configManager.getDefaultConsumer().isPresent());
configs = configManager.getConsumers();
assertEquals(2, configs.size());
}
use of org.apache.dubbo.config.ConsumerConfig 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.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"));
}
use of org.apache.dubbo.config.ConsumerConfig in project dubbo by alibaba.
the class ConfigValidationUtils method validateReferenceConfig.
public static void validateReferenceConfig(ReferenceConfig config) {
checkMultiExtension(InvokerListener.class, LISTENER_KEY, config.getListener());
checkKey(VERSION_KEY, config.getVersion());
checkKey(GROUP_KEY, config.getGroup());
checkName(CLIENT_KEY, config.getClient());
validateAbstractInterfaceConfig(config);
List<RegistryConfig> registries = config.getRegistries();
if (registries != null) {
for (RegistryConfig registry : registries) {
validateRegistryConfig(registry);
}
}
ConsumerConfig consumerConfig = config.getConsumer();
if (consumerConfig != null) {
validateConsumerConfig(consumerConfig);
}
}
Aggregations