use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.
the class ConfigTest method testGenericServiceConfig.
@Test
public void testGenericServiceConfig() throws Exception {
ServiceConfig<GenericService> service = new ServiceConfig<GenericService>();
service.setRegistry(new RegistryConfig("mock://localhost"));
service.setInterface(DemoService.class.getName());
service.setGeneric(GENERIC_SERIALIZATION_BEAN);
service.setRef((method, parameterTypes, args) -> null);
DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(new ApplicationConfig("test")).service(service).start();
try {
Collection<Registry> collection = MockRegistryFactory.getCachedRegistry();
MockRegistry registry = (MockRegistry) collection.iterator().next();
URL url = registry.getRegistered().get(0);
Assertions.assertEquals(GENERIC_SERIALIZATION_BEAN, url.getParameter(GENERIC_KEY));
} finally {
MockRegistryFactory.cleanCachedRegistry();
bootstrap.stop();
}
}
use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.
the class AbstractAnnotationConfigBeanBuilder method configureApplicationConfig.
private void configureApplicationConfig(B bean) {
String applicationConfigBeanName = resolveApplicationConfigBeanName(annotation);
ApplicationConfig applicationConfig = getOptionalBean(applicationContext, applicationConfigBeanName, ApplicationConfig.class);
bean.setApplication(applicationConfig);
}
use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.
the class ConfigTest method testSystemPropertyOverrideApi.
@Test
public void testSystemPropertyOverrideApi() throws Exception {
System.setProperty("dubbo.application.name", "sysover");
System.setProperty("dubbo.application.owner", "sysowner");
System.setProperty("dubbo.registry.address", "N/A");
System.setProperty("dubbo.protocol.name", "dubbo");
System.setProperty("dubbo.protocol.port", "20834");
try {
ApplicationConfig application = new ApplicationConfig();
application.setName("aaa");
RegistryConfig registry = new RegistryConfig();
registry.setAddress("127.0.0.1");
ProtocolConfig protocol = new ProtocolConfig();
protocol.setName("rmi");
protocol.setPort(1099);
ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
service.setInterface(DemoService.class);
service.setRef(new DemoServiceImpl());
service.setApplication(application);
service.setRegistry(registry);
service.setProtocol(protocol);
DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(application).registry(registry).protocol(protocol).service(service).start();
try {
URL url = service.getExportedUrls().get(0);
assertEquals("sysover", url.getParameter("application"));
assertEquals("sysowner", url.getParameter("owner"));
assertEquals("dubbo", url.getProtocol());
assertEquals(20834, url.getPort());
} finally {
bootstrap.stop();
}
} finally {
System.setProperty("dubbo.application.name", "");
System.setProperty("dubbo.application.owner", "");
System.setProperty("dubbo.registry.address", "");
System.setProperty("dubbo.protocol.name", "");
System.setProperty("dubbo.protocol.port", "");
}
}
use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.
the class ReferenceConfigCacheTest method buildXxxMockReferenceConfig.
private XxxMockReferenceConfig buildXxxMockReferenceConfig(String service, String group, String version) {
XxxMockReferenceConfig config = new XxxMockReferenceConfig();
config.setApplication(new ApplicationConfig("cache"));
config.setRegistry(new RegistryConfig("multicast://224.5.6.7:1234"));
config.setInterface(service);
config.setCheck(false);
config.setGroup(group);
config.setVersion(version);
return config;
}
use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.
the class MetadataServiceExporterTest method init.
@BeforeAll
public static void init() {
ApplicationModel.reset();
ApplicationModel.getConfigManager().setApplication(new ApplicationConfig("Test"));
ApplicationModel.getConfigManager().addRegistry(new RegistryConfig("test://1.2.3.4"));
ApplicationModel.getConfigManager().addProtocol(new ProtocolConfig("injvm"));
}
Aggregations