use of org.apache.dubbo.config.spring.api.DemoService in project dubbo by alibaba.
the class ConfigTest method testProviderNestedService.
@Test
@SuppressWarnings("unchecked")
public void testProviderNestedService() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/provider-nested-service.xml");
ctx.start();
try {
ServiceConfig<DemoService> serviceConfig = (ServiceConfig<DemoService>) ctx.getBean("serviceConfig");
assertNotNull(serviceConfig.getProvider());
assertEquals(2000, serviceConfig.getProvider().getTimeout().intValue());
ServiceConfig<DemoService> serviceConfig2 = (ServiceConfig<DemoService>) ctx.getBean("serviceConfig2");
assertNotNull(serviceConfig2.getProvider());
assertEquals(1000, serviceConfig2.getProvider().getTimeout().intValue());
} finally {
ctx.stop();
ctx.close();
}
}
use of org.apache.dubbo.config.spring.api.DemoService in project dubbo by alibaba.
the class ReferenceAnnotationBeanPostProcessorTest method test.
@Test
public void test() throws Exception {
assertTrue(context.containsBean("helloService"));
TestBean testBean = context.getBean(TestBean.class);
DemoService demoService = testBean.getDemoService();
Map<String, DemoService> demoServicesMap = context.getBeansOfType(DemoService.class);
Assertions.assertNotNull(testBean.getDemoServiceFromAncestor());
Assertions.assertNotNull(testBean.getDemoServiceFromParent());
Assertions.assertNotNull(testBean.getDemoService());
Assertions.assertNotNull(testBean.autowiredDemoService);
Assertions.assertEquals(1, demoServicesMap.size());
String expectedResult = "Hello,Mercy" + AOP_SUFFIX;
Assertions.assertEquals(expectedResult, testBean.autowiredDemoService.sayName("Mercy"));
Assertions.assertEquals(expectedResult, demoService.sayName("Mercy"));
Assertions.assertEquals("Greeting, Mercy", defaultHelloService.sayHello("Mercy"));
Assertions.assertEquals("Hello, Mercy", helloServiceImpl.sayHello("Mercy"));
Assertions.assertEquals("Greeting, Mercy", helloService.sayHello("Mercy"));
Assertions.assertEquals(expectedResult, testBean.getDemoServiceFromAncestor().sayName("Mercy"));
Assertions.assertEquals(expectedResult, testBean.getDemoServiceFromParent().sayName("Mercy"));
Assertions.assertEquals(expectedResult, testBean.getDemoService().sayName("Mercy"));
DemoService myDemoService = context.getBean("my-reference-bean", DemoService.class);
Assertions.assertEquals(expectedResult, myDemoService.sayName("Mercy"));
for (DemoService demoService1 : demoServicesMap.values()) {
Assertions.assertEquals(myDemoService, demoService1);
Assertions.assertEquals(expectedResult, demoService1.sayName("Mercy"));
}
}
use of org.apache.dubbo.config.spring.api.DemoService in project dubbo by alibaba.
the class EnableDubboTest method testProvider.
@Test
public void testProvider() {
context.register(TestProviderConfiguration.class);
context.refresh();
DemoService demoService = context.getBean(DemoService.class);
String value = demoService.sayName("Mercy");
Assertions.assertEquals("Hello,Mercy", value);
Class<?> beanClass = AopUtils.getTargetClass(demoService);
// DemoServiceImpl with @Transactional
Assertions.assertEquals(DemoServiceImpl.class, beanClass);
// Test @Transactional is present or not
Assertions.assertNotNull(findAnnotation(beanClass, Transactional.class));
}
use of org.apache.dubbo.config.spring.api.DemoService in project dubbo by alibaba.
the class SpringExtensionFactoryTest method testGetExtensionByName.
@Test
public void testGetExtensionByName() {
DemoService bean = springExtensionFactory.getExtension(DemoService.class, "bean1");
Assertions.assertNotNull(bean);
HelloService hello = springExtensionFactory.getExtension(HelloService.class, "hello");
Assertions.assertNotNull(hello);
}
use of org.apache.dubbo.config.spring.api.DemoService in project dubbo by alibaba.
the class DubboNamespaceHandlerTest method testProviderXml.
private void testProviderXml(ApplicationContext context) {
ProtocolConfig protocolConfig = context.getBean(ProtocolConfig.class);
assertThat(protocolConfig, not(nullValue()));
assertThat(protocolConfig.getName(), is("dubbo"));
assertThat(protocolConfig.getPort(), is(20813));
ApplicationConfig applicationConfig = context.getBean(ApplicationConfig.class);
assertThat(applicationConfig, not(nullValue()));
assertThat(applicationConfig.getName(), is("demo-provider"));
DemoService service = context.getBean(DemoService.class);
assertThat(service, not(nullValue()));
}
Aggregations