Esempio n. 1
0
  public void testPerJoinpoint() throws Exception {
    System.out.println("****** testPerJoinpoint");
    POJO pojo = new POJO();
    pojo.perJoinpointMethod();

    ArrayList invoked = InvokedConfigs.getInvokedConfigs();
    assertEquals("Wrong number of interceptions in testPerJoinpoint", 2, invoked.size());

    System.out.println("****** testPerJoinpoint (aspect)");
    InvokedConfig invokedConfig = (InvokedConfig) invoked.get(0);
    assertEquals(
        "Wrong interceptor class in testPerJoinpoint",
        InterceptorPerJoinpoint.class.getName(),
        invokedConfig.name);
    assertEquals(
        "Wrong aspect int attribute for interceptor in testPerJoinpoint",
        14,
        invokedConfig.intAttr);
    assertEquals(
        "Wrong aspect string for interceptor in testPerJoinpoint",
        InterceptorPerJoinpoint.class.getName(),
        invokedConfig.stringAttr);
    assertNotNull("Advisor was null in interceptor in testPerJoinpoint", invokedConfig.advisor);
    assertNotNull(
        "InstanceAdvisor was null in interceptor in testPerJoinpoint",
        invokedConfig.instanceAdvisor);
    assertNotNull("Joinpoint was null in interceptor in testPerJoinpoint", invokedConfig.joinpoint);

    System.out.println("****** testPerJoinpoint (interceptor)");
    invokedConfig = (InvokedConfig) invoked.get(1);
    assertEquals(
        "Wrong aspect class in testPerJoinpoint",
        AdvicePerJoinpoint.class.getName(),
        invokedConfig.name);
    assertEquals("Wrong aspect int attribute in testPerJoinpoint", 24, invokedConfig.intAttr);
    assertEquals(
        "Wrong aspect string attribute in testPerJoinpoint",
        AdvicePerJoinpoint.class.getName(),
        invokedConfig.stringAttr);
    assertNotNull("Advisor was null in aspect in testPerJoinpoint", invokedConfig.advisor);
    assertNotNull(
        "InstanceAdvisor was null in aspect in testPerJoinpoint", invokedConfig.instanceAdvisor);
    assertNotNull("Joinpoint was null in aspect in testPerJoinpoint", invokedConfig.joinpoint);
  }