KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > mbtf > v1 > assembler > AsmblTransitionUTest


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

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

53     private static final Class JavaDoc THIS_CLASS = AsmblTransitionUTest.class;
54     
55     public AsmblTransitionUTest( String JavaDoc name )
56     {
57         super( name );
58     }
59
60     
61     //-------------------------------------------------------------------------
62
// setup
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
}
74
75
76     //-------------------------------------------------------------------------
77
// Tests
78

79     
80     public void testConstructor1()
81     {
82         new AsmblTransition();
83     }
84     
85     
86     public void testAddValidate1()
87     {
88         AsmblTransition at = new AsmblTransition();
89         at.addValidate( null );
90         IValidate[] v = at.getValidates();
91         assertNotNull(
92             "validates returned null.",
93             v );
94         assertEquals(
95             "validates size not right.",
96             0,
97             v.length );
98     }
99     
100     
101     private static class MyValidate implements IValidate
102     {
103         public void validate( ISystem s, IErrors e ) {}
104     }
105     
106     
107     private static class MyAction implements IAction
108     {
109         public void performAction( ISystem s, IErrors e ) {}
110     }
111     
112     
113     public void testAddValidate2()
114     {
115         IValidate ov = new MyValidate();
116         AsmblTransition at = new AsmblTransition();
117         at.addValidate( ov );
118         IValidate[] v = at.getValidates();
119         assertNotNull(
120             "validates returned null.",
121             v );
122         assertEquals(
123             "validates size not right.",
124             1,
125             v.length );
126         assertEquals(
127             "validates inserted not returned.",
128             ov,
129             v[0] );
130     }
131     
132     
133     public void testGetTransition1()
134     {
135         AsmblTransition at = new AsmblTransition();
136         try
137         {
138             at.getTransition();
139             fail("did not throw IllegalArgumentException");
140         }
141         catch (IllegalArgumentException JavaDoc iae)
142         {
143             // test exception
144
}
145     }
146     
147     
148     public void testGetTransition2()
149     {
150         AsmblTransition at = new AsmblTransition();
151         at.setName( "trans" );
152         at.setNextStateName( "state" );
153         IAction act = new MyAction();
154         at.setAction( act );
155         ITransition t = at.getTransition();
156         assertNotNull(
157             "get transition returned null.",
158             t );
159         assertEquals(
160             "wrong name.",
161             "trans",
162             t.getName() );
163         assertEquals(
164             "wrong action.",
165             act,
166             t.getAction() );
167         
168         try
169         {
170             t.getDestinationState();
171             fail("did not throw IllegalStateException");
172         }
173         catch (IllegalStateException JavaDoc e)
174         {
175             // test exception
176
}
177     }
178     
179     
180     //-------------------------------------------------------------------------
181
// Helpers
182

183     
184     //-------------------------------------------------------------------------
185
// Standard JUnit declarations
186

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

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

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

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

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