You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Common.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import org.aspectj.testing.Tester;
  2. import org.aspectj.testing.Tester;
  3. public class Common {
  4. public static String[] SIGNALS = new String[] { };
  5. public static final void expect(String[] args) {
  6. for (int i = 0; i < args.length; i++) {
  7. expect(args[i]);
  8. }
  9. }
  10. public static final void expect(String s) { Tester.expectEvent(s); }
  11. public static final void signal(String s) { Tester.event(s); }
  12. public static final void fail(String s) { Tester.check(false, s); }
  13. public static final void check() { Tester.checkAllEvents(); }
  14. public static final void joinWith(Thread thread) {
  15. if (null == thread) {
  16. Common.fail("null thread");
  17. }
  18. try { thread.join(); }
  19. catch (InterruptedException e) {
  20. Common.fail("Interrupted");
  21. }
  22. }
  23. }
  24. class Target {
  25. public static void main (String[] args) {
  26. Common.expect(Target.SIGNALS);
  27. Common.expect(Aspect.SIGNALS);
  28. int result = new Target().targetMethod();
  29. if (1 != result) Common.fail("1 != result: " + result);
  30. Common.check();
  31. }
  32. pointcut pointcutTarget() : call(int Target.targetMethod());
  33. public static String[] SIGNALS = new String[]
  34. { "targetMethod()" };
  35. public int targetMethod() {
  36. Common.signal(SIGNALS[0]);
  37. return 1;
  38. }
  39. }