use of example.scannable.FooService in project spring-framework by spring-projects.
the class ComponentScanWithBasePackagesAndValueAlias method withScopedProxyThroughAspectJPattern.
@Test
public void withScopedProxyThroughAspectJPattern() throws IOException, ClassNotFoundException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(ComponentScanWithScopedProxyThroughAspectJPattern.class);
ctx.getBeanFactory().registerScope("myScope", new SimpleMapScope());
ctx.refresh();
// should cast to the interface
FooService bean = (FooService) ctx.getBean("scopedProxyTestBean");
// should be dynamic proxy
assertThat(AopUtils.isJdkDynamicProxy(bean), is(true));
}
use of example.scannable.FooService in project spring-framework by spring-projects.
the class SimpleConfigTests method testFooService.
@Test
public void testFooService() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass());
FooService fooService = ctx.getBean("fooServiceImpl", FooService.class);
ServiceInvocationCounter serviceInvocationCounter = ctx.getBean("serviceInvocationCounter", ServiceInvocationCounter.class);
String value = fooService.foo(1);
assertEquals("bar", value);
Future<?> future = fooService.asyncFoo(1);
assertTrue(future instanceof FutureTask);
assertEquals("bar", future.get());
assertEquals(2, serviceInvocationCounter.getCount());
fooService.foo(1);
assertEquals(3, serviceInvocationCounter.getCount());
}
Aggregations