KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > ExceptionEventTest


1 package test;
2
3 import alt.jiapi.event.ExceptionEventProducer;
4 import alt.jiapi.event.ExceptionListener;
5 import alt.jiapi.event.ExceptionEvent;
6 import alt.jiapi.*;
7
8 /**
9  * This class is mainly used to test Jiapi event model.
10  * In addition to that, it servers as an example to using
11  * Jiapi event model.
12  */

13 public class ExceptionEventTest extends InstrumentorTest implements ExceptionListener {
14     public static void main(String JavaDoc [] args) throws Exception JavaDoc {
15         ExceptionEventTest ft = new ExceptionEventTest();
16         ft.run(args);
17     }
18
19     public ExceptionEventTest() throws JiapiException {
20         InstrumentationDescriptor id = new InstrumentationDescriptor();
21         ctx.addInstrumentationDescriptor(id);
22
23         addInclusionRules(id, getInclusionRules());
24         addExclusionRules(id, getExclusionRules());
25
26         ExceptionEventProducer fep =
27             new ExceptionEventProducer(id, System.getProperty("resolution", "*"));
28
29         fep.addExceptionListener(this);
30     }
31
32     // --- Interface FieldListener ---
33
public void exceptionCaught(ExceptionEvent event) {
34         Object JavaDoc target = event.getTarget();
35         String JavaDoc __target = null;
36         if (target != null) {
37             __target = target.getClass().toString();
38         }
39
40         System.out.println("Exception caught : " + event + "::" +
41                            __target);
42     }
43
44
45     // Default test case name
46
public String JavaDoc defaultClassName() {
47         return "test.ExceptionTest";
48     }
49 }
50
Popular Tags