Search in sources :

Example 51 with ApplicationConfig

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();
    }
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) GenericService(org.apache.dubbo.rpc.service.GenericService) ServiceConfig(org.apache.dubbo.config.ServiceConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) MockRegistry(org.apache.dubbo.config.spring.registry.MockRegistry) DemoService(org.apache.dubbo.config.spring.api.DemoService) DubboBootstrap(org.apache.dubbo.config.bootstrap.DubboBootstrap) MockRegistry(org.apache.dubbo.config.spring.registry.MockRegistry) Registry(org.apache.dubbo.registry.Registry) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Example 52 with ApplicationConfig

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);
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig)

Example 53 with 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", "");
    }
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ServiceConfig(org.apache.dubbo.config.ServiceConfig) DemoService(org.apache.dubbo.config.spring.api.DemoService) DubboBootstrap(org.apache.dubbo.config.bootstrap.DubboBootstrap) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) URL(org.apache.dubbo.common.URL) DemoServiceImpl(org.apache.dubbo.config.spring.impl.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 54 with ApplicationConfig

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;
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig)

Example 55 with ApplicationConfig

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"));
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)75 RegistryConfig (org.apache.dubbo.config.RegistryConfig)42 Test (org.junit.jupiter.api.Test)32 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)27 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)19 ServiceConfig (org.apache.dubbo.config.ServiceConfig)18 ReferenceConfig (org.apache.dubbo.config.ReferenceConfig)16 DemoService (org.apache.dubbo.config.spring.api.DemoService)13 URL (org.apache.dubbo.common.URL)9 GenericService (org.apache.dubbo.rpc.service.GenericService)8 Test (org.junit.Test)8 DemoServiceImpl (org.apache.dubbo.config.spring.impl.DemoServiceImpl)7 ArrayList (java.util.ArrayList)6 MonitorConfig (org.apache.dubbo.config.MonitorConfig)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 AbstractInterfaceConfigTest (org.apache.dubbo.config.AbstractInterfaceConfigTest)4 UserService (org.apache.dubbo.config.bootstrap.rest.UserService)4 MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)3 ModuleConfig (org.apache.dubbo.config.ModuleConfig)3 UserServiceImpl (org.apache.dubbo.config.bootstrap.rest.UserServiceImpl)3