Search in sources :

Example 6 with ProtocolConfig

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

the class AbstractServiceBuilderTest method build.

@Test
void build() {
    ProtocolConfig protocol = new ProtocolConfig();
    ServiceBuilder builder = new ServiceBuilder();
    builder.version("version").group("group").deprecated(true).delay(1000).export(false).weight(1).document("document").dynamic(true).token("token").accesslog("accesslog").addProtocol(protocol).protocolIds("protocolIds").tag("tag").executes(100).register(false).warmup(200).serialization("serialization").id("id").prefix("prefix");
    ServiceConfig config = builder.build();
    ServiceConfig config2 = builder.build();
    Assertions.assertEquals("id", config.getId());
    Assertions.assertEquals("prefix", config.getPrefix());
    Assertions.assertEquals("version", config.getVersion());
    Assertions.assertEquals("group", config.getGroup());
    Assertions.assertEquals("document", config.getDocument());
    Assertions.assertEquals("token", config.getToken());
    Assertions.assertEquals("accesslog", config.getAccesslog());
    Assertions.assertEquals("protocolIds", config.getProtocolIds());
    Assertions.assertEquals("tag", config.getTag());
    Assertions.assertEquals("serialization", config.getSerialization());
    Assertions.assertTrue(config.isDeprecated());
    Assertions.assertFalse(config.getExport());
    Assertions.assertTrue(config.isDynamic());
    Assertions.assertFalse(config.isRegister());
    Assertions.assertEquals(1000, config.getDelay());
    Assertions.assertEquals(1, config.getWeight());
    Assertions.assertEquals(100, config.getExecutes());
    Assertions.assertEquals(200, config.getWarmup());
    Assertions.assertNotSame(config, config2);
}
Also used : AbstractServiceConfig(org.apache.dubbo.config.AbstractServiceConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 7 with ProtocolConfig

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

the class AbstractServiceBuilderTest method addProtocol.

@Test
void addProtocol() {
    ProtocolConfig protocol = new ProtocolConfig();
    ServiceBuilder builder = new ServiceBuilder();
    Assertions.assertNull(builder.build().getProtocols());
    builder.addProtocol(protocol);
    Assertions.assertNotNull(builder.build().getProtocols());
    Assertions.assertEquals(1, builder.build().getProtocols().size());
    Assertions.assertEquals(protocol, builder.build().getProtocol());
}
Also used : ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 8 with ProtocolConfig

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

the class ConfigManagerTest method testDefaultConfig.

@Test
public void testDefaultConfig() {
    ProviderConfig providerConfig = new ProviderConfig();
    providerConfig.setDefault(false);
    assertFalse(ConfigManager.isDefaultConfig(providerConfig));
    ProviderConfig providerConfig1 = new ProviderConfig();
    assertTrue(ConfigManager.isDefaultConfig(providerConfig1));
    ProviderConfig providerConfig3 = new ProviderConfig();
    providerConfig.setDefault(true);
    assertTrue(ConfigManager.isDefaultConfig(providerConfig3));
    ProtocolConfig protocolConfig = new ProtocolConfig();
    protocolConfig.setDefault(false);
    assertFalse(ConfigManager.isDefaultConfig(protocolConfig));
}
Also used : ProviderConfig(org.apache.dubbo.config.ProviderConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 9 with ProtocolConfig

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

the class ConfigManagerTest method testProtocolConfig.

// Test ProtocolConfig correlative methods
@Test
public void testProtocolConfig() {
    ProtocolConfig config = new ProtocolConfig();
    configManager.addProtocols(asList(config, null));
    Collection<ProtocolConfig> configs = configManager.getProtocols();
    assertEquals(1, configs.size());
    assertEquals(config, configs.iterator().next());
    assertFalse(configManager.getDefaultProtocols().isEmpty());
}
Also used : ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 10 with ProtocolConfig

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

the class ConfigTest method testDubboProtocolPortOverride.

@Test
public void testDubboProtocolPortOverride() throws Exception {
    String dubboPort = System.getProperty("dubbo.protocol.dubbo.port");
    int port = 55555;
    System.setProperty("dubbo.protocol.dubbo.port", String.valueOf(port));
    ServiceConfig<DemoService> service = null;
    DubboBootstrap bootstrap = null;
    try {
        ApplicationConfig application = new ApplicationConfig();
        application.setName("dubbo-protocol-port-override");
        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("N/A");
        ProtocolConfig protocol = new ProtocolConfig();
        service = new ServiceConfig<DemoService>();
        service.setInterface(DemoService.class);
        service.setRef(new DemoServiceImpl());
        service.setApplication(application);
        service.setRegistry(registry);
        service.setProtocol(protocol);
        DubboBootstrap.getInstance().application(application).registry(registry).protocol(protocol).service(service).start();
        Assertions.assertEquals(port, service.getExportedUrls().get(0).getPort());
    } finally {
        if (StringUtils.isNotEmpty(dubboPort)) {
            System.setProperty("dubbo.protocol.dubbo.port", dubboPort);
        }
        if (bootstrap != null) {
            bootstrap.stop();
        }
    }
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) DemoService(org.apache.dubbo.config.spring.api.DemoService) DubboBootstrap(org.apache.dubbo.config.bootstrap.DubboBootstrap) Matchers.containsString(org.hamcrest.Matchers.containsString) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) DemoServiceImpl(org.apache.dubbo.config.spring.impl.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

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