KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > monitors > ConsoleComponentMonitorTestCase


1 package org.picocontainer.monitors;
2
3 import java.io.PrintStream JavaDoc;
4 import java.lang.reflect.Constructor JavaDoc;
5 import java.lang.reflect.Method JavaDoc;
6
7 import junit.framework.TestCase;
8
9 import org.picocontainer.ComponentMonitor;
10
11 /**
12  * @author Aslak Hellesøy
13  * @author Mauro Talevi
14  * @version $Revision: 2024 $
15  */

16 public class ConsoleComponentMonitorTestCase extends TestCase {
17     private PrintStream JavaDoc out;
18     private ComponentMonitor componentMonitor;
19     private Constructor JavaDoc constructor;
20     private Method JavaDoc method;
21
22     protected void setUp() throws Exception JavaDoc {
23         out = System.out;
24         constructor = getClass().getConstructor((Class JavaDoc[])null);
25         method = getClass().getDeclaredMethod("setUp", (Class JavaDoc[])null);
26         componentMonitor = new ConsoleComponentMonitor(out);
27     }
28
29     public void testShouldTraceInstantiating() {
30         componentMonitor.instantiating(constructor);
31     }
32
33     public void testShouldTraceInstantiated() {
34         componentMonitor.instantiated(constructor, 543);
35     }
36
37     public void testShouldTraceInstantiatedWithInjected() {
38         componentMonitor.instantiated(constructor, new Object JavaDoc(), new Object JavaDoc[0], 543);
39     }
40
41     public void testShouldTraceInstantiationFailed() {
42         componentMonitor.instantiationFailed(constructor, new RuntimeException JavaDoc("doh"));
43     }
44
45     public void testShouldTraceInvoking() {
46         componentMonitor.invoking(method, this);
47     }
48
49     public void testShouldTraceInvoked() {
50         componentMonitor.invoked(method, this, 543);
51     }
52
53     public void testShouldTraceInvocatiationFailed() {
54         componentMonitor.invocationFailed(method, this, new RuntimeException JavaDoc("doh"));
55     }
56
57 }
58
Popular Tags