1 26 27 package net.sourceforge.groboutils.autodoc.v1.testserver; 28 29 import net.sourceforge.groboutils.autodoc.v1.*; 30 31 import org.easymock.EasyMock; 32 import org.easymock.MockControl; 33 import net.sourceforge.groboutils.junit.v1.iftc.*; 34 import junit.framework.Test; 35 import junit.framework.TestCase; 36 import junit.framework.TestSuite; 37 38 39 46 public class DefaultMonitorUTest extends TestCase 47 { 48 51 private static final Class THIS_CLASS = DefaultMonitorUTest.class; 52 53 public DefaultMonitorUTest( String name ) 54 { 55 super( name ); 56 } 57 58 59 62 66 protected void setUp() throws Exception 67 { 68 super.setUp(); 69 70 } 72 73 74 77 78 public void testConstructor1() 79 { 80 try 81 { 82 new DefaultMonitor( null, null ); 83 fail("Did not throw an IllegalArgumentException"); 84 } 85 catch (IllegalArgumentException ise) 86 { 87 } 89 } 90 91 92 public void testConstructor2() 93 { 94 Server s = new MyServer(); 95 try 96 { 97 new DefaultMonitor( s, null ); 98 fail("Did not throw an IllegalArgumentException"); 99 } 100 catch (IllegalArgumentException ise) 101 { 102 } 104 } 105 106 107 public void testConstructor3() 108 { 109 TestDataFactory tdf = new MyTDFactory(); 110 try 111 { 112 new DefaultMonitor( null, tdf ); 113 fail("Did not throw an IllegalArgumentException"); 114 } 115 catch (IllegalArgumentException ise) 116 { 117 } 119 } 120 121 122 public void testRemoveInfoOnSend1() 123 { 124 DefaultMonitor dm = new DefaultMonitor( 125 new MyServer(), new MyTDFactory() ); 126 TestInfo ti = new DefaultTestInfo( "A", "b" ); 127 dm.addTestData( ti ); 128 dm.sendTestData( ti ); 129 try 130 { 131 dm.getTestData( ti ); 132 fail( "Did not throw an IllegalStateException." ); 133 } 134 catch (IllegalStateException ise) 135 { 136 } 138 } 139 140 141 142 143 146 147 protected static class MyServer implements Server 148 { 149 public void addTestData( TestData td ) 150 { 151 } 153 } 154 155 156 protected static class MyTestData implements TestData 157 { 158 TestInfo info; 159 public MyTestData( TestInfo ti ) 160 { 161 this.info = ti; 162 } 163 public TestInfo getTestInfo() 164 { 165 return this.info; 166 } 167 } 168 169 170 protected static class MyTDFactory implements TestDataFactory 171 { 172 public TestData createTestData( TestInfo info ) 173 { 174 return new MyTestData( info ); 175 } 176 } 177 178 179 180 183 184 public static Test suite() 185 { 186 InterfaceTestSuite suite = MonitorUTestI.suite(); 187 suite.addTestSuite( THIS_CLASS ); 188 suite.addFactory( new CxFactory( "A" ) { 189 public Object createImplObject() { 190 Server s = new MyServer(); 191 TestDataFactory tdf = new MyTDFactory(); 192 return new DefaultMonitor( s, tdf ); 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 |