1 26 27 package net.sourceforge.groboutils.pmti.v1.autodoc.v1; 28 29 import java.util.Vector ; 30 import java.util.Hashtable ; 31 import junit.framework.Test; 32 import junit.framework.TestCase; 33 import junit.framework.TestSuite; 34 import net.sourceforge.groboutils.autodoc.v1.AutoDocITUTestI; 35 import net.sourceforge.groboutils.autodoc.v1.testserver.*; 36 import net.sourceforge.groboutils.junit.v1.iftc.*; 37 import junit.framework.AssertionFailedError; 38 39 40 47 public class AutoDocITImplUTest extends TestCase 48 { 49 52 private static final Class THIS_CLASS = AutoDocITImplUTest.class; 53 55 public AutoDocITImplUTest( String name ) 56 { 57 super( name ); 58 } 59 60 61 64 68 protected void setUp() throws Exception 69 { 70 super.setUp(); 71 72 } 74 75 76 79 public class MyMonitor implements Monitor 80 { 81 public Vector addedTests = new Vector (); 82 public Hashtable testData = new Hashtable (); 83 public Vector sentTests = new Vector (); 84 85 public void addTestData( TestInfo info ) 86 { 87 addedTests.addElement( info ); 88 } 89 90 91 public TestData getTestData( TestInfo info ) 92 { 93 return (TestData)testData.get( info ); 94 } 95 96 97 public void sendTestData( TestInfo info ) 98 { 99 sentTests.addElement( info ); 100 } 101 } 102 103 public class MyMonitorFinder implements MonitorFinder 104 { 105 private Monitor m; 106 public MyMonitorFinder( Monitor m ) 107 { 108 this.m = m; 109 } 110 111 public Monitor getMonitor() 112 { 113 return m; 114 } 115 } 116 117 118 119 120 121 public void testSendTestIssue1() 122 { 123 MyMonitor mon = new MyMonitor(); 124 MyMonitorFinder mf = new MyMonitorFinder( mon ); 125 DefaultTestInfo ti = new DefaultTestInfo( "a", "b" ); 126 DefaultTestData td = new DefaultTestData( ti ); 127 mon.testData.put( ti, td ); 128 129 AutoDocITImpl it = new AutoDocITImpl( THIS_CLASS, mf ); 130 try 131 { 132 it.sendTestIssue( ti, "" ); 133 fail("did not throw IllegalStateException"); 134 } 135 catch (IllegalStateException iae) 136 { 137 } 139 } 140 141 142 public void testSendTestIssue2() 143 { 144 MyMonitor mon = new MyMonitor(); 145 MyMonitorFinder mf = new MyMonitorFinder( mon ); 146 DefaultTestInfo ti = new DefaultTestInfo( "a", "b" ); 147 ITFTestData td = new ITFTestData( ti ); 148 mon.testData.put( ti, td ); 149 150 AutoDocITImpl it = new AutoDocITImpl( THIS_CLASS, mf ); 151 it.sendTestIssue( ti, "a" ); 152 153 String [] issues = td.getIssues(); 154 assertNotNull( 155 "null issue set", 156 issues ); 157 assertEquals( 158 "incorrect number of issues registered.", 159 issues.length, 160 1 ); 161 assertEquals( 162 "incorrect registration of issue.", 163 issues[0], 164 "a" ); 165 } 166 167 168 169 172 173 176 177 public static Test suite() 178 { 179 InterfaceTestSuite suite = AutoDocITUTestI.suite(); 180 suite.addTestSuite( THIS_CLASS ); 181 suite.addFactory( new CxFactory( "A" ) { 182 public Object createImplObject() { 183 return new AutoDocITImpl( THIS_CLASS ); 184 } 185 } ); 186 187 return suite; 188 } 189 190 public static void main( String [] args ) 191 { 192 String [] name = { THIS_CLASS.getName() }; 193 194 197 junit.textui.TestRunner.main( name ); 198 } 199 200 201 205 protected void tearDown() throws Exception 206 { 207 209 210 super.tearDown(); 211 } 212 } 213 214 | Popular Tags |