KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)BreadthPathGeneratorUTest.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 java.util.Hashtable JavaDoc;
36
37 import net.sourceforge.groboutils.mbtf.v1.assembler.*;
38 import net.sourceforge.groboutils.mbtf.v1.*;
39
40 /**
41  * Tests the BreadthPathGenerator class.
42  *
43  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
44  * @version $Date: 2003/02/10 22:52:28 $
45  * @since June 17, 2002
46  */

47 public class BreadthPathGeneratorUTest extends TestCase
48 {
49     //-------------------------------------------------------------------------
50
// Standard JUnit Class-specific declarations
51

52     private static final Class JavaDoc THIS_CLASS = BreadthPathGeneratorUTest.class;
53     
54     public BreadthPathGeneratorUTest( String JavaDoc name )
55     {
56         super( name );
57     }
58
59     
60     //-------------------------------------------------------------------------
61
// setup
62

63     /**
64      *
65      * @exception Exception thrown under any exceptional condition.
66      */

67     protected void setUp() throws Exception JavaDoc
68     {
69         super.setUp();
70         
71         // set ourself up
72
}
73
74
75     //-------------------------------------------------------------------------
76
// Tests
77

78     
79     private static class MyAction implements IAction
80     {
81         public void performAction( ISystem s, IErrors e ) {}
82     }
83     
84     
85     
86     public void testInnerStateConstructor1()
87     {
88         try
89         {
90             new BreadthPathGenerator.InnerState( null, null );
91             fail("Did not throw IllegalArgumentException");
92         }
93         catch (IllegalArgumentException JavaDoc e)
94         {
95             // check exception
96
}
97     }
98     
99     public void testInnerStateConstructor2()
100     {
101         try
102         {
103             new BreadthPathGenerator.InnerState( null, new Hashtable JavaDoc() );
104             fail("Did not throw IllegalArgumentException");
105         }
106         catch (IllegalArgumentException JavaDoc e)
107         {
108             // check exception
109
}
110     }
111     
112     public void testInnerStateConstructor3()
113     {
114         AsmblState state = new AsmblState();
115         state.setName( "state" );
116         AsmblTransitionSet ats = new AsmblTransitionSet();
117         try
118         {
119             new BreadthPathGenerator.InnerState( state.createState( ats ), null );
120             fail("Did not throw IllegalArgumentException");
121         }
122         catch (IllegalArgumentException JavaDoc e)
123         {
124             // check exception
125
}
126     }
127
128     
129     public void testConstructor1()
130     {
131         try
132         {
133             new BreadthPathGenerator( null, null );
134             fail("did not throw IllegalArgumentException");
135         }
136         catch (IllegalArgumentException JavaDoc iae)
137         {
138             // check exception
139
}
140     }
141
142     
143     public void testStructure1()
144     {
145         AsmblState state1 = new AsmblState();
146         state1.setName( "state1" );
147         state1.addTransitionName( "trans1" );
148         AsmblStateSet ass = new AsmblStateSet();
149         ass.addState( state1 );
150
151         AsmblTransition trans1 = new AsmblTransition();
152         trans1.setName( "trans1" );
153         trans1.setNextStateName( "state1" );
154         trans1.setAction( new MyAction() );
155         AsmblTransitionSet ats = new AsmblTransitionSet();
156         ats.addTransition( trans1 );
157         
158         Assembler asm = new Assembler( ats, ass );
159
160         new BreadthPathGenerator( asm.getStates(), null );
161     }
162     
163     
164     
165     //-------------------------------------------------------------------------
166
// Helpers
167

168     public void assertEquals( String JavaDoc msg, Object JavaDoc[] left, Object JavaDoc[] right )
169     {
170         if (left == null)
171         {
172             assertNull( msg, right );
173         }
174         else
175         {
176             assertNotNull( msg, right );
177             assertEquals( msg, left.length, right.length );
178             for (int i = left.length; ++i >= 0;)
179             {
180                 assertEquals( msg, left[i], right[i] );
181             }
182         }
183     }
184     
185     //-------------------------------------------------------------------------
186
// Standard JUnit declarations
187

188     
189     public static Test suite()
190     {
191         TestSuite suite = new TestSuite( THIS_CLASS );
192         
193         // Test the implementation's interface conformity.
194
/*
195         suite.addTest( IxUTestI.suite(
196             new ImplementationCreator[] {
197                 new ImplementationCreator() {
198                     public Object createImplementedObject() {
199                         // XXXXXXXXXXXXXXXXXXXXXXXX
200                     }
201                 },
202             } ) );
203         */

204         return suite;
205     }
206     
207     public static void main( String JavaDoc[] args )
208     {
209         String JavaDoc[] name = { THIS_CLASS.getName() };
210         
211         // junit.textui.TestRunner.main( name );
212
// junit.swingui.TestRunner.main( name );
213

214         junit.textui.TestRunner.main( name );
215     }
216     
217     
218     /**
219      *
220      * @exception Exception thrown under any exceptional condition.
221      */

222     protected void tearDown() throws Exception JavaDoc
223     {
224         // tear ourself down
225

226         super.tearDown();
227     }
228 }
229
230
Popular Tags