1 26 27 package net.sourceforge.groboutils.codecoverage.v2.compiler; 28 29 import junit.framework.Test; 30 import junit.framework.TestCase; 31 import junit.framework.TestSuite; 32 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 33 34 35 42 public class ParseCoverageLoggerUTest extends TestCase 43 { 44 47 private static final Class THIS_CLASS = ParseCoverageLoggerUTest.class; 48 private static final AutoDoc DOC = new AutoDoc( THIS_CLASS ); 49 50 public ParseCoverageLoggerUTest( String name ) 51 { 52 super( name ); 53 } 54 55 56 59 60 public void testConstructor1() 61 { 62 new ParseCoverageLogger(); 63 } 64 65 66 public void testConstructor2() 67 { 68 try 69 { 70 new ParseCoverageLogger( null, null ); 71 fail( "Did not throw IllegalArgumentException." ); 72 } 73 catch (IllegalArgumentException iae) 74 { 75 } 77 } 78 79 80 public void testConstructor3() 81 { 82 try 83 { 84 new ParseCoverageLogger( THIS_CLASS, null ); 85 fail( "Did not throw IllegalArgumentException." ); 86 } 87 catch (IllegalArgumentException iae) 88 { 89 } 91 } 92 93 94 public void testConstructor4() 95 { 96 try 97 { 98 new ParseCoverageLogger( null, "" ); 99 fail( "Did not throw IllegalArgumentException." ); 100 } 101 catch (IllegalArgumentException iae) 102 { 103 } 105 } 106 107 108 public void testConstructor5() 109 { 110 try 111 { 112 new ParseCoverageLogger( MyLogger.class, "not-exist" ); 113 fail( "Did not throw IllegalStateException." ); 114 } 115 catch (IllegalStateException iae) 116 { 117 } 119 } 120 121 122 public void testConstructor6() 123 { 124 try 125 { 126 new ParseCoverageLogger( MyLogger.class, "bad1" ); 127 fail( "Did not throw IllegalStateException." ); 128 } 129 catch (IllegalStateException iae) 130 { 131 } 133 } 134 135 136 public void testConstructor7() 137 { 138 try 139 { 140 new ParseCoverageLogger( MyLogger.class, "bad2" ); 141 fail( "Did not throw IllegalStateException." ); 142 } 143 catch (IllegalStateException iae) 144 { 145 } 147 } 148 149 150 public void testConstructor8() 151 { 152 try 153 { 154 new ParseCoverageLogger( MyLogger.class, "bad3" ); 155 fail( "Did not throw IllegalStateException." ); 156 } 157 catch (IllegalStateException iae) 158 { 159 } 161 } 162 163 164 public void testConstructor9() 165 { 166 try 167 { 168 new ParseCoverageLogger( MyLogger.class, "bad4" ); 169 fail( "Did not throw IllegalStateException." ); 170 } 171 catch (IllegalStateException iae) 172 { 173 } 175 } 176 177 178 public void testConstructor10() 179 { 180 try 181 { 182 new ParseCoverageLogger( MyLogger.class, "bad5" ); 183 fail( "Did not throw IllegalStateException." ); 184 } 185 catch (IllegalStateException iae) 186 { 187 } 189 } 190 191 192 public void testConstructor11() 193 { 194 try 195 { 196 new ParseCoverageLogger( MyLogger.class, "bad6" ); 197 fail( "Did not throw IllegalStateException." ); 198 } 199 catch (IllegalStateException iae) 200 { 201 } 203 } 204 205 206 public void testConstructor12() 207 { 208 new ParseCoverageLogger( MyLogger.class, "good" ); 209 } 210 211 212 public void testGetClassName1() 213 { 214 ParseCoverageLogger pcl = new ParseCoverageLogger( 215 MyLogger.class, "good" ); 216 assertEquals( 217 "Incorrect class name.", 218 MyLogger.class.getName(), 219 pcl.getClassName() ); 220 } 221 222 223 public void testGetMethodName1() 224 { 225 ParseCoverageLogger pcl = new ParseCoverageLogger( 226 MyLogger.class, "good" ); 227 assertEquals( 228 "Incorrect method name.", 229 "good", 230 pcl.getMethodName() ); 231 } 232 233 234 public void testGetMethodSignature1() 235 { 236 ParseCoverageLogger pcl = new ParseCoverageLogger( 237 MyLogger.class, "good" ); 238 assertEquals( 239 "Incorrect method signature.", 240 "(Ljava/lang/String;SSS)V", 241 pcl.getMethodSignature() ); 242 } 243 244 245 246 249 public static class MyLogger 250 { 251 public static void good( String s, short a, short b, short c ) 252 { 253 } 254 public static String bad1( String s, short a, short b, short c ) 255 { 256 return ""; 257 } 258 public void bad2( String s, short a, short b, short c ) 259 { 260 } 261 protected static void bad3( String s, short a, short b, short c ) 262 { 263 } 264 static void bad4( String s, short a, short b, short c ) 265 { 266 } 267 protected void bad5( String s, short a, short b, short c ) 268 { 269 } 270 void bad6( String s, short a, short b, short c ) 271 { 272 } 273 } 274 275 276 279 280 public static Test suite() 281 { 282 TestSuite suite = new TestSuite( THIS_CLASS ); 283 284 return suite; 285 } 286 287 public static void main( String [] args ) 288 { 289 String [] name = { THIS_CLASS.getName() }; 290 291 294 junit.textui.TestRunner.main( name ); 295 } 296 297 298 302 protected void setUp() throws Exception 303 { 304 super.setUp(); 305 306 } 308 309 310 314 protected void tearDown() throws Exception 315 { 316 318 319 super.tearDown(); 320 } 321 } 322 323 | Popular Tags |