use of org.apache.dubbo.config.ProviderConfig in project dubbo by alibaba.
the class ServiceBuilderTest method provider.
@Test
void provider() {
ProviderConfig provider = new ProviderConfig();
ServiceBuilder builder = new ServiceBuilder();
builder.provider(provider);
Assertions.assertSame(provider, builder.build().getProvider());
}
use of org.apache.dubbo.config.ProviderConfig in project dubbo by alibaba.
the class ServiceBuilderTest method build.
//
// @Test
// public void Mock() throws Exception {
// Assertions.assertThrows(IllegalArgumentException.class, () -> {
// ServiceBuilder builder = new ServiceBuilder();
// builder.mock("true");
// });
// }
//
// @Test
// public void Mock1() throws Exception {
// Assertions.assertThrows(IllegalArgumentException.class, () -> {
// ServiceBuilder builder = new ServiceBuilder();
// builder.mock(true);
// });
// }
@Test
void build() {
MethodConfig method = new MethodConfig();
ProviderConfig provider = new ProviderConfig();
ServiceBuilder builder = new ServiceBuilder();
builder.path("path").addMethod(method).provider(provider).providerIds("providerIds").generic(GENERIC_SERIALIZATION_DEFAULT);
ServiceConfig config = builder.build();
ServiceConfig config2 = builder.build();
assertThat(config.getGeneric(), equalTo(GENERIC_SERIALIZATION_DEFAULT));
Assertions.assertEquals("path", config.getPath());
Assertions.assertEquals("providerIds", config.getProviderIds());
Assertions.assertSame(provider, config.getProvider());
Assertions.assertTrue(config.getMethods().contains(method));
Assertions.assertEquals(1, config.getMethods().size());
Assertions.assertNotSame(config, config2);
}
use of org.apache.dubbo.config.ProviderConfig in project dubbo by alibaba.
the class ConfigManagerTest method testDefaultConfig.
@Test
public void testDefaultConfig() {
ProviderConfig providerConfig = new ProviderConfig();
providerConfig.setDefault(false);
assertFalse(ConfigManager.isDefaultConfig(providerConfig));
ProviderConfig providerConfig1 = new ProviderConfig();
assertTrue(ConfigManager.isDefaultConfig(providerConfig1));
ProviderConfig providerConfig3 = new ProviderConfig();
providerConfig.setDefault(true);
assertTrue(ConfigManager.isDefaultConfig(providerConfig3));
ProtocolConfig protocolConfig = new ProtocolConfig();
protocolConfig.setDefault(false);
assertFalse(ConfigManager.isDefaultConfig(protocolConfig));
}
use of org.apache.dubbo.config.ProviderConfig 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.ProviderConfig in project dubbo by alibaba.
the class UrlTestBase method initServConf.
@SuppressWarnings("deprecation")
protected void initServConf() {
regConfForProvider = new RegistryConfig();
regConfForService = new RegistryConfig();
provConf = new ProviderConfig();
protoConfForProvider = new ProtocolConfig("mockprotocol");
protoConfForService = new ProtocolConfig("mockprotocol");
methodConfForService = new MethodConfig();
servConf = new ServiceConfig<DemoService>();
// provConf.setApplication(appConfForProvider);
servConf.setApplication(application);
provConf.setRegistry(regConfForProvider);
servConf.setRegistry(regConfForService);
provConf.setProtocols(new ArrayList<>(Arrays.asList(protoConfForProvider)));
servConf.setProtocols(new ArrayList<>(Arrays.asList(protoConfForService)));
servConf.setMethods(Arrays.asList(new MethodConfig[] { methodConfForService }));
servConf.setProvider(provConf);
servConf.setRef(demoService);
servConf.setInterfaceClass(DemoService.class);
methodConfForService.setName("sayName");
regConfForService.setAddress("127.0.0.1:9090");
regConfForService.setProtocol("mockregistry");
application.setName("ConfigTests");
}
Aggregations