1 26 27 package net.sourceforge.groboutils.util.throwable.v1; 28 29 import org.easymock.EasyMock; 30 import org.easymock.MockControl; 31 import junit.framework.Test; 32 import junit.framework.TestCase; 33 import junit.framework.TestSuite; 34 35 36 43 public class StackTraceLineParserUTest extends TestCase 44 { 45 48 private static final Class THIS_CLASS = StackTraceLineParserUTest.class; 49 50 public StackTraceLineParserUTest( String name ) 51 { 52 super( name ); 53 } 54 55 56 59 63 protected void setUp() throws Exception 64 { 65 super.setUp(); 66 67 } 69 70 71 74 75 public void testConstructor1() 76 { 77 try 78 { 79 new StackTraceLineParser( null, null ); 80 fail( "did not throw an IllegalArgumentException." ); 81 } 82 catch (IllegalArgumentException e) 83 { 84 } 86 } 87 88 89 public void testConstructor2() 90 { 91 try 92 { 93 new StackTraceLineParser( "me", null ); 94 fail( "did not throw an IllegalArgumentException." ); 95 } 96 catch (IllegalArgumentException e) 97 { 98 } 100 } 101 102 103 public void testConstructor3() 104 { 105 try 106 { 107 new StackTraceLineParser( null, "you" ); 108 fail( "did not throw an IllegalArgumentException." ); 109 } 110 catch (IllegalArgumentException e) 111 { 112 } 114 } 115 116 117 public void testConstructor4() 118 { 119 try 120 { 121 new StackTraceLineParser( null, null, 1 ); 122 fail( "did not throw an IllegalArgumentException." ); 123 } 124 catch (IllegalArgumentException e) 125 { 126 } 128 } 129 130 131 public void testConstructor5() 132 { 133 try 134 { 135 new StackTraceLineParser( "me", null, 1 ); 136 fail( "did not throw an IllegalArgumentException." ); 137 } 138 catch (IllegalArgumentException e) 139 { 140 } 142 } 143 144 145 public void testConstructor6() 146 { 147 try 148 { 149 new StackTraceLineParser( null, "you", 1 ); 150 fail( "did not throw an IllegalArgumentException." ); 151 } 152 catch (IllegalArgumentException e) 153 { 154 } 156 } 157 158 159 public void testInit1() 160 { 161 StackTraceLineParser stlp = new StackTraceLineParser( "me", "you" ); 162 assertEquals( 163 "Did not save class name right.", 164 "me", 165 stlp.getClassName() ); 166 assertEquals( 167 "Did not save method name right.", 168 "you", 169 stlp.getMethodName() ); 170 assertEquals( 171 "Did not save default line number right.", 172 -1, 173 stlp.getLineNumber() ); 174 } 175 176 177 public void testInit2() 178 { 179 StackTraceLineParser stlp = new StackTraceLineParser( "me", "you", -100 ); 180 assertEquals( 181 "Did not save class name right.", 182 "me", 183 stlp.getClassName() ); 184 assertEquals( 185 "Did not save method name right.", 186 "you", 187 stlp.getMethodName() ); 188 assertEquals( 189 "Did not set out-of-range line number right.", 190 -1, 191 stlp.getLineNumber() ); 192 } 193 194 195 public void testInit3() 196 { 197 StackTraceLineParser stlp = new StackTraceLineParser( "me", "you", 100 ); 198 assertEquals( 199 "Did not save class name right.", 200 "me", 201 stlp.getClassName() ); 202 assertEquals( 203 "Did not save method name right.", 204 "you", 205 stlp.getMethodName() ); 206 assertEquals( 207 "Did not save line number right.", 208 100, 209 stlp.getLineNumber() ); 210 } 211 212 213 214 217 218 221 222 public static Test suite() 223 { 224 TestSuite suite = new TestSuite( THIS_CLASS ); 225 226 237 238 return suite; 239 } 240 241 public static void main( String [] args ) 242 { 243 String [] name = { THIS_CLASS.getName() }; 244 245 248 junit.textui.TestRunner.main( name ); 249 } 250 251 252 256 protected void tearDown() throws Exception 257 { 258 260 261 super.tearDown(); 262 } 263 } 264 265 | Popular Tags |