@ThreadedTest
 public void getPosition_afterCall() throws Exception {
   SimpleClass2 target = recorder.createTarget(SimpleClass2.class);
   control.add(0, 0);
   CodePosition cp =
       recorder.in(control.callSecond()).afterCalling(target.setPosition(null, 0)).position();
   CodePosition verification =
       ic.afterCall(
           SimpleClass.class.getDeclaredMethod("callSecond"),
           SimpleClass2.class.getDeclaredMethod("setPosition", SimpleClass.class, int.class));
   assertTrue(verification.matches(cp));
 }
  @Test
  public void shouldLogUsingInterceptor() {
    givenLogLevel(INFO);

    simpleClass.foo();

    verify(log).info("foo", NO_ARGS);
  }
 @ThreadedTest
 public void getPosition_atEndOfLastMethod() throws Exception {
   control.add(0, 0);
   CodePosition cp = recorder.atEndOfLastMethod().position();
   CodePosition verification =
       ic.atMethodEnd(SimpleClass.class.getDeclaredMethod("add", int.class, int.class));
   assertTrue(verification.matches(cp));
 }
 @ThreadedTest
 public void getPosition_atStart() throws Exception {
   final SimpleInteger value = new SimpleInteger(0);
   CodePosition cp = recorder.atStartOf(control.add(value, value)).position();
   CodePosition verification =
       ic.atMethodStart(
           SimpleClass.class.getDeclaredMethod("add", SimpleInteger.class, SimpleInteger.class));
   assertTrue(verification.matches(cp));
 }
  @Test
  public void shouldCacheLogPoint() {
    givenLogLevel(INFO);
    assertTrue(LoggingInterceptor.CACHE.isEmpty());

    // the timing stuff is not very robust... but sometimes helpful ;)
    // long t0 = System.nanoTime();
    simpleClass.foo();
    // long t1 = System.nanoTime();
    simpleClass.foo();
    // long t2 = System.nanoTime();

    // long d0 = t1 - t0;
    // long d1 = t2 - t1;

    verify(log, times(2)).info("foo", NO_ARGS); // actually did log twice
    // assertTrue("expected second (cached) call must be faster, but actually " + d0 + " <= " + d1,
    // d0 > d1);
    assertFalse(LoggingInterceptor.CACHE.isEmpty());
  }