Package example.scannable

Examples of example.scannable.ServiceInvocationCounter


  @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());
  }
View Full Code Here


  @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());
  }
View Full Code Here

  }


  private void aspectIsApplied(ApplicationContext ctx) throws Exception {
    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());
  }
View Full Code Here

TOP

Related Classes of example.scannable.ServiceInvocationCounter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.