Search in sources :

Example 1 with TestConsumerConfiguration

use of org.apache.dubbo.config.spring.context.annotation.consumer.test.TestConsumerConfiguration in project dubbo by alibaba.

the class EnableDubboTest method testConsumer.

@Test
public void testConsumer() {
    context.register(TestProviderConfiguration.class, TestConsumerConfiguration.class);
    context.refresh();
    TestConsumerConfiguration consumerConfiguration = context.getBean(TestConsumerConfiguration.class);
    DemoService demoService = consumerConfiguration.getDemoService();
    String value = demoService.sayName("Mercy");
    Assertions.assertEquals("Hello,Mercy", value);
    DemoService autowiredDemoService = consumerConfiguration.getAutowiredDemoService();
    Assertions.assertEquals("Hello,Mercy", autowiredDemoService.sayName("Mercy"));
    TestConsumerConfiguration.Child child = context.getBean(TestConsumerConfiguration.Child.class);
    // From Child
    demoService = child.getDemoServiceFromChild();
    Assertions.assertNotNull(demoService);
    value = demoService.sayName("Mercy");
    Assertions.assertEquals("Hello,Mercy", value);
    // From Parent
    demoService = child.getDemoServiceFromParent();
    Assertions.assertNotNull(demoService);
    value = demoService.sayName("Mercy");
    Assertions.assertEquals("Hello,Mercy", value);
    // From Ancestor
    demoService = child.getDemoServiceFromAncestor();
    Assertions.assertNotNull(demoService);
    value = demoService.sayName("Mercy");
    Assertions.assertEquals("Hello,Mercy", value);
    // Test my-registry2 bean presentation
    RegistryConfig registryConfig = context.getBean("my-registry2", RegistryConfig.class);
    // Test multiple binding
    Assertions.assertEquals("N/A", registryConfig.getAddress());
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) TestConsumerConfiguration(org.apache.dubbo.config.spring.context.annotation.consumer.test.TestConsumerConfiguration) DemoService(org.apache.dubbo.config.spring.api.DemoService) Test(org.junit.jupiter.api.Test)

Aggregations

RegistryConfig (org.apache.dubbo.config.RegistryConfig)1 DemoService (org.apache.dubbo.config.spring.api.DemoService)1 TestConsumerConfiguration (org.apache.dubbo.config.spring.context.annotation.consumer.test.TestConsumerConfiguration)1 Test (org.junit.jupiter.api.Test)1