Search in sources :

Example 1 with AnnotationAction

use of com.alibaba.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(com.alibaba.dubbo.config.spring.annotation.consumer.AnnotationAction) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) RegistryService(com.alibaba.dubbo.registry.RegistryService) Test(org.junit.Test)

Aggregations

AnnotationAction (com.alibaba.dubbo.config.spring.annotation.consumer.AnnotationAction)1 RegistryService (com.alibaba.dubbo.registry.RegistryService)1 Test (org.junit.Test)1 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1