use of org.apache.dubbo.config.ProtocolConfig in project dubbo by alibaba.
the class LazyInitDubboAnnotationTest method protocolConfig.
/**
* lazy-init Protocol Configuration
*
* @return {@link ProtocolConfig} Bean
*/
@Bean("protocolConfig")
public ProtocolConfig protocolConfig() {
ProtocolConfig protocolConfig = new ProtocolConfig();
protocolConfig.setName("dubbo");
protocolConfig.setPort(NetUtils.getAvailablePort());
return protocolConfig;
}
use of org.apache.dubbo.config.ProtocolConfig 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.ProtocolConfig 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.ProtocolConfig in project dubbo by alibaba.
the class DubboNamespaceHandlerTest method testDefaultProtocol.
@Test
public void testDefaultProtocol() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/override-protocol.xml");
ctx.start();
ProtocolConfig protocolConfig = ctx.getBean(ProtocolConfig.class);
protocolConfig.refresh();
assertThat(protocolConfig.getName(), is("dubbo"));
ctx.close();
}
use of org.apache.dubbo.config.ProtocolConfig in project dubbo by alibaba.
the class DubboNamespaceHandlerTest method testMultiProtocol.
@Test
public void testMultiProtocol() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol.xml");
ctx.start();
Map<String, ProtocolConfig> protocolConfigMap = ctx.getBeansOfType(ProtocolConfig.class);
assertThat(protocolConfigMap.size(), is(2));
ProtocolConfig rmiProtocolConfig = protocolConfigMap.get("rmi");
assertThat(rmiProtocolConfig.getPort(), is(10991));
ProtocolConfig dubboProtocolConfig = protocolConfigMap.get("dubbo");
assertThat(dubboProtocolConfig.getPort(), is(20881));
ctx.close();
}
Aggregations