KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > mbtf > v1 > engine > ErrorImplJDK13UTest


1 /*
2  * @(#)ErrorImplJDK13UTest.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.mbtf.v1.engine;
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 import net.sourceforge.groboutils.mbtf.v1.IPathHistory;
36
37 /**
38  * Tests the ErrorImpl class.
39  *
40  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
41  * @version $Date: 2003/02/10 22:52:28 $
42  * @since March 21, 2002
43  */

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

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

60     private MockControl phControl;
61     private IPathHistory mockPH;
62
63     
64     /**
65      *
66      * @exception Exception thrown under any exceptional condition.
67      */

68     protected void setUp() throws Exception JavaDoc
69     {
70         super.setUp();
71         
72         // set ourself up
73
this.phControl = EasyMock.controlFor( IPathHistory.class );
74         this.mockPH = (IPathHistory)this.phControl.getMock();
75     }
76
77
78     //-------------------------------------------------------------------------
79
// Tests
80

81     
82     public void testConstructor1()
83     {
84         ErrorImpl ei = new ErrorImpl( null, null, null );
85
86         assertNull(
87             "didn't set path history right.",
88             ei.getPathHistory() );
89         assertNull(
90             "didn't set throwable right.",
91             ei.getThrowable() );
92         assertNull(
93             "didn't set message right.",
94             ei.getMessage() );
95     }
96     
97     
98     public void testConstructor2()
99     {
100         String JavaDoc msg = "blah";
101         Throwable JavaDoc t = new Throwable JavaDoc();
102         this.phControl.activate();
103
104         ErrorImpl ei = new ErrorImpl( msg, t, this.mockPH );
105
106         assertEquals(
107             "didn't set path history right.",
108             ei.getPathHistory(),
109             this.mockPH );
110         assertEquals(
111             "didn't set throwable right.",
112             ei.getThrowable(),
113             t );
114         assertEquals(
115             "didn't set message right.",
116             ei.getMessage(),
117             msg );
118     }
119     
120     
121     //-------------------------------------------------------------------------
122
// Helpers
123

124     
125     //-------------------------------------------------------------------------
126
// Standard JUnit declarations
127

128     
129     public static Test suite()
130     {
131         TestSuite suite = new TestSuite( THIS_CLASS );
132         
133         // Test the implementation's interface conformity.
134
/*
135         suite.addTest( IxUTestI.suite(
136             new ImplementationCreator[] {
137                 new ImplementationCreator() {
138                     public Object createImplementedObject() {
139                         // XXXXXXXXXXXXXXXXXXXXXXXX
140                     }
141                 },
142             } ) );
143         */

144         return suite;
145     }
146     
147     public static void main( String JavaDoc[] args )
148     {
149         String JavaDoc[] name = { THIS_CLASS.getName() };
150         
151         // junit.textui.TestRunner.main( name );
152
// junit.swingui.TestRunner.main( name );
153

154         junit.textui.TestRunner.main( name );
155     }
156     
157     
158     /**
159      *
160      * @exception Exception thrown under any exceptional condition.
161      */

162     protected void tearDown() throws Exception JavaDoc
163     {
164         // tear ourself down
165

166         super.tearDown();
167     }
168 }
169
170
Popular Tags