Search in sources :

Example 31 with ApplicationConfig

use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.

the class EnableDubboConfigTest method testMultiple.

@Test
public void testMultiple() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(TestMultipleConfig.class);
    context.refresh();
    // application
    ApplicationConfig applicationConfig = context.getBean("applicationBean", ApplicationConfig.class);
    Assertions.assertEquals("dubbo-demo-application", applicationConfig.getName());
    ApplicationConfig applicationBean2 = context.getBean("applicationBean2", ApplicationConfig.class);
    Assertions.assertEquals("dubbo-demo-application2", applicationBean2.getName());
    ApplicationConfig applicationBean3 = context.getBean("applicationBean3", ApplicationConfig.class);
    Assertions.assertEquals("dubbo-demo-application3", applicationBean3.getName());
    Map<String, ProtocolConfig> protocolConfigs = context.getBeansOfType(ProtocolConfig.class);
    for (Map.Entry<String, ProtocolConfig> entry : protocolConfigs.entrySet()) {
        ProtocolConfig protocol = entry.getValue();
        Assertions.assertEquals(protocol, context.getBean(protocol.getName(), ProtocolConfig.class));
    }
    // asserts aliases
    assertTrue(hasAlias(context, "applicationBean2", "dubbo-demo-application2"));
    assertTrue(hasAlias(context, "applicationBean3", "dubbo-demo-application3"));
    context.close();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 32 with ApplicationConfig

use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.

the class LazyInitDubboAnnotationTest method applicationConfig.

/**
 * lazy-init Application Configuration
 *
 * @return {@link ApplicationConfig} Bean
 */
@Bean("applicationConfig")
public ApplicationConfig applicationConfig() {
    ApplicationConfig applicationConfig = new ApplicationConfig();
    applicationConfig.setName("lazy-init-annotation-application");
    return applicationConfig;
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) Bean(org.springframework.context.annotation.Bean)

Example 33 with ApplicationConfig

use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.

the class DubboConfigConfigurationTest method testSingle.

@Test
public void testSingle() throws IOException {
    context.register(DubboConfigConfiguration.Single.class);
    context.refresh();
    // application
    ApplicationConfig applicationConfig = context.getBean("applicationBean", ApplicationConfig.class);
    Assertions.assertEquals("dubbo-demo-application", applicationConfig.getName());
    // module
    ModuleConfig moduleConfig = context.getBean("moduleBean", ModuleConfig.class);
    Assertions.assertEquals("dubbo-demo-module", moduleConfig.getName());
    // registry
    RegistryConfig registryConfig = context.getBean(RegistryConfig.class);
    Assertions.assertEquals("zookeeper://192.168.99.100:32770", registryConfig.getAddress());
    // protocol
    ProtocolConfig protocolConfig = context.getBean(ProtocolConfig.class);
    Assertions.assertEquals("dubbo", protocolConfig.getName());
    Assertions.assertEquals(Integer.valueOf(20880), protocolConfig.getPort());
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ModuleConfig(org.apache.dubbo.config.ModuleConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 34 with ApplicationConfig

use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.

the class DefaultDubboConfigBinderTest method testBinder.

@Test
public void testBinder() {
    ApplicationConfig applicationConfig = new ApplicationConfig();
    dubboConfigBinder.bind("dubbo.application", applicationConfig);
    Assertions.assertEquals("hello", applicationConfig.getName());
    Assertions.assertEquals("world", applicationConfig.getOwner());
    RegistryConfig registryConfig = new RegistryConfig();
    dubboConfigBinder.bind("dubbo.registry", registryConfig);
    Assertions.assertEquals("10.20.153.17", registryConfig.getAddress());
    ProtocolConfig protocolConfig = new ProtocolConfig();
    dubboConfigBinder.bind("dubbo.protocol", protocolConfig);
    Assertions.assertEquals(Integer.valueOf(20881), protocolConfig.getPort());
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 35 with ApplicationConfig

use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.

the class DubboNamespaceHandlerTest method testProviderXml.

private void testProviderXml(ApplicationContext context) {
    ProtocolConfig protocolConfig = context.getBean(ProtocolConfig.class);
    assertThat(protocolConfig, not(nullValue()));
    assertThat(protocolConfig.getName(), is("dubbo"));
    assertThat(protocolConfig.getPort(), is(20813));
    ApplicationConfig applicationConfig = context.getBean(ApplicationConfig.class);
    assertThat(applicationConfig, not(nullValue()));
    assertThat(applicationConfig.getName(), is("demo-provider"));
    DemoService service = context.getBean(DemoService.class);
    assertThat(service, not(nullValue()));
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) DemoService(org.apache.dubbo.config.spring.api.DemoService) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig)

Aggregations

ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)75 RegistryConfig (org.apache.dubbo.config.RegistryConfig)42 Test (org.junit.jupiter.api.Test)32 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)27 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)19 ServiceConfig (org.apache.dubbo.config.ServiceConfig)18 ReferenceConfig (org.apache.dubbo.config.ReferenceConfig)16 DemoService (org.apache.dubbo.config.spring.api.DemoService)13 URL (org.apache.dubbo.common.URL)9 GenericService (org.apache.dubbo.rpc.service.GenericService)8 Test (org.junit.Test)8 DemoServiceImpl (org.apache.dubbo.config.spring.impl.DemoServiceImpl)7 ArrayList (java.util.ArrayList)6 MonitorConfig (org.apache.dubbo.config.MonitorConfig)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 AbstractInterfaceConfigTest (org.apache.dubbo.config.AbstractInterfaceConfigTest)4 UserService (org.apache.dubbo.config.bootstrap.rest.UserService)4 MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)3 ModuleConfig (org.apache.dubbo.config.ModuleConfig)3 UserServiceImpl (org.apache.dubbo.config.bootstrap.rest.UserServiceImpl)3