Search in sources :

Example 1 with AnnotationAction

use of org.apache.dubbo.config.spring.annotation.consumer.AnnotationAction in project dubbo by alibaba.

the class ConfigTest method testAnnotation.

@Test
public void testAnnotation() {
    SimpleRegistryService registryService = new SimpleRegistryService();
    Exporter<RegistryService> exporter = SimpleRegistryExporter.export(4548, registryService);
    try {
        ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/annotation-provider.xml");
        providerContext.start();
        try {
            ClassPathXmlApplicationContext consumerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/annotation-consumer.xml");
            consumerContext.start();
            try {
                AnnotationAction annotationAction = (AnnotationAction) consumerContext.getBean("annotationAction");
                String hello = annotationAction.doSayName("hello");
                assertEquals("annotation:hello", hello);
            } finally {
                consumerContext.stop();
                consumerContext.close();
            }
        } finally {
            providerContext.stop();
            providerContext.close();
        }
    } finally {
        exporter.unexport();
    }
}
Also used : AnnotationAction(org.apache.dubbo.config.spring.annotation.consumer.AnnotationAction) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Matchers.containsString(org.hamcrest.Matchers.containsString) RegistryService(org.apache.dubbo.registry.RegistryService) Test(org.junit.jupiter.api.Test)

Aggregations

AnnotationAction (org.apache.dubbo.config.spring.annotation.consumer.AnnotationAction)1 RegistryService (org.apache.dubbo.registry.RegistryService)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.jupiter.api.Test)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1