Ver código fonte

Tests for static method call/execution with @annotation

tags/Root_AspectJ5_Development
aclement 19 anos atrás
pai
commit
94251be73e

+ 28
- 0
tests/java5/annotations/binding/StaticMethods.java Ver arquivo

@@ -0,0 +1,28 @@
import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@interface Colored {String value();}


public class StaticMethods {

public static void main(String[] argv) {
m1();
m2();
}


@Colored("red") static void m1() {System.err.println("m1 running");}
@Colored("blue") static void m2() {System.err.println("m2 running");}

static aspect X {
before(Colored c): call(* m*(..)) && @annotation(c) {
System.err.println("Color at "+thisJoinPoint+" is "+c.value());
}
before(Colored c): execution(* m*(..)) && @annotation(c) {
System.err.println("Color at "+thisJoinPoint+" is "+c.value());
}
}

}


+ 7
- 0
tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java Ver arquivo

@@ -144,4 +144,11 @@ public class AnnotationBinding extends TestUtils {
assertMessages(cR,new EmptyMessageSpec());
RunResult rR = run("a.b.c.A");
}
// Binding with calls/executions of static methods
public void testCallsAndExecutionsOfStaticMethods() {
CompilationResult cR = ajc(baseDir,new String[]{"StaticMethods.java","-1.5","-d","."});
assertMessages(cR,new EmptyMessageSpec());
RunResult rR = run("StaticMethods");
}
}

Carregando…
Cancelar
Salvar