1 26 27 package net.sourceforge.groboutils.autodoc.v1.testserver.junit; 28 29 import net.sourceforge.groboutils.autodoc.v1.*; 30 import net.sourceforge.groboutils.autodoc.v1.testserver.*; 31 32 import java.util.*; 33 34 import org.easymock.EasyMock; 35 import org.easymock.MockControl; 36 import net.sourceforge.groboutils.junit.v1.iftc.*; 37 import junit.framework.Test; 38 import junit.framework.TestCase; 39 import junit.framework.TestSuite; 40 import junit.framework.AssertionFailedError; 41 42 43 50 public class JUnitTestListenerUTest extends TestCase 51 { 52 55 private static final Class THIS_CLASS = JUnitTestListenerUTest.class; 56 57 public JUnitTestListenerUTest( String name ) 58 { 59 super( name ); 60 } 61 62 63 66 67 68 72 protected void setUp() throws Exception 73 { 74 super.setUp(); 75 76 } 78 79 80 83 84 public void testNeedMoreTests() 85 {} 86 87 88 89 92 static class MyMonitor implements Monitor 93 { 94 public Vector addedInfo = new Vector(); 95 public Vector sentInfo = new Vector(); 96 public Vector testInfo = new Vector(); 97 98 public void addTestData( TestInfo info ) 99 { 100 this.addedInfo.addElement( info ); 101 this.testInfo.addElement( info ); 102 } 103 104 105 public TestData getTestData( TestInfo info ) 106 { 107 return new DefaultTestData( info ); 108 } 109 110 111 public void sendTestData( TestInfo info ) 112 { 113 if (this.addedInfo.contains( info )) 114 { 115 this.addedInfo.removeElement( info ); 116 this.sentInfo.addElement( info ); 117 } 118 else 119 { 120 throw new IllegalStateException (""); 121 } 122 } 123 124 125 public void clear() 126 { 127 this.addedInfo = new Vector(); 128 this.sentInfo = new Vector(); 129 this.testInfo = new Vector(); 130 } 131 } 132 133 134 static class MyMonitorFinder implements MonitorFinder 135 { 136 public MyMonitor monitor = new MyMonitor(); 137 public Monitor getMonitor() 138 { 139 return this.monitor; 140 } 141 } 142 143 144 static class MyJUnitTestListener extends JUnitTestListener 145 { 146 public static MyMonitorFinder finder = new MyMonitorFinder(); 147 public Vector start = new Vector(); 148 public Vector end = new Vector(); 149 public Vector error = new Vector(); 150 public Vector thr = new Vector(); 151 public Vector failure = new Vector(); 152 153 public MyJUnitTestListener() 154 { 155 super( finder ); 156 } 157 158 protected void startTest( TestData data ) 159 { 160 this.start.addElement( data ); 161 } 162 163 protected void endTest( TestData data ) 164 { 165 this.end.addElement( data ); 166 } 167 168 protected void addError( TestData data, Throwable t ) 169 { 170 this.error.addElement( data ); 171 this.thr.addElement( t ); 172 } 173 174 protected void addFailure( TestData data, AssertionFailedError t ) 175 { 176 this.failure.addElement( data ); 177 this.thr.addElement( t ); 178 } 179 } 180 181 184 185 public static TestSuite suite() 186 { 187 InterfaceTestSuite suite = JUnitTestListenerUTestI.suite(); 188 suite.addTestSuite( THIS_CLASS ); 189 suite.addFactory( new CxFactory( "A" ) { 190 public Object createImplObject() { 191 MyJUnitTestListener.finder.monitor.clear(); 192 return new MyJUnitTestListener(); 193 } 194 } ); 195 196 return suite; 197 } 198 199 public static void main( String [] args ) 200 { 201 String [] name = { THIS_CLASS.getName() }; 202 203 206 junit.textui.TestRunner.main( name ); 207 } 208 209 210 214 protected void tearDown() throws Exception 215 { 216 218 super.tearDown(); 219 } 220 } 221 222 | Popular Tags |