use of example.scannable.ServiceInvocationCounter in project spring-framework by spring-projects.
the class EnableAspectJAutoProxyTests method aspectIsApplied.
private void aspectIsApplied(ApplicationContext ctx) {
FooService fooService = ctx.getBean(FooService.class);
ServiceInvocationCounter counter = ctx.getBean(ServiceInvocationCounter.class);
assertEquals(0, counter.getCount());
assertTrue(fooService.isInitCalled());
assertEquals(1, counter.getCount());
String value = fooService.foo(1);
assertEquals("bar", value);
assertEquals(2, counter.getCount());
fooService.foo(1);
assertEquals(3, counter.getCount());
}
use of example.scannable.ServiceInvocationCounter in project spring-framework by spring-projects.
the class SimpleScanTests method testFooService.
@Test
public void testFooService() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass());
FooService fooService = (FooService) ctx.getBean("fooServiceImpl");
ServiceInvocationCounter serviceInvocationCounter = (ServiceInvocationCounter) ctx.getBean("serviceInvocationCounter");
assertEquals(0, serviceInvocationCounter.getCount());
assertTrue(fooService.isInitCalled());
assertEquals(1, serviceInvocationCounter.getCount());
String value = fooService.foo(1);
assertEquals("bar", value);
assertEquals(2, serviceInvocationCounter.getCount());
fooService.foo(1);
assertEquals(3, serviceInvocationCounter.getCount());
}
use of example.scannable.ServiceInvocationCounter 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