Exemple #1
0
  public void testAnnotation() {
    System.out.println("RUNNING TEST BASIC");

    SimpleInterceptor.intercepted = false;
    AnnotatedPOJO pojo = new AnnotatedPOJO();
    if (!SimpleInterceptor.intercepted)
      throw new RuntimeException("failed to intercept tagged constructor");

    complex c = (complex) AnnotationElement.getAnyAnnotation(AnnotatedPOJO.class, complex.class);
    printComplex(c);

    SimpleInterceptor.intercepted = false;
    pojo = new AnnotatedPOJO("no interception");
    if (SimpleInterceptor.intercepted)
      throw new RuntimeException("should not intercept non-tagged constructor");

    pojo.someMethod();
    if (!SimpleInterceptor.intercepted)
      throw new RuntimeException("failed to intercept tagged method");

    SimpleInterceptor.intercepted = false;
    pojo.nontraceableMethod();
    if (SimpleInterceptor.intercepted)
      throw new RuntimeException("should not intercept non-tagged method");

    pojo.field = 5;
    if (!SimpleInterceptor.intercepted)
      throw new RuntimeException("failed to intercept tagged field");

    SimpleInterceptor.intercepted = false;
    pojo.nontraceable = 25;
    if (SimpleInterceptor.intercepted)
      throw new RuntimeException("should not intercept non-tagged field");

    Introduction intro = (Introduction) pojo;
    intro.helloWorld("hello");
  }