예제 #1
0
  @Test
  public void test0() {
    InterceptorScopeInvocation transaction = new DefaultInterceptorScopeInvocation("test");

    assertFalse(transaction.isActive());

    assertFalse(transaction.tryEnter(ExecutionPolicy.INTERNAL));
    assertFalse(transaction.isActive());

    assertTrue(transaction.tryEnter(ExecutionPolicy.BOUNDARY));
    assertTrue(transaction.isActive());

    assertTrue(transaction.tryEnter(ExecutionPolicy.INTERNAL));
    assertTrue(transaction.isActive());

    assertFalse(transaction.tryEnter(ExecutionPolicy.BOUNDARY));
    assertTrue(transaction.isActive());

    assertFalse(transaction.canLeave(ExecutionPolicy.BOUNDARY));
    assertTrue(transaction.isActive());

    assertTrue(transaction.canLeave(ExecutionPolicy.INTERNAL));
    transaction.leave(ExecutionPolicy.INTERNAL);
    assertTrue(transaction.isActive());

    assertTrue(transaction.canLeave(ExecutionPolicy.BOUNDARY));
    assertTrue(transaction.isActive());
    transaction.leave(ExecutionPolicy.BOUNDARY);
    assertFalse(transaction.isActive());

    assertFalse(transaction.canLeave(ExecutionPolicy.INTERNAL));
    assertFalse(transaction.isActive());
  }
예제 #2
0
  @Test
  public void test1() {
    InterceptorScopeInvocation transaction = new DefaultInterceptorScopeInvocation("test");

    assertFalse(transaction.isActive());

    assertTrue(transaction.tryEnter(ExecutionPolicy.ALWAYS));
    assertTrue(transaction.isActive());

    assertTrue(transaction.tryEnter(ExecutionPolicy.ALWAYS));
    assertTrue(transaction.isActive());

    assertTrue(transaction.canLeave(ExecutionPolicy.ALWAYS));
    assertTrue(transaction.isActive());
    transaction.leave(ExecutionPolicy.ALWAYS);
    assertTrue(transaction.isActive());

    assertTrue(transaction.canLeave(ExecutionPolicy.ALWAYS));
    assertTrue(transaction.isActive());
    transaction.leave(ExecutionPolicy.ALWAYS);
    assertFalse(transaction.isActive());
  }