KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > util > throwable > v1 > StackTraceLineParserUTest


1 /*
2  * @(#)StackTraceLineParserUTest.java
3  *
4  * Copyright (C) 2002-2003 Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  */

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 /**
37  * Tests the StackTraceLineParser class.
38  *
39  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
40  * @version $Date: 2003/02/10 22:52:43 $
41  * @since March 17, 2002
42  */

43 public class StackTraceLineParserUTest extends TestCase
44 {
45     //-------------------------------------------------------------------------
46
// Standard JUnit Class-specific declarations
47

48     private static final Class JavaDoc THIS_CLASS = StackTraceLineParserUTest.class;
49     
50     public StackTraceLineParserUTest( String JavaDoc name )
51     {
52         super( name );
53     }
54
55     
56     //-------------------------------------------------------------------------
57
// setup
58

59     /**
60      *
61      * @exception Exception thrown under any exceptional condition.
62      */

63     protected void setUp() throws Exception JavaDoc
64     {
65         super.setUp();
66         
67         // set ourself up
68
}
69
70
71     //-------------------------------------------------------------------------
72
// Tests
73

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 JavaDoc e)
83         {
84             // parse exception?
85
}
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 JavaDoc e)
97         {
98             // parse exception?
99
}
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 JavaDoc e)
111         {
112             // parse exception?
113
}
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 JavaDoc e)
125         {
126             // parse exception?
127
}
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 JavaDoc e)
139         {
140             // parse exception?
141
}
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 JavaDoc e)
153         {
154             // parse exception?
155
}
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     //-------------------------------------------------------------------------
215
// Helpers
216

217     
218     //-------------------------------------------------------------------------
219
// Standard JUnit declarations
220

221     
222     public static Test suite()
223     {
224         TestSuite suite = new TestSuite( THIS_CLASS );
225         
226         // Test the implementation's interface conformity.
227
/*
228         suite.addTest( IxUTestI.suite(
229             new ImplementationCreator[] {
230                 new ImplementationCreator() {
231                     public Object createImplementedObject() {
232                         // XXXXXXXXXXXXXXXXXXXXXXXX
233                     }
234                 },
235             } ) );
236         */

237         
238         return suite;
239     }
240     
241     public static void main( String JavaDoc[] args )
242     {
243         String JavaDoc[] name = { THIS_CLASS.getName() };
244         
245         // junit.textui.TestRunner.main( name );
246
// junit.swingui.TestRunner.main( name );
247

248         junit.textui.TestRunner.main( name );
249     }
250     
251     
252     /**
253      *
254      * @exception Exception thrown under any exceptional condition.
255      */

256     protected void tearDown() throws Exception JavaDoc
257     {
258         // tear ourself down
259

260         
261         super.tearDown();
262     }
263 }
264
265
Popular Tags