Search in sources :

Example 56 with ApplicationConfig

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

the class EnableDubboConfigTest method testSingle.

@Test
public void testSingle() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(TestConfig.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());
    // monitor
    MonitorConfig monitorConfig = context.getBean(MonitorConfig.class);
    Assertions.assertEquals("zookeeper://127.0.0.1:32770", monitorConfig.getAddress());
    // provider
    ProviderConfig providerConfig = context.getBean(ProviderConfig.class);
    Assertions.assertEquals("127.0.0.1", providerConfig.getHost());
    // consumer
    ConsumerConfig consumerConfig = context.getBean(ConsumerConfig.class);
    Assertions.assertEquals("netty", consumerConfig.getClient());
    // asserts aliases
    assertFalse(hasAlias(context, "org.apache.dubbo.config.RegistryConfig#0", "zookeeper"));
    assertFalse(hasAlias(context, "org.apache.dubbo.config.MonitorConfig#0", "zookeeper"));
    context.close();
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ProviderConfig(org.apache.dubbo.config.ProviderConfig) ModuleConfig(org.apache.dubbo.config.ModuleConfig) ConsumerConfig(org.apache.dubbo.config.ConsumerConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) MonitorConfig(org.apache.dubbo.config.MonitorConfig) Test(org.junit.jupiter.api.Test)

Example 57 with ApplicationConfig

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

the class ConsumerConfiguration method applicationConfig.

/**
 * Current application configuration, to replace XML config:
 * <prev>
 * &lt;dubbo:application name="dubbo-demo-application"/&gt;
 * </prev>
 *
 * @return {@link ApplicationConfig} Bean
 */
@Bean("dubbo-demo-application")
public ApplicationConfig applicationConfig() {
    ApplicationConfig applicationConfig = new ApplicationConfig();
    applicationConfig.setName("dubbo-demo-application");
    return applicationConfig;
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) Bean(org.springframework.context.annotation.Bean)

Example 58 with ApplicationConfig

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

the class ProviderConfiguration method applicationConfig.

/**
 * Current application configuration, to replace XML config:
 * <prev>
 * &lt;dubbo:application name="dubbo-demo-application"/&gt;
 * </prev>
 *
 * @return {@link ApplicationConfig} Bean
 */
@Bean("dubbo-demo-application")
public ApplicationConfig applicationConfig() {
    ApplicationConfig applicationConfig = new ApplicationConfig();
    applicationConfig.setName("dubbo-demo-application");
    return applicationConfig;
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) Bean(org.springframework.context.annotation.Bean)

Example 59 with ApplicationConfig

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

the class ServiceAnnotationTestConfiguration method applicationConfig.

/**
 * Current application configuration, to replace XML config:
 * <prev>
 * &lt;dubbo:application name="dubbo-demo-application"/&gt;
 * </prev>
 *
 * @return {@link ApplicationConfig} Bean
 */
@Bean("dubbo-demo-application")
public ApplicationConfig applicationConfig() {
    ApplicationConfig applicationConfig = new ApplicationConfig();
    applicationConfig.setName("dubbo-demo-application");
    return applicationConfig;
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) Bean(org.springframework.context.annotation.Bean)

Example 60 with ApplicationConfig

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

the class DubboConfigConfigurationTest method testMultiple.

@Test
public void testMultiple() {
    context.register(DubboConfigConfiguration.Multiple.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());
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) Test(org.junit.jupiter.api.Test)

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