Search in sources :

Example 1 with ProviderConfig

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());
}
Also used : ProviderConfig(org.apache.dubbo.config.ProviderConfig) Test(org.junit.jupiter.api.Test)

Example 2 with ProviderConfig

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);
}
Also used : MethodConfig(org.apache.dubbo.config.MethodConfig) ServiceConfig(org.apache.dubbo.config.ServiceConfig) ProviderConfig(org.apache.dubbo.config.ProviderConfig) Test(org.junit.jupiter.api.Test)

Example 3 with ProviderConfig

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));
}
Also used : ProviderConfig(org.apache.dubbo.config.ProviderConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 4 with ProviderConfig

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();
    }
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ProviderConfig(org.apache.dubbo.config.ProviderConfig) DemoService(org.apache.dubbo.config.spring.api.DemoService) URL(org.apache.dubbo.common.URL) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ServiceConfig(org.apache.dubbo.config.ServiceConfig) ReferenceConfig(org.apache.dubbo.config.ReferenceConfig) DubboBootstrap(org.apache.dubbo.config.bootstrap.DubboBootstrap) ConsumerConfig(org.apache.dubbo.config.ConsumerConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) DemoServiceImpl(org.apache.dubbo.config.spring.impl.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 5 with ProviderConfig

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");
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) MethodConfig(org.apache.dubbo.config.MethodConfig) ProviderConfig(org.apache.dubbo.config.ProviderConfig) DemoService(org.apache.dubbo.config.api.DemoService) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig)

Aggregations

ProviderConfig (org.apache.dubbo.config.ProviderConfig)15 Test (org.junit.jupiter.api.Test)9 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)6 RegistryConfig (org.apache.dubbo.config.RegistryConfig)4 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)3 ConsumerConfig (org.apache.dubbo.config.ConsumerConfig)3 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 MethodConfig (org.apache.dubbo.config.MethodConfig)2 ServiceConfig (org.apache.dubbo.config.ServiceConfig)2 URL (org.apache.dubbo.common.URL)1 MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)1 ModuleConfig (org.apache.dubbo.config.ModuleConfig)1 MonitorConfig (org.apache.dubbo.config.MonitorConfig)1 ReferenceConfig (org.apache.dubbo.config.ReferenceConfig)1 DemoService (org.apache.dubbo.config.api.DemoService)1 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)1 ConfigTest (org.apache.dubbo.config.spring.ConfigTest)1 DemoService (org.apache.dubbo.config.spring.api.DemoService)1 DemoServiceImpl (org.apache.dubbo.config.spring.impl.DemoServiceImpl)1