Search in sources :

Example 1 with ConsumerConfig

use of com.alibaba.dubbo.config.ConsumerConfig in project dubbo by alibaba.

the class InvokerSideConfigUrlTest method initRefConf.

// ======================================================
//   private helper
// ====================================================== 
private void initRefConf() {
    appConfForConsumer = new ApplicationConfig();
    appConfForReference = new ApplicationConfig();
    regConfForConsumer = new RegistryConfig();
    regConfForReference = new RegistryConfig();
    methodConfForReference = new MethodConfig();
    refConf = new ReferenceConfig<DemoService>();
    consumerConf = new ConsumerConfig();
    methodConfForReference.setName("sayName");
    regConfForReference.setAddress("127.0.0.1:9090");
    regConfForReference.setProtocol("mockregistry");
    appConfForReference.setName("ConfigTests");
    refConf.setInterface("com.alibaba.dubbo.config.api.DemoService");
    refConf.setApplication(appConfForReference);
    consumerConf.setApplication(appConfForConsumer);
    refConf.setRegistry(regConfForReference);
    consumerConf.setRegistry(regConfForConsumer);
    refConf.setConsumer(consumerConf);
    refConf.setMethods(Arrays.asList(new MethodConfig[] { methodConfForReference }));
    refConf.setScope(Constants.SCOPE_REMOTE);
}
Also used : RegistryConfig(com.alibaba.dubbo.config.RegistryConfig) MethodConfig(com.alibaba.dubbo.config.MethodConfig) ApplicationConfig(com.alibaba.dubbo.config.ApplicationConfig) DemoService(com.alibaba.dubbo.config.api.DemoService) ConsumerConfig(com.alibaba.dubbo.config.ConsumerConfig)

Example 2 with ConsumerConfig

use of com.alibaba.dubbo.config.ConsumerConfig in project dubbo by alibaba.

the class ConfigTest method testAppendFilter.

@Test
public void testAppendFilter() throws Exception {
    ProviderConfig provider = new ProviderConfig();
    provider.setFilter("classloader,monitor");
    ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
    service.setFilter("accesslog,trace");
    service.setProvider(provider);
    service.setProtocol(new ProtocolConfig("dubbo", 20880));
    service.setApplication(new ApplicationConfig("provider"));
    service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
    service.setInterface(DemoService.class);
    service.setRef(new DemoServiceImpl());
    try {
        service.export();
        List<URL> urls = service.toUrls();
        assertNotNull(urls);
        assertEquals(1, urls.size());
        assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("service.filter"));
        ConsumerConfig consumer = new ConsumerConfig();
        consumer.setFilter("classloader,monitor");
        ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
        reference.setFilter("accesslog,trace");
        reference.setConsumer(consumer);
        reference.setApplication(new ApplicationConfig("consumer"));
        reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
        reference.setInterface(DemoService.class);
        reference.setUrl("dubbo://" + NetUtils.getLocalHost() + ":20880?" + DemoService.class.getName() + "?check=false");
        try {
            reference.get();
            urls = reference.toUrls();
            assertNotNull(urls);
            assertEquals(1, urls.size());
            assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("reference.filter"));
        } finally {
            reference.destroy();
        }
    } finally {
        service.unexport();
    }
}
Also used : RegistryConfig(com.alibaba.dubbo.config.RegistryConfig) ProviderConfig(com.alibaba.dubbo.config.ProviderConfig) DemoService(com.alibaba.dubbo.config.spring.api.DemoService) URL(com.alibaba.dubbo.common.URL) ServiceConfig(com.alibaba.dubbo.config.ServiceConfig) ApplicationConfig(com.alibaba.dubbo.config.ApplicationConfig) ReferenceConfig(com.alibaba.dubbo.config.ReferenceConfig) ConsumerConfig(com.alibaba.dubbo.config.ConsumerConfig) ProtocolConfig(com.alibaba.dubbo.config.ProtocolConfig) DemoServiceImpl(com.alibaba.dubbo.config.spring.impl.DemoServiceImpl) Test(org.junit.Test)

Example 3 with ConsumerConfig

use of com.alibaba.dubbo.config.ConsumerConfig in project dubbo by alibaba.

the class ConfigTest method testRmiTimeout.

@Test
public void testRmiTimeout() throws Exception {
    if (System.getProperty("sun.rmi.transport.tcp.responseTimeout") != null) {
        System.setProperty("sun.rmi.transport.tcp.responseTimeout", "");
    }
    ConsumerConfig consumer = new ConsumerConfig();
    consumer.setTimeout(1000);
    assertEquals("1000", System.getProperty("sun.rmi.transport.tcp.responseTimeout"));
    consumer.setTimeout(2000);
    assertEquals("1000", System.getProperty("sun.rmi.transport.tcp.responseTimeout"));
}
Also used : ConsumerConfig(com.alibaba.dubbo.config.ConsumerConfig) Test(org.junit.Test)

Aggregations

ConsumerConfig (com.alibaba.dubbo.config.ConsumerConfig)3 ApplicationConfig (com.alibaba.dubbo.config.ApplicationConfig)2 RegistryConfig (com.alibaba.dubbo.config.RegistryConfig)2 Test (org.junit.Test)2 URL (com.alibaba.dubbo.common.URL)1 MethodConfig (com.alibaba.dubbo.config.MethodConfig)1 ProtocolConfig (com.alibaba.dubbo.config.ProtocolConfig)1 ProviderConfig (com.alibaba.dubbo.config.ProviderConfig)1 ReferenceConfig (com.alibaba.dubbo.config.ReferenceConfig)1 ServiceConfig (com.alibaba.dubbo.config.ServiceConfig)1 DemoService (com.alibaba.dubbo.config.api.DemoService)1 DemoService (com.alibaba.dubbo.config.spring.api.DemoService)1 DemoServiceImpl (com.alibaba.dubbo.config.spring.impl.DemoServiceImpl)1