KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > JVMAspectInterfaceTest


1 // $Id: JVMAspectInterfaceTest.java,v 1.3 2004/05/12 17:26:51 anicoara Exp $
2
// =====================================================================
3
//
4
// (history at end)
5
//
6

7 package ch.ethz.prose;
8
9 //used packages
10
import java.lang.reflect.Field JavaDoc;
11 import java.lang.reflect.Method JavaDoc;
12
13 import junit.framework.*;
14 import ch.ethz.jvmai.*;
15
16 /**
17 * JUnit testcase for class JVMAspectInterface.
18 *
19 * @version $Revision: 1.3 $
20 * @author Stephan Markwalder
21 * @author Angela Nicoara
22 */

23 public
24 class JVMAspectInterfaceTest extends TestCase {
25
26   JVMAspectInterface aspectInterface = null;
27   Method JavaDoc method = null;
28   Field JavaDoc field = null;
29   Class JavaDoc exceptionClass = null;
30
31   /**
32    * Construct test with given name.
33    * @param name test name
34    */

35   public JVMAspectInterfaceTest(String JavaDoc name)
36   {
37     super(name);
38   }
39
40   static class TestHook extends JoinPointHook {
41     public int oFA,oFM,oMEn,oMEx,oExt, oExc, oCL;
42     public void reset() { oFA = 0; oFM = 0; oMEn = 0; oMEx = 0; oExt = 0; oExc = 0; oCL = 0; }
43     public void onFieldAccess (FieldAccessJoinPoint joinPoint) { oFA++; }
44     public void onFieldModification(FieldModificationJoinPoint joinPoint) { oFM++; }
45     public void onMethodEntry (MethodEntryJoinPoint joinPoint) { oMEn++; }
46     public void onMethodExit (MethodExitJoinPoint joinPoint) { oMEx++; }
47     public void onExceptionThrow (ExceptionJoinPoint joinPoint) { oExt++; }
48     public void onExceptionCatch (ExceptionCatchJoinPoint joinPoint) { oExc++; }
49     public void onClassLoad (Class JavaDoc cls) { oCL++; }
50   }
51
52   static class TestException extends Exception JavaDoc {
53     public TestException() {super(); }
54     public TestException(String JavaDoc s) {super(s);}
55   }
56
57   static class TestException2 extends Exception JavaDoc {
58     public TestException2() {super(); }
59     public TestException2(String JavaDoc s) {super(s);}
60   }
61
62   static class TestException3 extends Exception JavaDoc {
63     public TestException3() {super(); }
64     public TestException3(String JavaDoc s) {super(s);}
65   }
66
67   static class TestException4 extends RuntimeException JavaDoc { }
68
69   static class TestCatch {
70     public int field1;
71     public int field2;
72     public void method1() { }
73     public void throwMethod2(){
74         try{ if (field1 == 1) throw new TestException(); }catch(TestException e){ }
75     }
76     public void throwMethod3(){
77         try{ throw new TestException2(); } catch(TestException2 e) {}
78     }
79     public void throwMethod4(){
80         try{ if (field2 == 2) throw new TestException2(); } catch (TestException2 e){ }
81     }
82     public void throwMethod5(){
83         try{ if (field2 == 2) throw new TestException3(); } catch (TestException3 e){ }
84     }
85     public void throwMethod6(){
86         try{ throw new TestException4(); } catch(Exception JavaDoc e) { }
87     }
88   }
89
90   static class TestClass1 {
91     public void method() { }
92     public int field;
93     public void throwMethod() {try {throw new TestException();} catch (TestException e) {} }
94     public void run() {
95       method();
96       field = field + 1;
97       throwMethod();
98     }
99   }
100
101   static abstract class TestClass2 {
102   }
103
104   static abstract class TestClass3 {
105     public abstract void method();
106   }
107
108   static abstract class TestAbstractClass {
109
110       // abstract methods (implemented by TestClass4)
111
abstract void method08();
112       abstract public void method09();
113       abstract protected void method10();
114
115       // standard methods (overwritten by TestClass4)
116
void method11() {}
117                public void method12() {}
118                protected void method13() {}
119                private void method14() {}
120
121       // standard methods (inherited by TestClass4)
122
void method17() {}
123                public void method18() {}
124                protected void method19() {}
125
126       // static methods (inherited by TestClass4)
127
static void method20() {}
128       static public void method21() {}
129       static protected void method22() {}
130
131
132       // standard fields (shadowed by TestClass4)
133
int field00;
134              public int field01;
135              protected int field02;
136              private int field03;
137
138       // standard fields (inherited by TestClass4)
139
int field04;
140              public int field05;
141              protected int field06;
142
143       // static fields (inherited by TestClass4)
144
static int field07;
145       static public int field08;
146       static protected int field09;
147
148   }
149
150   static interface TestInterface {
151       // interface methods (implemented by TestClass4)
152
void method15();
153                public void method16();
154
155   }
156
157   static class TestClass4 extends TestAbstractClass implements TestInterface {
158
159       // standard fields
160
int field00;
161              public int field01;
162              protected int field02;
163              private int field03;
164
165       // standard fields
166
int field10;
167              public int field11;
168              protected int field12;
169              private int field13;
170
171       // static fields
172
static int field14;
173       static public int field15;
174       static protected int field16;
175       static private int field17;
176
177       // standard methods, different access modifiers
178
void method00() {}
179                public void method01() {}
180                protected void method02() {}
181                private void method03() {}
182
183       // static methods
184
static void method04() {}
185       static public void method05() {}
186       static protected void method06() {}
187       static private void method07() {}
188
189       // implementation of abstract methods in TestAbstractClass
190
void method08() {}
191                public void method09() {}
192                protected void method10() {}
193       // methods overwriting TestAbstractClass's methods
194
void method11() {}
195                public void method12() {}
196                protected void method13() {}
197                private void method14() {}
198       // implementation of methods in interface TestInterface
199
public void method15() {}
200                public void method16() {}
201
202
203     public void callMethods() {
204       method00();
205       method01();
206       method02();
207       method03();
208       method04();
209       method05();
210       method06();
211       method07();
212       method08();
213       method09();
214       method10();
215       method11();
216       method12();
217       method13();
218       method14();
219       method15();
220       method16();
221       method17();
222       method18();
223       method19();
224       method20();
225       method21();
226       method22();
227     }
228
229     public void accessFields() {
230       field00 = field00+1;
231       field01 = field01+1;
232       field02 = field02+1;
233       field03 = field03+1;
234       field04 = field04+1;
235       field05 = field05+1;
236       field06 = field06+1;
237       field07 = field07+1;
238       field08 = field08+1;
239       field09 = field09+1;
240       field10 = field10+1;
241       field11 = field11+1;
242       field12 = field12+1;
243       field13 = field13+1;
244       field14 = field14+1;
245       field15 = field15+1;
246       field16 = field16+1;
247       field17 = field17+1;
248     }
249
250   }
251
252     static class TestClass5
253     {
254     int exit;
255     public void method0()
256     {
257         if (exit == 0)
258         return;
259         else
260         {
261             switch(exit)
262             {
263             case 2: return;
264             case 3: return;
265             }
266             return;
267         }
268     }
269
270     public int method1()
271     {
272         if (exit == 0)
273         return 0;
274         else
275         {
276             switch(exit)
277             {
278             case 2: return 2;
279             case 3: return 3;
280             }
281             return 4;
282         }
283     }
284
285     public Object JavaDoc method2()
286     {
287         if (exit == 0)
288         return "hi0";
289         else
290         {
291             switch(exit)
292             {
293             case 2: return "hi2";
294             case 3: return "hi3";
295             }
296             return "hi4";
297         }
298     }
299
300     public double method3()
301     {
302         if (exit == 0)
303         return 1.0;
304         else
305         {
306             switch(exit)
307             {
308             case 2: return 2.0;
309             case 3: return 3.0;
310             }
311             return 4.0;
312         }
313     }
314     }
315
316   static class TestThread extends Thread JavaDoc {
317     private TestClass1 test;
318     public TestThread(TestClass1 t) { test = t; }
319     public void run()
320     {
321         if(test==null) return;
322         test.run();
323     }
324   }
325
326   protected void setUp() throws Exception JavaDoc
327   {
328    String JavaDoc providerClassName = System.getProperty("ch.ethz.prose.JVMAIProvider","ch.ethz.inf.iks.jvmai.jvmdi.DebuggerProvider");
329    Class JavaDoc providerClass = Class.forName(providerClassName);
330    Provider provider = (Provider)providerClass.newInstance();
331    aspectInterface = provider.getAspectInterface();
332    method = TestClass1.class.getDeclaredMethods()[0];
333    field = TestClass1.class.getDeclaredFields()[0];
334   }
335
336   protected void tearDown()
337   {
338     try
339     {
340
341       try { aspectInterface.clearMethodEntryWatch (method); } catch (RuntimeException JavaDoc e) { }
342       try { aspectInterface.clearMethodExitWatch (method); } catch (RuntimeException JavaDoc e) { }
343       try { aspectInterface.clearFieldAccessWatch (field); } catch (RuntimeException JavaDoc e) { }
344       try { aspectInterface.clearFieldModificationWatch(field); } catch (RuntimeException JavaDoc e) { }
345       try { aspectInterface.clearExceptionThrowWatch (TestException.class); } catch (RuntimeException JavaDoc e) { }
346       try { aspectInterface.clearExceptionCatchWatch (TestException.class); } catch (RuntimeException JavaDoc e) { }
347       try { aspectInterface.setJoinPointHook(null); } catch (RuntimeException JavaDoc e) { }
348     }
349     catch (RuntimeException JavaDoc e)
350     {
351     }
352   }
353
354   public void test_0010_NotInitializedExceptions()
355   {
356
357     // calling any method from aspect-interface before initialization should throw a NotInitializedException
358
int exceptions = 0;
359
360
361     try { aspectInterface.setJoinPointHook(null); }
362     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException) {exceptions++; }}
363
364     try { aspectInterface.setFieldAccessWatch(null,null); }
365     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException){ exceptions++; }}
366
367     try { aspectInterface.setFieldModificationWatch(null,null); }
368     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException){ exceptions++; }}
369
370     try { aspectInterface.setMethodEntryWatch(null,null); }
371     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException) {exceptions++; }}
372
373     try { aspectInterface.setMethodExitWatch(null,null); }
374     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException) {exceptions++; }}
375
376     try { aspectInterface.setExceptionThrowWatch(null,null); }
377     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException){ exceptions++; }}
378     
379     try { aspectInterface.setExceptionCatchWatch(null,null); }
380     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException){ exceptions++; }}
381     
382
383     try { aspectInterface.clearFieldAccessWatch(null); }
384     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException){ exceptions++; }}
385
386     try { aspectInterface.clearFieldModificationWatch(null); }
387     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException){ exceptions++; }}
388
389     try { aspectInterface.clearMethodEntryWatch(null); }
390     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException) {exceptions++; }}
391
392     try { aspectInterface.clearMethodExitWatch(null); }
393     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException) {exceptions++; }}
394
395     try { aspectInterface.clearExceptionThrowWatch(null); }
396     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException){ exceptions++; }}
397
398     try { aspectInterface.clearExceptionCatchWatch(null); }
399     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException){ exceptions++; }}
400
401     try { aspectInterface.suspendNotification(null); }
402     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException) {exceptions++; }}
403
404     try { aspectInterface.resumeNotification(null); }
405     catch (RuntimeException JavaDoc e) { if(e instanceof NotInitializedException){ exceptions++; }}
406
407     assertEquals("13 NotInitializedException",exceptions,15);
408
409   }
410
411   public void test_0020_Startup()
412   {
413       try
414       {
415           try
416           {
417               aspectInterface.startup(new String JavaDoc[0],true);
418               aspectInterface.startup(new String JavaDoc[0],false);
419           }
420           catch (RuntimeException JavaDoc e)
421           {
422               assertTrue("calling startup a second time is ignored",false);
423           }
424       }
425       catch (Throwable JavaDoc e)
426       {
427           e.printStackTrace();
428           throw new RuntimeException JavaDoc("startup failed" + e);
429       }
430
431   }
432
433   public void test_0030_SetClearWatch()
434   {
435
436     Object JavaDoc aopTag = new Object JavaDoc();
437     int exceptions = 0;
438
439
440     // set all possible watches in TestClass : no exceptions should be thrown
441
try { aspectInterface.setMethodEntryWatch (method,aopTag); }
442     catch (RuntimeException JavaDoc e) { exceptions++; System.err.println("A1");}
443     try { aspectInterface.setMethodExitWatch (method,aopTag); }
444     catch (RuntimeException JavaDoc e) { exceptions++; System.err.println("A2"); }
445     try { aspectInterface.setFieldAccessWatch (field ,aopTag); }
446     catch (RuntimeException JavaDoc e) { exceptions++; System.err.println("A3"); }
447     try { aspectInterface.setFieldModificationWatch(field ,aopTag); }
448     catch (RuntimeException JavaDoc e) { exceptions++; System.err.println("A4"); }
449     try { aspectInterface.setExceptionThrowWatch (TestException.class,aopTag); }
450     catch (RuntimeException JavaDoc e) { exceptions++; System.err.println("A5");}
451     try { aspectInterface.setExceptionCatchWatch (TestException.class,aopTag); }
452     catch (RuntimeException JavaDoc e) { exceptions++; System.err.println("A6");}
453
454     assertEquals("no exceptions when setting watches",0,exceptions);
455
456
457     // clear all watches in TestClass
458
try { aspectInterface.clearMethodEntryWatch (method); } catch (RuntimeException JavaDoc e)
459     { exceptions++; System.err.println("B1");}
460     try { aspectInterface.clearMethodExitWatch (method); } catch (RuntimeException JavaDoc e)
461     { exceptions++;System.err.println("B2"); }
462     try { aspectInterface.clearFieldAccessWatch (field ); } catch (RuntimeException JavaDoc e)
463     { exceptions++; System.err.println("B3");}
464     try { aspectInterface.clearFieldModificationWatch(field ); } catch (RuntimeException JavaDoc e)
465     { exceptions++; System.err.println("B4");}
466     try { aspectInterface.clearExceptionThrowWatch (TestException.class ); } catch (RuntimeException JavaDoc e)
467     { exceptions++;System.err.println("B5"); }
468     try { aspectInterface.clearExceptionCatchWatch (TestException.class ); } catch (RuntimeException JavaDoc e)
469     { exceptions++;System.err.println("B6"); }
470     assertEquals("no exceptions when clearing watches",0,exceptions);
471   }
472
473   public void test_0040_SetClearWatch_Exceptions()
474   {
475
476     Object JavaDoc aopTag = new Object JavaDoc();
477     int exceptions = 0;
478     long id = 0;
479
480     // try again to set watches twice : every second set**Watch should throw a WatchAlreadySetException
481
exceptions = 0;
482
483     aspectInterface.setMethodEntryWatch (method,aopTag);
484     try { aspectInterface.setMethodEntryWatch (method,aopTag); }
485     catch (WatchAlreadySetException e) { exceptions++; }
486
487     aspectInterface.setMethodExitWatch (method,aopTag);
488     try { aspectInterface.setMethodExitWatch (method,aopTag); }
489     catch (WatchAlreadySetException e) { exceptions++; }
490
491     aspectInterface.setFieldAccessWatch (field ,aopTag);
492     try { aspectInterface.setFieldAccessWatch (field ,aopTag); }
493     catch (WatchAlreadySetException e) { exceptions++; }
494
495     aspectInterface.setFieldModificationWatch(field ,aopTag);
496     try { aspectInterface.setFieldModificationWatch(field ,aopTag); }
497     catch (WatchAlreadySetException e) { exceptions++; }
498
499     aspectInterface.setExceptionThrowWatch (TestException.class, aopTag);
500     try { aspectInterface.setExceptionThrowWatch (TestException.class, aopTag); }
501     catch (WatchAlreadySetException e) { exceptions++; }
502     
503     aspectInterface.setExceptionCatchWatch (TestException.class, aopTag);
504     try { aspectInterface.setExceptionCatchWatch (TestException.class, aopTag); }
505     catch (WatchAlreadySetException e) { exceptions++; }
506     
507     assertEquals("6 WatchAlreadySetExceptions",6,exceptions);
508
509     // try again to clear watches twice : every second clear**Watch should throw a WatchNotSetException
510
exceptions = 0;
511     aspectInterface.clearMethodEntryWatch (method);
512
513     try { aspectInterface.clearMethodEntryWatch (method); }
514     catch (WatchNotSetException e) { exceptions++; }
515
516     aspectInterface.clearMethodExitWatch (method);
517     try { aspectInterface.clearMethodExitWatch (method); }
518     catch (WatchNotSetException e) { exceptions++; }
519
520      aspectInterface.clearFieldAccessWatch (field);
521      try { aspectInterface.clearFieldAccessWatch (field); }
522      catch (WatchNotSetException e) { exceptions++; }
523
524      aspectInterface.clearFieldModificationWatch(field);
525      try { aspectInterface.clearFieldModificationWatch(field); }
526      catch (WatchNotSetException e) { exceptions++; }
527
528      aspectInterface.clearExceptionThrowWatch (TestException.class );
529      try { aspectInterface.clearExceptionThrowWatch (TestException.class ); }
530      catch (WatchNotSetException e) { exceptions++; }
531
532      aspectInterface.clearExceptionCatchWatch (TestException.class );
533      try { aspectInterface.clearExceptionCatchWatch (TestException.class ); }
534      catch (WatchNotSetException e) { exceptions++; }
535
536      assertEquals("6 WatchNotSetExceptions",6,exceptions);
537
538
539      exceptions = 0;
540
541      // try to set watches on an interface method : every set**Watch should throw a CannotSetWatchException
542
method = TestInterface.class.getDeclaredMethods()[0];
543      exceptions = 0;
544      try { aspectInterface.setMethodEntryWatch(method,aopTag); } catch (CannotSetWatchException e) { exceptions++; }
545      try { aspectInterface.setMethodExitWatch (method,aopTag); } catch (CannotSetWatchException e) { exceptions++; }
546      assertTrue("2 CannotSetWatchExceptions (interface method)",exceptions==2);
547
548      // try to set watches on an abstract method : every set**Watch should throw a CannotSetWatchException
549
method = TestClass3.class.getDeclaredMethods()[0];
550      exceptions = 0;
551      try { aspectInterface.setMethodEntryWatch(method,aopTag); } catch (CannotSetWatchException e) { exceptions++; }
552      try { aspectInterface.setMethodExitWatch (method,aopTag); } catch (CannotSetWatchException e) { exceptions++; }
553      assertTrue("2 CannotSetWatchExceptions (abstract method)",exceptions==2);
554
555      // try to set/clear watches on class 'null' : every set**Watch/clear**Watch should throw a NullPointerException
556
exceptions = 0;
557      try { aspectInterface.setMethodEntryWatch (null,aopTag); } catch (NullPointerException JavaDoc e) { exceptions++; }
558      try { aspectInterface.setMethodExitWatch (null,aopTag); } catch (NullPointerException JavaDoc e) { exceptions++; }
559      try { aspectInterface.setFieldAccessWatch (null,aopTag); } catch (NullPointerException JavaDoc e) { exceptions++; }
560      try { aspectInterface.setFieldModificationWatch (null,aopTag); } catch (NullPointerException JavaDoc e) { exceptions++; }
561      try { aspectInterface.setExceptionThrowWatch (null, aopTag); } catch (NullPointerException JavaDoc e) { exceptions++; }
562      try { aspectInterface.setExceptionCatchWatch (null, aopTag); } catch (NullPointerException JavaDoc e) { exceptions++; }
563      try { aspectInterface.clearMethodEntryWatch (null); } catch (NullPointerException JavaDoc e) { exceptions++; }
564      try { aspectInterface.clearMethodExitWatch (null); } catch (NullPointerException JavaDoc e) { exceptions++; }
565      try { aspectInterface.clearFieldAccessWatch (null); } catch (NullPointerException JavaDoc e) { exceptions++; }
566      try { aspectInterface.clearFieldModificationWatch(null); } catch (NullPointerException JavaDoc e) { exceptions++; }
567      try { aspectInterface.clearExceptionThrowWatch (null); } catch (NullPointerException JavaDoc e) { exceptions++; }
568      try { aspectInterface.clearExceptionCatchWatch (null); } catch (NullPointerException JavaDoc e) { exceptions++; }
569      assertTrue("12 NullPointerExceptions",exceptions==12);
570
571   }
572
573     public void test_0050_SetJoinPointHook()
574     {
575     int exceptions = 0;
576     TestHook hook = new TestHook();
577
578     try { aspectInterface.setJoinPointHook(hook); } catch (RuntimeException JavaDoc e) { exceptions++; }
579     assertTrue("no exceptions while setting hook",exceptions==0);
580
581     // check if setting again the same hook changes the result
582
try { aspectInterface.setJoinPointHook(hook); } catch (RuntimeException JavaDoc e) { exceptions++; }
583     assertTrue("no exceptions while re-setting hook",exceptions==0);
584
585     // it should be allowed to set 'null' as hook
586
try { aspectInterface.setJoinPointHook(null); } catch (RuntimeException JavaDoc e) { exceptions++; }
587     assertTrue("no exceptions while setting hook to 'null'",exceptions==0);
588
589     try { aspectInterface.setJoinPointHook(hook); } catch (RuntimeException JavaDoc e) { exceptions++; }
590     assertTrue("no exceptions while setting hook",exceptions==0);
591
592     }
593
594     public void test_0060_HookNotification()
595     {
596
597     Object JavaDoc aopTag = new Object JavaDoc();
598     TestHook hook = new TestHook();
599     TestClass1 test = new TestClass1();
600
601     aspectInterface.setMethodEntryWatch (method,aopTag);
602     aspectInterface.setMethodExitWatch (method,aopTag);
603     aspectInterface.setFieldAccessWatch (field ,aopTag);
604     aspectInterface.setFieldModificationWatch(field ,aopTag);
605     aspectInterface.setExceptionThrowWatch (TestException.class, aopTag);
606     aspectInterface.setExceptionCatchWatch (TestException.class, aopTag);
607     aspectInterface.resumeNotification(Thread.currentThread());
608   
609     aspectInterface.setJoinPointHook(hook);
610     hook.reset();
611     test.run();
612
613     assertEquals("1 field access event" ,1,hook.oFA);
614     assertEquals("1 field modification event",1,hook.oFM);
615     assertEquals("1 method entry event" ,1,hook.oMEn);
616     assertEquals("1 method exit event" ,1,hook.oMEx);
617     assertEquals("1 exception throw event(1)",1,hook.oExt);
618     assertEquals("1 exception catch event(1)",1,hook.oExc);
619
620     // check if setting again the same hook changes the result
621
aspectInterface.setJoinPointHook(hook);
622     hook.reset();
623     test.run();
624
625     assertEquals("1 field access event" ,1,hook.oFA );
626     assertEquals("1 field modification event",1,hook.oFM );
627     assertEquals("1 method entry event" ,1,hook.oMEn);
628     assertEquals("1 method exit event" ,1,hook.oMEx);
629     assertEquals("1 exception throw event(2)",1,hook.oExt);
630     assertEquals("1 exception catch event(2)",1,hook.oExc);
631
632     // check wether events are forwarded to the hook after he has been removed (set 'null')
633
aspectInterface.setJoinPointHook(null);
634     hook.reset();
635     test.run();
636
637     assertEquals("no field access events" ,0,hook.oFA );
638     assertEquals("no field modification events",0,hook.oFM );
639     assertEquals("no method entry events" ,0,hook.oMEn);
640     assertEquals("no method exit events" ,0,hook.oMEx);
641     assertEquals("no exception throw events" ,0,hook.oExt);
642     assertEquals("no exception catch events" ,0,hook.oExc);
643
644     aspectInterface.setJoinPointHook(hook);
645     hook.reset();
646     test.run();
647
648     assertEquals("1 field access event" ,1,hook.oFA );
649     assertEquals("1 field modification event",1,hook.oFM );
650     assertEquals("1 method entry event" ,1,hook.oMEn);
651     assertEquals("1 method exit event" ,1,hook.oMEx);
652     assertEquals("1 exception throw event" ,1,hook.oExt);
653     assertEquals("1 exception catch event" ,1,hook.oExc);
654
655     aspectInterface.clearMethodEntryWatch (method);
656     aspectInterface.clearMethodExitWatch (method);
657     aspectInterface.clearFieldAccessWatch (field);
658     aspectInterface.clearFieldModificationWatch(field);
659     aspectInterface.clearExceptionThrowWatch (TestException.class );
660     aspectInterface.clearExceptionCatchWatch (TestException.class );
661     aspectInterface.resumeNotification(Thread.currentThread());
662   }
663
664   public void test_0070_AopTagHandling()
665   {
666
667     Class JavaDoc exception = TestException.class;
668     int exceptions = 0;
669     JoinPointHook hook = null;
670     TestClass1 test = new TestClass1();
671
672     // set all watches in TestClass with 'null' as aopTag
673
exceptions = 0;
674     try { aspectInterface.setMethodEntryWatch (method,null); } catch (RuntimeException JavaDoc e) { exceptions++; }
675     try { aspectInterface.setMethodExitWatch (method,null); } catch (RuntimeException JavaDoc e) { exceptions++; }
676     try { aspectInterface.setFieldAccessWatch (field ,null); } catch (RuntimeException JavaDoc e) { exceptions++; }
677     try { aspectInterface.setFieldModificationWatch (field ,null); } catch (RuntimeException JavaDoc e) { exceptions++; }
678     try { aspectInterface.setExceptionThrowWatch (TestException.class, null); } catch (RuntimeException JavaDoc e) { exceptions++; }
679     try { aspectInterface.setExceptionCatchWatch (TestException.class, null); } catch (RuntimeException JavaDoc e) { exceptions++; }
680     assertEquals("exceptions while setting watches with aopTag equals to 'null'",exceptions,6);
681
682
683     // check if watches have been set
684
exceptions = 0;
685     final Object JavaDoc stringTag = "hi, I'm a tag";
686     try { aspectInterface.setMethodEntryWatch (method,stringTag); }
687     catch (WatchAlreadySetException e) { exceptions++; }
688
689     try { aspectInterface.setMethodExitWatch (method,stringTag); }
690     catch (WatchAlreadySetException e) { exceptions++; }
691
692     try { aspectInterface.setFieldAccessWatch (field ,stringTag); }
693     catch (WatchAlreadySetException e) { exceptions++; }
694
695     try { aspectInterface.setFieldModificationWatch (field ,stringTag); }
696     catch (WatchAlreadySetException e) { exceptions++; }
697
698     try { aspectInterface.setExceptionThrowWatch (TestException.class, stringTag); }
699     catch (WatchAlreadySetException e) { exceptions++; }
700
701     try { aspectInterface.setExceptionCatchWatch (TestException.class, stringTag); }
702     catch (WatchAlreadySetException e) { exceptions++; }
703
704     assertEquals("NO exceptions while re-setting watches with non-null tags",exceptions,0);
705
706     // check if double setting watches leads to exceptions
707
exceptions = 0;
708     try { aspectInterface.setMethodEntryWatch (method,stringTag); }
709     catch (WatchAlreadySetException e) { exceptions++; }
710
711     try { aspectInterface.setMethodExitWatch (method,stringTag); }
712     catch (WatchAlreadySetException e) { exceptions++; }
713
714     try { aspectInterface.setFieldAccessWatch (field ,stringTag); }
715     catch (WatchAlreadySetException e) { exceptions++; }
716
717     try { aspectInterface.setFieldModificationWatch (field ,stringTag); }
718     catch (WatchAlreadySetException e) { exceptions++; }
719
720     try { aspectInterface.setExceptionThrowWatch (TestException.class,stringTag); }
721     catch (WatchAlreadySetException e) { exceptions++; }
722     
723     try { aspectInterface.setExceptionCatchWatch (TestException.class,stringTag); }
724     catch (WatchAlreadySetException e) { exceptions++; }
725     
726     assertEquals("6 exceptions while re-setting watches with non null tags",exceptions,6);
727
728     // check if aopTags are correctly passed to hook in case of notification
729
class TagTestHook extends JoinPointHook
730     {
731         Object JavaDoc omenTag;
732         Object JavaDoc omexTag;
733         Object JavaDoc ofmTag;
734         Object JavaDoc ofaTag;
735         Object JavaDoc oexTag;
736         Object JavaDoc oexcTag;
737
738         public void onFieldAccess (FieldAccessJoinPoint joinPoint) { ofaTag=joinPoint.getAopTag(); }
739         public void onMethodEntry (MethodEntryJoinPoint joinPoint) { omenTag=joinPoint.getAopTag(); }
740         public void onMethodExit (MethodExitJoinPoint joinPoint) {omexTag=joinPoint.getAopTag(); }
741         public void onExceptionThrow (ExceptionJoinPoint joinPoint) { oexTag=joinPoint.getAopTag(); }
742         public void onExceptionCatch (ExceptionCatchJoinPoint joinPoint) { oexcTag=joinPoint.getAopTag(); }
743         public void onFieldModification(FieldModificationJoinPoint joinPoint) {ofmTag=joinPoint.getAopTag(); }
744
745       public void onClassLoad(Class JavaDoc cls) { }
746     };
747
748     TagTestHook tthook = new TagTestHook();
749
750     aspectInterface.resumeNotification(Thread.currentThread());
751     aspectInterface.setJoinPointHook(tthook);
752     test.run();
753
754     assertEquals("FA:aopTag:",stringTag,tthook.ofaTag);
755     assertEquals("MEN:aopTag:",stringTag,tthook.omenTag);
756     assertEquals("MEX:aopTag:",stringTag,tthook.omexTag);
757     assertEquals("ET:aopTag:",stringTag,tthook.oexTag);
758     assertEquals("EC:aopTag:",stringTag,tthook.oexcTag);
759     assertEquals("FM:aopTag:",stringTag,tthook.ofmTag);
760
761
762     // try to clear watches
763
exceptions = 0;
764     try { aspectInterface.clearMethodEntryWatch (method); } catch (RuntimeException JavaDoc e) { exceptions++; }
765     try { aspectInterface.clearMethodExitWatch (method); } catch (RuntimeException JavaDoc e) { exceptions++; }
766     try { aspectInterface.clearFieldAccessWatch (field ); } catch (RuntimeException JavaDoc e) { exceptions++; }
767     try { aspectInterface.clearFieldModificationWatch(field ); } catch (RuntimeException JavaDoc e) { exceptions++; }
768     try { aspectInterface.clearExceptionThrowWatch (TestException.class ); } catch (RuntimeException JavaDoc e) { exceptions++; }
769     try { aspectInterface.clearExceptionCatchWatch (TestException.class ); } catch (RuntimeException JavaDoc e) { exceptions++; }
770     assertTrue("no exceptions while clearing watches with aopTag equals to 'null'",exceptions==0);
771
772     // check if watches have been cleaned
773
exceptions = 0;try { aspectInterface.clearFieldAccessWatch (field ); } catch (WatchNotSetException e) { exceptions++; }
774
775     try { aspectInterface.clearFieldModificationWatch(field ); } catch (WatchNotSetException e) { exceptions++; }
776
777     try { aspectInterface.clearMethodExitWatch (method); } catch (WatchNotSetException e) { exceptions++; }
778
779     try { aspectInterface.clearMethodEntryWatch (method); } catch (WatchNotSetException e) { exceptions++; }
780
781     try { aspectInterface.clearExceptionThrowWatch (TestException.class ); } catch (WatchNotSetException e) { exceptions++; }
782
783     try { aspectInterface.clearExceptionCatchWatch (TestException.class ); } catch (WatchNotSetException e) { exceptions++; }
784
785     assertEquals("exceptions/re-clearing watches",6,exceptions);
786
787     // check if "normal" aopTags are treated correctly
788
aspectInterface.setMethodEntryWatch (method,method);
789     aspectInterface.setMethodExitWatch (method,method);
790     aspectInterface.setFieldAccessWatch (field ,field );
791     aspectInterface.setFieldModificationWatch(field ,field );
792     aspectInterface.setExceptionThrowWatch (TestException.class, exception);
793     aspectInterface.setExceptionCatchWatch (TestException.class, exception);
794
795     hook = new JoinPointHook() {
796       public void onFieldAccess(FieldAccessJoinPoint joinPoint) {
797       Field JavaDoc field = joinPoint.getField();
798         assertTrue("FieldAccessJoinPoint.getAopTag() contains correct field",field.equals(joinPoint.getAopTag()));
799       }
800       public void onFieldModification(FieldModificationJoinPoint joinPoint) {
801         Field JavaDoc field = joinPoint.getField();
802         assertTrue("FieldModificationJoinPoint.getAopTag() contains correct field",field.equals(joinPoint.getAopTag()));
803       }
804       public void onMethodEntry(MethodEntryJoinPoint joinPoint) {
805         Method JavaDoc method = joinPoint.getMethod();
806         assertTrue("MethodEntryJoinPoint.getAopTag() contains correct method",method.equals(joinPoint.getAopTag()));
807       }
808       public void onMethodExit(MethodExitJoinPoint joinPoint) {
809         Method JavaDoc method = joinPoint.getMethod();
810         assertTrue("MethodExitJoinPoint.getAopTag() contains correct method",method.equals(joinPoint.getAopTag()));
811       }
812       public void onExceptionThrow(ExceptionJoinPoint joinPoint) {
813         Class JavaDoc exceptionClass = joinPoint.getException().getClass();
814         assertTrue("ExceptionThrowJoinPoint.getAopTag() contains correct exception",exceptionClass.equals(joinPoint.getAopTag()));
815       }
816       public void onExceptionCatch(ExceptionCatchJoinPoint joinPoint) {
817         Class JavaDoc exceptionCatchClass = joinPoint.getException().getClass();
818         assertTrue("ExceptionCatchJoinPoint.getAopTag() contains correct exception",exceptionCatchClass.equals(joinPoint.getAopTag()));
819       }
820       public void onClassLoad(Class JavaDoc cls) { }
821     };
822
823     aspectInterface.resumeNotification(Thread.currentThread());
824     aspectInterface.setJoinPointHook(hook);
825     test.method();
826     test.field = test.field + 1;
827     test.throwMethod();
828
829     aspectInterface.clearMethodEntryWatch (method);
830     aspectInterface.clearMethodExitWatch (method);
831     aspectInterface.clearFieldAccessWatch (field);
832     aspectInterface.clearFieldModificationWatch(field );
833     aspectInterface.clearExceptionThrowWatch (TestException.class );
834     aspectInterface.clearExceptionCatchWatch (TestException.class );
835
836     aspectInterface.setJoinPointHook(null);
837     aspectInterface.resumeNotification(Thread.currentThread());
838
839   }
840
841
842   public void test_0080_SuspendResumeNotification()
843   {
844
845     Object JavaDoc aopTag = new Object JavaDoc();
846     int exceptions = 0;
847     TestHook hook = new TestHook();
848     TestClass1 test = new TestClass1();
849     TestThread thread = null;
850
851     aspectInterface.setMethodEntryWatch (method,aopTag);
852     aspectInterface.setMethodExitWatch (method,aopTag);
853     aspectInterface.setFieldAccessWatch (field ,aopTag);
854     aspectInterface.setFieldModificationWatch(field ,aopTag);
855     aspectInterface.setExceptionThrowWatch (TestException.class, aopTag);
856     aspectInterface.setExceptionCatchWatch (TestException.class, aopTag);
857
858     aspectInterface.resumeNotification(Thread.currentThread());
859     aspectInterface.setJoinPointHook(hook);
860
861     // do not suspend current thread and let it access test : 6 notifications
862
hook.reset();
863     test.run();
864     assertEquals("no suspend test, notifications",6,hook.oMEx+hook.oMEn+hook.oFA+hook.oFM+hook.oExt+hook.oExc);
865
866     // suspend current thread and let it access test : 0 notifications
867
hook.reset();
868     aspectInterface.suspendNotification(Thread.currentThread());
869     test.run();
870     aspectInterface.resumeNotification(Thread.currentThread());
871     assertTrue("no notifications",hook.oMEx+hook.oMEn+hook.oFA+hook.oFM+hook.oExt+hook.oExc==0);
872
873     // suspend a second thread and let the current thread access test : 6 notifications
874
thread = new TestThread(test);
875     hook.reset();
876     aspectInterface.suspendNotification(thread);
877     thread.start();
878     test.run();
879     try { thread.join(); } catch (InterruptedException JavaDoc e) { }
880     aspectInterface.resumeNotification(thread);
881     assertEquals("notifications from this thread",6,hook.oMEx+hook.oMEn+hook.oFA+hook.oFM+hook.oExt+hook.oExc);
882
883     // let a second thread access test : 5 notifications
884
thread = new TestThread(test);
885     hook.reset();
886     thread.start();
887     try { thread.join(); } catch (InterruptedException JavaDoc e) { }
888     assertEquals("notifications from other thread",6,hook.oMEx+hook.oMEn+hook.oFA+hook.oFM+hook.oExt+hook.oExc);
889
890     // suspend the second thread and let it access testClass : 0 notifications
891
thread = new TestThread(test);
892     hook.reset();
893
894     aspectInterface.suspendNotification(thread);
895     // test.method();
896
//test.field = test.field + 1;
897
//test.throwMethod();
898
//aspectInterface.resumeNotification(Thread.currentThread());
899
thread.start();
900     try { thread.join(); } catch (InterruptedException JavaDoc e) { }
901     aspectInterface.resumeNotification(thread);
902     assertEquals("notifications after suspend",0,hook.oMEx+hook.oMEn+hook.oFA+hook.oFM+hook.oExt+hook.oExc);
903
904     aspectInterface.clearMethodEntryWatch (method);
905     aspectInterface.clearMethodExitWatch (method);
906     aspectInterface.clearFieldAccessWatch (field );
907     aspectInterface.clearFieldModificationWatch(field );
908     aspectInterface.clearExceptionThrowWatch (TestException.class );
909     aspectInterface.clearExceptionCatchWatch (TestException.class );
910     aspectInterface.resumeNotification(Thread.currentThread());
911   }
912
913   public void test_0090_ClassLoadNotification() throws Exception JavaDoc
914   {
915     TestHook hook = new TestHook();
916     aspectInterface.setJoinPointHook(hook);
917     Class JavaDoc cls = Class.forName("ch.ethz.prose.UnreferencedTestClass");
918     aspectInterface.setJoinPointHook(null);
919     assertEquals("Number of 'onClassLoad' calls was increased",1,hook.oCL);
920   }
921
922   public void test_0100_ModifiersAndInheritance()
923   {
924
925     TestHook hook = null;
926     TestClass4 test = null;
927     Method JavaDoc[] methods = null;
928     Field JavaDoc[] fields = null;
929
930     methods = TestClass4.class.getDeclaredMethods();
931     fields = TestClass4.class.getDeclaredFields();
932     for(int m=0; m<methods.length; m++) {
933       aspectInterface.setMethodEntryWatch(methods[m],"entag");
934       aspectInterface.setMethodExitWatch(methods[m],"extag");
935     }
936
937     for(int f=0; f<fields.length; f++) {
938       aspectInterface.setFieldAccessWatch(fields[f],new Object JavaDoc());
939       aspectInterface.setFieldModificationWatch(fields[f],new Object JavaDoc());
940     }
941
942     test = new TestClass4();
943     hook = new TestHook();
944     aspectInterface.setJoinPointHook(hook);
945     aspectInterface.resumeNotification(Thread.currentThread());
946
947     test.callMethods();
948     test.accessFields();
949     aspectInterface.setJoinPointHook(null);
950     assertTrue(hook.oMEn + " of "+methods.length+" method entry events received" ,hook.oMEn==methods.length);
951     assertTrue(hook.oMEx + " of "+methods.length+" method entry events received" ,hook.oMEx==methods.length);
952     assertTrue(hook.oFA + " of "+fields.length +" field access events received" ,hook.oFA ==fields.length );
953     assertTrue(hook.oFM + " of "+fields.length +" field modification events received",hook.oFM ==fields.length );
954
955     for(int m=0; m<methods.length; m++) {
956       aspectInterface.clearMethodEntryWatch(methods[m]);
957       aspectInterface.clearMethodExitWatch(methods[m]);
958     }
959     for(int f=0; f<fields.length; f++) {
960       aspectInterface.clearFieldAccessWatch(fields[f]);
961       aspectInterface.clearFieldModificationWatch(fields[f]);
962     }
963     aspectInterface.resumeNotification(Thread.currentThread());
964   }
965
966  public void test_0110_MethodExitJoinPoints()
967   {
968
969     TestHook hook = null;
970     TestClass5 test = null;
971     Method JavaDoc[] methods = null;
972
973
974     methods = TestClass5.class.getDeclaredMethods();
975
976     for(int m=0; m<methods.length; m++)
977       aspectInterface.setMethodExitWatch(methods[m],"extag");
978
979     aspectInterface.resumeNotification(Thread.currentThread());
980
981     test = new TestClass5();
982     hook = new TestHook();
983     aspectInterface.setJoinPointHook(hook);
984     for(int exitPoint=0; exitPoint<5;exitPoint++)
985     {
986         test.exit=exitPoint;
987         test.method0();
988         test.method1();
989         test.method2();
990         test.method3();
991     }
992
993     aspectInterface.setJoinPointHook(null);
994
995     assertEquals(hook.oMEx + " of "+methods.length+" method entry events received" ,methods.length*5,hook.oMEx);
996
997     for(int m=0; m<methods.length; m++)
998           aspectInterface.clearMethodExitWatch(methods[m]);
999     aspectInterface.resumeNotification(Thread.currentThread());
1000  }
1001  
1002  
1003  public void test_0120_CatchThrow()
1004  {
1005      Object JavaDoc aopTag = new Object JavaDoc();
1006      Object JavaDoc aopTag2 = new Object JavaDoc();
1007      TestHook hook = new TestHook();
1008      TestCatch testCatch = new TestCatch();
1009      int exceptions = 0;
1010    
1011      aspectInterface.setExceptionThrowWatch (TestException.class, aopTag);
1012      aspectInterface.setExceptionCatchWatch (TestException.class, aopTag);
1013      aspectInterface.setJoinPointHook(hook);
1014        
1015      hook.reset();
1016      testCatch.field1 = 0;
1017      testCatch.field1 = testCatch.field1 + 1;
1018      testCatch.throwMethod2();
1019
1020      assertEquals("1 exception throw event(1)",1,hook.oExt);
1021      assertEquals("1 exception catch event(1)",1,hook.oExc);
1022    
1023      //*************************
1024

1025      // check if setting again the same hook changes the result
1026
aspectInterface.setJoinPointHook(hook);
1027      hook.reset();
1028      testCatch.field1 = 0;
1029      testCatch.field1 = testCatch.field1 + 1;
1030      testCatch.throwMethod2();
1031        
1032      assertEquals("1 exception throw event(2)",1,hook.oExt);
1033      assertEquals("1 exception catch event(2)",1,hook.oExc);
1034        
1035      //*************************
1036

1037      // check wether events are forwarded to the hook after he has been removed (set 'null')
1038
aspectInterface.setJoinPointHook(null);
1039    
1040      hook.reset();
1041      testCatch.field1 = 0;
1042      testCatch.field1 = testCatch.field1 + 1;
1043      testCatch.throwMethod2();
1044    
1045      assertEquals("no exception throw events",0,hook.oExt);
1046      assertEquals("no exception catch events",0,hook.oExc);
1047    
1048      //*************************
1049

1050      // check if the events are forwarded to the hook after it has been set
1051
aspectInterface.setJoinPointHook(hook);
1052      hook.reset();
1053      testCatch.field1 = 0;
1054      testCatch.field1 = testCatch.field1 + 1;
1055      testCatch.throwMethod2();
1056    
1057      assertEquals("1 exception throw event",1,hook.oExt);
1058      assertEquals("1 exception catch event",1,hook.oExc);
1059    
1060      aspectInterface.clearExceptionThrowWatch (TestException.class);
1061      aspectInterface.clearExceptionCatchWatch (TestException.class);
1062        
1063      //*************************
1064

1065      // try to set watches twice : every second set**Watch should throw a WatchAlreadySetException
1066
exceptions = 0;
1067
1068      aspectInterface.setExceptionThrowWatch (TestException.class, aopTag);
1069      try { aspectInterface.setExceptionThrowWatch (TestException.class, aopTag); }
1070      catch (WatchAlreadySetException e) { exceptions++; }
1071    
1072      aspectInterface.setExceptionCatchWatch (TestException.class, aopTag);
1073      try { aspectInterface.setExceptionCatchWatch (TestException.class, aopTag); }
1074      catch (WatchAlreadySetException e) { exceptions++; }
1075    
1076      assertEquals("2 WatchAlreadySetExceptions",2,exceptions);
1077        
1078      // try again to clear watches twice : every second clear**Watch should throw a WatchNotSetException
1079
exceptions = 0;
1080    
1081      aspectInterface.clearExceptionThrowWatch (TestException.class);
1082      try { aspectInterface.clearExceptionThrowWatch (TestException.class ); }
1083      catch (WatchNotSetException e) { exceptions++; }
1084    
1085      aspectInterface.clearExceptionCatchWatch (TestException.class);
1086      try { aspectInterface.clearExceptionCatchWatch (TestException.class); }
1087      catch (WatchNotSetException e) { exceptions++; }
1088    
1089      assertEquals("2 WatchNotSetExceptions",2,exceptions);
1090
1091      //*************************
1092

1093      // set 3 different watches for 3 types of exceptions for catch and throw
1094
aspectInterface.setExceptionThrowWatch (TestException.class, aopTag);
1095      aspectInterface.setExceptionThrowWatch (TestException2.class, aopTag);
1096      aspectInterface.setExceptionThrowWatch (TestException3.class, aopTag);
1097
1098      aspectInterface.setExceptionCatchWatch (TestException.class, aopTag);
1099      aspectInterface.setExceptionCatchWatch (TestException2.class, aopTag);
1100      aspectInterface.setExceptionCatchWatch (TestException3.class, aopTag);
1101
1102      aspectInterface.setJoinPointHook(hook);
1103
1104      // check if 3 catch and throw events are forwarded to the hook after it has been set
1105
hook.reset();
1106      testCatch.field1 = 0; testCatch.field2 = 0;
1107      testCatch.field1 = testCatch.field1 + 2;
1108      testCatch.field2 = testCatch.field2 + 2;
1109      testCatch.throwMethod4();
1110      testCatch.throwMethod5();
1111      testCatch.throwMethod3();
1112
1113      assertEquals("3 exceptions throw events for TestException, 2 and 3",3,hook.oExt);
1114      assertEquals("3 exceptions catch events for TestException, 2 and 3",3,hook.oExc);
1115
1116      //*************************
1117
// check if 3 catch and throw events are forwarded to the hook after it has been set
1118
hook.reset();
1119      testCatch.field1 = 0; testCatch.field2 = 0;
1120      testCatch.field1 = testCatch.field1 + 3;
1121      testCatch.field2 = testCatch.field2 + 3;
1122      testCatch.throwMethod4();
1123      testCatch.throwMethod5();
1124      testCatch.throwMethod3();
1125
1126      assertEquals("1 exception throw events for TestException, 2 and 3",1,hook.oExt);
1127      assertEquals("1 exception catch events for TestException, 2 and 3",1,hook.oExc);
1128
1129      aspectInterface.clearExceptionThrowWatch (TestException.class);
1130      aspectInterface.clearExceptionThrowWatch (TestException2.class);
1131      aspectInterface.clearExceptionThrowWatch (TestException3.class);
1132
1133      aspectInterface.clearExceptionCatchWatch (TestException.class);
1134      aspectInterface.clearExceptionCatchWatch (TestException2.class);
1135      aspectInterface.clearExceptionCatchWatch (TestException3.class);
1136
1137      //*************************
1138

1139      // set throw and catch waches on TestException4
1140
aspectInterface.setExceptionThrowWatch (TestException4.class, aopTag);
1141      aspectInterface.setExceptionCatchWatch (TestException4.class, aopTag);
1142
1143      //aspectInterface.setExceptionThrowWatch (TestException2.class, aopTag);
1144
//aspectInterface.setExceptionCatchWatch (TestException2.class, aopTag);
1145

1146      aspectInterface.setJoinPointHook(hook);
1147
1148      //check if only the events for the catch wach that was set are forwarded to the hook after it has been set
1149
hook.reset();
1150      testCatch.field2 = 0;
1151      testCatch.field2 = testCatch.field2 + 2;
1152      testCatch.throwMethod6();
1153      testCatch.throwMethod4();
1154
1155      assertEquals("1 exception throw events for TestException4",1,hook.oExt);
1156      assertEquals("1 exception catch events for TestException4",1,hook.oExc);
1157
1158      aspectInterface.clearExceptionThrowWatch (TestException4.class);
1159      aspectInterface.clearExceptionCatchWatch (TestException4.class);
1160
1161      //aspectInterface.clearExceptionThrowWatch (TestException2.class);
1162
//aspectInterface.clearExceptionCatchWatch (TestException2.class);
1163

1164  }
1165
1166
1167  /**
1168   * Test suite.
1169   * @return test instance
1170   */

1171  public static
1172  Test suite()
1173  {
1174    return new TestSuite(JVMAspectInterfaceTest.class);
1175  }
1176
1177}
1178
1179
1180//======================================================================
1181
//
1182
// $Log: JVMAspectInterfaceTest.java,v $
1183
// Revision 1.3 2004/05/12 17:26:51 anicoara
1184
// Adapt Junit tests to 3.8.1 version and the new package structure
1185
//
1186
// Revision 1.1.1.1 2003/07/02 15:30:42 apopovic
1187
// Imported from ETH Zurich
1188
//
1189
// Revision 1.2 2003/07/02 12:42:33 anicoara
1190
// Added CatchJoinPoint Functionality (Requests, Join-Points, Filters, CatchCuts, Tests)
1191
//
1192
// Revision 1.1 2003/05/05 14:02:29 popovici
1193
// renaming from runes to prose
1194
//
1195
// Revision 1.4 2003/04/30 20:16:17 popovici
1196
// Changes for windows portability
1197
//
1198
// Revision 1.3 2003/04/26 14:09:55 popovici
1199
// Fixed test class load test; an old string used to be used
1200
//
1201
// Revision 1.2 2003/03/04 18:36:06 popovici
1202
// Organization of imprts
1203
//
1204
// Revision 1.1 2003/03/04 12:10:27 popovici
1205
// Moved from inf/jvmai (whitebox location) to inf/runes/ (bb location)
1206
//
1207
// Revision 1.8 2002/11/27 17:09:31 popovici
1208
// asertions more verbose, changes to show exaclty where the
1209
// exception bug appears in 1.4.
1210
//
1211
// Revision 1.7 2002/10/17 17:05:45 pschoch
1212
// Added throw capabability to JVMAI
1213
//
1214
// Revision 1.6 2002/10/17 12:23:37 pschoch
1215
// Added throw capabability to JVMAI
1216
//
1217
// Revision 1.5 2002/05/07 10:41:28 popovici
1218
// Minor improvement in the junit message error
1219
//
1220
// Revision 1.4 2002/03/11 11:02:21 smarkwal
1221
// JVMInfoInterface and JoinPointHook changed to abstract classes
1222
//
1223
// Revision 1.3 2002/02/18 14:41:38 popovici
1224
// testcases JVMAspect interfaces relaxed to allow null aop tags
1225
//
1226
// Revision 1.2 2002/02/15 12:27:11 smarkwal
1227
// doesn't rely anymore on Provider.getProvider(...)
1228
//
1229
// Revision 1.1 2002/02/05 11:13:09 smarkwal
1230
// Initial revision
1231
//
1232
//
1233
Popular Tags