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