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();
}
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;
}
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());
}
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());
}
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()));
}
Aggregations