Example #1
0
  public void testStaticInnerClassFromOuterClass() {
    TestAspect.clear();
    POJO pojo = new POJO();
    assertFalse(TestAspect.constructor);
    TestAspect.clear();
    pojo.executeStatic();

    assertTrue(TestAspect.constructor);
    assertTrue(TestAspect.staticRead);
    assertTrue(TestAspect.staticWrite);
    assertTrue(TestAspect.normalRead);
    assertTrue(TestAspect.normalWrite);
    assertTrue(TestAspect.method);
  }
Example #2
0
  public void testPerInstanceStatic() throws Exception {
    System.out.println("****** testPerInstanceStatic");
    POJO.perInstanceMethodStatic();

    ArrayList invoked = InvokedConfigs.getInvokedConfigs();
    assertEquals("Wrong number of interceptions in testPerInstanceStatic", invoked.size(), 0);
  }
Example #3
0
  public static void main(String[] args) throws Exception {
    POJO pojo = new POJO();

    System.out.println("\nCalling POJO->getIntValue()");
    System.out.println("===========================");
    System.out.println("RECEIVED type:int value:" + pojo.getIntValue());
    ;

    System.out.println("\nCalling POJO->getList()");
    System.out.println("=======================");
    List list = pojo.getList();
    System.out.println("RECEIVED type:" + list.getClass() + " value:" + list);

    System.out.println("\nCalling POJO->doNothing()");
    System.out.println("=========================");
    pojo.doNothing();
    System.out.println("RECEIVED nothing");
  }
Example #4
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);
  }
Example #5
0
  public void testPOJO() {
    TestAspect.clear();
    POJO pojo = new POJO(Type.type.normalType, Type.type.staticType);

    pojo.nt = Type.type.normalType;
    NormalType ntype = pojo.nt;

    pojo.st = Type.type.staticType;
    StaticType stype = pojo.st;

    NormalType type = pojo.method(Type.type.staticType, Type.type.normalType);

    assertTrue(TestAspect.constructor);
    assertTrue(TestAspect.staticRead);
    assertTrue(TestAspect.staticWrite);
    assertTrue(TestAspect.normalRead);
    assertTrue(TestAspect.normalWrite);
    assertTrue(TestAspect.method);
  }