KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)PathIteratorImplUTest.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.IError;
36 import net.sourceforge.groboutils.mbtf.v1.IErrors;
37 import net.sourceforge.groboutils.mbtf.v1.ISystem;
38 import net.sourceforge.groboutils.mbtf.v1.IAction;
39 import net.sourceforge.groboutils.mbtf.v1.ITransition;
40 import net.sourceforge.groboutils.mbtf.v1.IPathHistory;
41 import net.sourceforge.groboutils.mbtf.v1.TestHaltRuntimeException;
42
43 import java.util.NoSuchElementException JavaDoc;
44
45 /**
46  * Tests the PathIteratorImpl class.
47  *
48  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
49  * @version $Date: 2003/02/10 22:52:28 $
50  * @since March 21, 2002
51  */

52 public class PathIteratorImplUTest extends TestCase
53 {
54     //-------------------------------------------------------------------------
55
// Standard JUnit Class-specific declarations
56

57     private static final Class JavaDoc THIS_CLASS = PathIteratorImplUTest.class;
58     
59     public PathIteratorImplUTest( String JavaDoc name )
60     {
61         super( name );
62     }
63
64     
65     //-------------------------------------------------------------------------
66
// setup
67

68     /**
69      *
70      * @exception Exception thrown under any exceptional condition.
71      */

72     protected void setUp() throws Exception JavaDoc
73     {
74         super.setUp();
75         
76         // set ourself up
77
}
78
79
80     //-------------------------------------------------------------------------
81
// Tests
82

83     
84     private static class MyAction implements IAction
85     {
86         public void performAction( ISystem s, IErrors e ) {}
87     }
88
89     
90     public void testNextTransition1()
91     {
92         try
93         {
94             (new PathIteratorImpl( null )).nextTransition();
95             fail("Did not throw NoSuchElementException");
96         }
97         catch (NoSuchElementException JavaDoc e)
98         {
99             // check exception
100
}
101     }
102     
103     public void testNextTransition2()
104     {
105         TransitionImpl trans = new TransitionImpl( "trans", null,
106             new MyAction(), null );
107         PathIteratorImpl pii = new PathIteratorImpl(
108             new ITransition[] { trans } );
109         assertEquals(
110             "did not return correct transition.",
111             trans,
112             pii.nextTransition() );
113     }
114     
115     
116     
117     //-------------------------------------------------------------------------
118
// Helpers
119

120     public void assertEquals( String JavaDoc msg, Object JavaDoc[] left, Object JavaDoc[] right )
121     {
122         if (left == null)
123         {
124             assertNull( msg, right );
125         }
126         else
127         {
128             assertNotNull( msg, right );
129             assertEquals( msg, left.length, right.length );
130             for (int i = left.length; ++i >= 0;)
131             {
132                 assertEquals( msg, left[i], right[i] );
133             }
134         }
135     }
136     
137     //-------------------------------------------------------------------------
138
// Standard JUnit declarations
139

140     
141     public static Test suite()
142     {
143         TestSuite suite = new TestSuite( THIS_CLASS );
144         
145         // Test the implementation's interface conformity.
146
/*
147         suite.addTest( IxUTestI.suite(
148             new ImplementationCreator[] {
149                 new ImplementationCreator() {
150                     public Object createImplementedObject() {
151                         // XXXXXXXXXXXXXXXXXXXXXXXX
152                     }
153                 },
154             } ) );
155         */

156         return suite;
157     }
158     
159     public static void main( String JavaDoc[] args )
160     {
161         String JavaDoc[] name = { THIS_CLASS.getName() };
162         
163         // junit.textui.TestRunner.main( name );
164
// junit.swingui.TestRunner.main( name );
165

166         junit.textui.TestRunner.main( name );
167     }
168     
169     
170     /**
171      *
172      * @exception Exception thrown under any exceptional condition.
173      */

174     protected void tearDown() throws Exception JavaDoc
175     {
176         // tear ourself down
177

178         super.tearDown();
179     }
180 }
181
182
Popular Tags