Search in sources :

Example 21 with ProtocolConfig

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;
}
Also used : ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Bean(org.springframework.context.annotation.Bean)

Example 22 with 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());
}
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 23 with ProtocolConfig

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());
}
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 24 with ProtocolConfig

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();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test) ConfigTest(org.apache.dubbo.config.spring.ConfigTest)

Example 25 with ProtocolConfig

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();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test) ConfigTest(org.apache.dubbo.config.spring.ConfigTest)

Aggregations

ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)52 Test (org.junit.jupiter.api.Test)30 RegistryConfig (org.apache.dubbo.config.RegistryConfig)29 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)27 ServiceConfig (org.apache.dubbo.config.ServiceConfig)14 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)11 ReferenceConfig (org.apache.dubbo.config.ReferenceConfig)8 DemoService (org.apache.dubbo.config.spring.api.DemoService)8 DemoServiceImpl (org.apache.dubbo.config.spring.impl.DemoServiceImpl)7 ArrayList (java.util.ArrayList)6 ProviderConfig (org.apache.dubbo.config.ProviderConfig)6 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)6 GenericService (org.apache.dubbo.rpc.service.GenericService)5 Map (java.util.Map)4 URL (org.apache.dubbo.common.URL)4 Bean (org.springframework.context.annotation.Bean)4 List (java.util.List)3 ConsumerConfig (org.apache.dubbo.config.ConsumerConfig)3 ConfigTest (org.apache.dubbo.config.spring.ConfigTest)3 Test (org.junit.Test)3