Search in sources :

Example 1 with ModuleConfig

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

the class AbstractInterfaceBuilderTest method module.

@Test
void module() {
    ModuleConfig moduleConfig = new ModuleConfig();
    InterfaceBuilder builder = new InterfaceBuilder();
    builder.module(moduleConfig);
    Assertions.assertEquals(moduleConfig, builder.build().getModule());
}
Also used : ModuleConfig(org.apache.dubbo.config.ModuleConfig) Test(org.junit.jupiter.api.Test)

Example 2 with ModuleConfig

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

the class AbstractInterfaceBuilderTest method build.

@Test
void build() {
    MonitorConfig monitorConfig = new MonitorConfig("123");
    ApplicationConfig applicationConfig = new ApplicationConfig();
    ModuleConfig moduleConfig = new ModuleConfig();
    RegistryConfig registryConfig = new RegistryConfig();
    MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
    ConfigCenterConfig configCenterConfig = new ConfigCenterConfig();
    InterfaceBuilder builder = new InterfaceBuilder();
    builder.id("id").prefix("prefix").local(true).stub(false).monitor("123").proxy("mockproxyfactory").cluster("mockcluster").filter("mockfilter").listener("mockinvokerlistener").owner("owner").connections(1).layer("layer").application(applicationConfig).module(moduleConfig).addRegistry(registryConfig).registryIds("registryIds").onconnect("onconnet").ondisconnect("ondisconnect").metadataReportConfig(metadataReportConfig).configCenter(configCenterConfig).callbacks(2).scope("scope");
    InterfaceConfig config = builder.build();
    InterfaceConfig config2 = builder.build();
    Assertions.assertEquals("id", config.getId());
    Assertions.assertEquals("prefix", config.getPrefix());
    Assertions.assertEquals("true", config.getLocal());
    Assertions.assertEquals("false", config.getStub());
    Assertions.assertEquals(monitorConfig, config.getMonitor());
    Assertions.assertEquals("mockproxyfactory", config.getProxy());
    Assertions.assertEquals("mockcluster", config.getCluster());
    Assertions.assertEquals("mockfilter", config.getFilter());
    Assertions.assertEquals("mockinvokerlistener", config.getListener());
    Assertions.assertEquals("owner", config.getOwner());
    Assertions.assertEquals(1, config.getConnections().intValue());
    Assertions.assertEquals("layer", config.getLayer());
    Assertions.assertEquals(applicationConfig, config.getApplication());
    Assertions.assertEquals(moduleConfig, config.getModule());
    Assertions.assertEquals(registryConfig, config.getRegistry());
    Assertions.assertEquals("registryIds", config.getRegistryIds());
    Assertions.assertEquals("onconnet", config.getOnconnect());
    Assertions.assertEquals("ondisconnect", config.getOndisconnect());
    Assertions.assertEquals(metadataReportConfig, config.getMetadataReportConfig());
    Assertions.assertEquals(configCenterConfig, config.getConfigCenter());
    Assertions.assertEquals(2, config.getCallbacks().intValue());
    Assertions.assertEquals("scope", config.getScope());
    Assertions.assertNotSame(config, config2);
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ConfigCenterConfig(org.apache.dubbo.config.ConfigCenterConfig) AbstractInterfaceConfig(org.apache.dubbo.config.AbstractInterfaceConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ModuleConfig(org.apache.dubbo.config.ModuleConfig) MetadataReportConfig(org.apache.dubbo.config.MetadataReportConfig) MonitorConfig(org.apache.dubbo.config.MonitorConfig) Test(org.junit.jupiter.api.Test)

Example 3 with ModuleConfig

use of org.apache.dubbo.config.ModuleConfig 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 4 with ModuleConfig

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

the class DubboNamespaceHandlerTest method testModuleInfo.

// @Test
// public void testMultiMonitor() {
// Assertions.assertThrows(BeanCreationException.class, () -> {
// ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-monitor.xml");
// ctx.start();
// });
// }
// 
// @Test
// public void testMultiProviderConfig() {
// Assertions.assertThrows(BeanCreationException.class, () -> {
// ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/provider-multi.xml");
// ctx.start();
// });
// }
@Test
public void testModuleInfo() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/provider-with-module.xml");
    ctx.start();
    ModuleConfig moduleConfig = ctx.getBean(ModuleConfig.class);
    assertThat(moduleConfig.getName(), is("test-module"));
    ctx.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ModuleConfig(org.apache.dubbo.config.ModuleConfig) Test(org.junit.jupiter.api.Test) ConfigTest(org.apache.dubbo.config.spring.ConfigTest)

Example 5 with ModuleConfig

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

the class DubboBootstrap method getModule.

private ModuleConfig getModule() {
    ModuleConfig module = configManager.getModule().orElseGet(() -> {
        ModuleConfig moduleConfig = new ModuleConfig();
        configManager.setModule(moduleConfig);
        return moduleConfig;
    });
    module.refresh();
    return module;
}
Also used : ModuleConfig(org.apache.dubbo.config.ModuleConfig)

Aggregations

ModuleConfig (org.apache.dubbo.config.ModuleConfig)11 Test (org.junit.jupiter.api.Test)7 RegistryConfig (org.apache.dubbo.config.RegistryConfig)4 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)3 MonitorConfig (org.apache.dubbo.config.MonitorConfig)3 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)2 AbstractInterfaceConfig (org.apache.dubbo.config.AbstractInterfaceConfig)1 ConfigCenterConfig (org.apache.dubbo.config.ConfigCenterConfig)1 ConsumerConfig (org.apache.dubbo.config.ConsumerConfig)1 MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)1 ProviderConfig (org.apache.dubbo.config.ProviderConfig)1 ConfigTest (org.apache.dubbo.config.spring.ConfigTest)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1