aboutsummaryrefslogtreecommitdiffstats
path: root/tests/java5/ataspectj/annotationGen/Deow.aj
blob: 063ac4200aba7dbe1d10d989b3fcf268c775e619 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import org.aspectj.lang.reflect.*;

public aspect Deow {

  declare warning : call(* System.*(..)) : "dont call system methods";
  declare error : call(* System.*(..)) : "dont call system methods";
  
  public static void main(String[] args) {
    AjType myType = AjTypeSystem.getAjType(Deow.class);
    DeclareErrorOrWarning[] deows = myType.getDeclareErrorOrWarnings();
    if (deows.length != 2) throw new RuntimeException("Excepting 2 deows, got: " + deows.length);
    int errorCount = 0;
    int warningCount = 0;
    if (deows[0].isError()) {
    	errorCount++;
    } else {
    	warningCount++;
    }
    if (deows[1].isError()) {
    	errorCount++;
    } else {
    	warningCount++;
    }
    if (errorCount != 1) { throw new RuntimeException("Expecting 1 declare error but found " + errorCount); }
    if (warningCount != 1) { throw new RuntimeException("Expecting 1 declare warning but found " + warningCount); }
    if (!deows[0].getMessage().equals("dont call system methods")) throw new RuntimeException("Bad message");
    if (!deows[1].getMessage().equals("dont call system methods")) throw new RuntimeException("Bad message");
    if (!deows[0].getPointcutExpression().toString().equals("call(* java.lang.System.*(..))")) throw new RuntimeException("Bad pc: " + deows[0].getPointcutExpression());
    if (!deows[1].getPointcutExpression().toString().equals("call(* java.lang.System.*(..))")) throw new RuntimeException("Bad pc: " + deows[0].getPointcutExpression());
  }
}