001 package org.picocontainer.monitors; 002 003 import java.io.PrintStream; 004 import java.lang.reflect.Constructor; 005 import java.lang.reflect.Method; 006 007 import junit.framework.TestCase; 008 009 import org.picocontainer.ComponentMonitor; 010 011 /** 012 * @author Aslak Hellesøy 013 * @author Mauro Talevi 014 * @version $Revision: 2024 $ 015 */ 016 public class ConsoleComponentMonitorTestCase extends TestCase { 017 private PrintStream out; 018 private ComponentMonitor componentMonitor; 019 private Constructor constructor; 020 private Method method; 021 022 protected void setUp() throws Exception { 023 out = System.out; 024 constructor = getClass().getConstructor((Class[])null); 025 method = getClass().getDeclaredMethod("setUp", (Class[])null); 026 componentMonitor = new ConsoleComponentMonitor(out); 027 } 028 029 public void testShouldTraceInstantiating() { 030 componentMonitor.instantiating(constructor); 031 } 032 033 public void testShouldTraceInstantiated() { 034 componentMonitor.instantiated(constructor, 543); 035 } 036 037 public void testShouldTraceInstantiatedWithInjected() { 038 componentMonitor.instantiated(constructor, new Object(), new Object[0], 543); 039 } 040 041 public void testShouldTraceInstantiationFailed() { 042 componentMonitor.instantiationFailed(constructor, new RuntimeException("doh")); 043 } 044 045 public void testShouldTraceInvoking() { 046 componentMonitor.invoking(method, this); 047 } 048 049 public void testShouldTraceInvoked() { 050 componentMonitor.invoked(method, this, 543); 051 } 052 053 public void testShouldTraceInvocatiationFailed() { 054 componentMonitor.invocationFailed(method, this, new RuntimeException("doh")); 055 } 056 057 }