1 26 27 package net.sourceforge.groboutils.autodoc.v1.testserver; 28 29 import net.sourceforge.groboutils.autodoc.v1.*; 30 31 import java.io.Writer ; 32 import java.io.StringWriter ; 33 import java.io.IOException ; 34 35 import org.easymock.EasyMock; 36 import org.easymock.MockControl; 37 import net.sourceforge.groboutils.junit.v1.iftc.*; 38 import junit.framework.Test; 39 import junit.framework.TestCase; 40 import junit.framework.TestSuite; 41 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 42 43 44 51 public class AbstractWriterServerUTestI extends InterfaceTestCase 52 { 53 56 private static final Class THIS_CLASS = AbstractWriterServerUTestI.class; 57 58 public AbstractWriterServerUTestI( String name, ImplFactory f ) 59 { 60 super( name, AbstractWriterServer.class, f ); 61 } 62 63 64 67 71 protected void setUp() throws Exception 72 { 73 super.setUp(); 74 75 } 77 78 79 public AbstractWriterServer createAbstractWriterServer() 80 { 81 return (AbstractWriterServer)createImplObject(); 82 } 83 84 85 88 89 public void testWriteTestData1() throws Exception 90 { 91 AbstractWriterServer aws = createAbstractWriterServer(); 92 StringWriter sw = new StringWriter (); 93 94 aws.writeTestData( null, sw ); 96 } 97 98 99 public void testWriteTestData2() throws Exception 100 { 101 AbstractWriterServer aws = createAbstractWriterServer(); 102 StringWriter sw = new StringWriter (); 103 TestData td = new TestData() { 104 public TestInfo getTestInfo() { 105 return null; 106 } 107 }; 108 109 aws.writeTestData( td, sw ); 111 } 112 113 114 public void testWriteTestData3() throws Exception 115 { 116 AbstractWriterServer aws = createAbstractWriterServer(); 117 StringWriter sw = new StringWriter (); 118 final TestInfo ti = new DefaultTestInfo( "a", "b" ); 119 TestData td = new TestData() { 120 public TestInfo getTestInfo() { 121 return ti; 122 } 123 }; 124 125 aws.writeTestData( td, sw ); 127 } 128 129 130 public void testWriteTestData4() throws Exception 131 { 132 AbstractWriterServer aws = createAbstractWriterServer(); 133 StringWriter sw = new StringWriter (); 134 final TestInfo ti = new DefaultTestInfo(); 135 TestData td = new TestData() { 136 public TestInfo getTestInfo() { 137 return ti; 138 } 139 }; 140 141 aws.writeTestData( td, sw ); 143 } 144 145 146 protected void _innerOpenOutput( AbstractWriterServer aws, TestData td ) 147 { 148 try 149 { 150 Writer w = aws.openOutput( td ); 151 assertNotNull( 152 "If no exception was thrown, then openOutput must never "+ 153 "return null.", 154 w ); 155 aws.closeOutput( w ); 156 } 157 catch (IOException ioe) 158 { 159 } 161 } 162 163 164 public void testOpenOutput1() 165 { 166 AbstractWriterServer aws = createAbstractWriterServer(); 167 168 try 169 { 170 _innerOpenOutput( aws, null ); 171 } 172 catch (NullPointerException e) 173 { 174 } 176 catch (IllegalArgumentException e) 177 { 178 } 180 } 181 182 183 public void testOpenOutput2() 184 { 185 AbstractWriterServer aws = createAbstractWriterServer(); 186 StringWriter sw = new StringWriter (); 187 TestData td = new TestData() { 188 public TestInfo getTestInfo() { 189 return null; 190 } 191 }; 192 193 194 try 195 { 196 _innerOpenOutput( aws, td ); 197 } 198 catch (NullPointerException e) 199 { 200 } 202 catch (IllegalArgumentException e) 203 { 204 } 206 } 207 208 209 public void testOpenOutput3() 210 { 211 AbstractWriterServer aws = createAbstractWriterServer(); 212 StringWriter sw = new StringWriter (); 213 final TestInfo ti = new DefaultTestInfo(); 214 TestData td = new TestData() { 215 public TestInfo getTestInfo() { 216 return ti; 217 } 218 }; 219 220 _innerOpenOutput( aws, td ); 221 } 222 223 224 public void testOpenOutput4() 225 { 226 AbstractWriterServer aws = createAbstractWriterServer(); 227 StringWriter sw = new StringWriter (); 228 final TestInfo ti = new DefaultTestInfo( "a", "b" ); 229 TestData td = new TestData() { 230 public TestInfo getTestInfo() { 231 return ti; 232 } 233 }; 234 235 _innerOpenOutput( aws, td ); 236 } 237 238 239 240 243 244 245 248 249 public static InterfaceTestSuite suite() 250 { 251 InterfaceTestSuite suite = new InterfaceTestSuite( THIS_CLASS ); 252 suite.addInterfaceTestSuite( ServerUTestI.suite() ); 253 254 return suite; 255 } 256 257 public static void main( String [] args ) 258 { 259 String [] name = { THIS_CLASS.getName() }; 260 261 264 junit.textui.TestRunner.main( name ); 265 } 266 267 268 272 protected void tearDown() throws Exception 273 { 274 276 super.tearDown(); 277 } 278 } 279 280 | Popular Tags |