001: /*
002: * @(#)BreadthPathGeneratorUTest.java
003: *
004: * Copyright (C) 2002-2003 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a
009: * copy of this software and associated documentation files (the "Software"),
010: * to deal in the Software without restriction, including without limitation
011: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
012: * and/or sell copies of the Software, and to permit persons to whom the
013: * Software is furnished to do so, subject to the following conditions:
014: *
015: * The above copyright notice and this permission notice shall be included in
016: * all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
021: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024: * DEALINGS IN THE SOFTWARE.
025: */
026:
027: package net.sourceforge.groboutils.mbtf.v1.engine;
028:
029: import org.easymock.EasyMock;
030: import org.easymock.MockControl;
031: import junit.framework.Test;
032: import junit.framework.TestCase;
033: import junit.framework.TestSuite;
034:
035: import java.util.Hashtable;
036:
037: import net.sourceforge.groboutils.mbtf.v1.assembler.*;
038: import net.sourceforge.groboutils.mbtf.v1.*;
039:
040: /**
041: * Tests the BreadthPathGenerator class.
042: *
043: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
044: * @version $Date: 2003/02/10 22:52:28 $
045: * @since June 17, 2002
046: */
047: public class BreadthPathGeneratorUTest extends TestCase {
048: //-------------------------------------------------------------------------
049: // Standard JUnit Class-specific declarations
050:
051: private static final Class THIS_CLASS = BreadthPathGeneratorUTest.class;
052:
053: public BreadthPathGeneratorUTest(String name) {
054: super (name);
055: }
056:
057: //-------------------------------------------------------------------------
058: // setup
059:
060: /**
061: *
062: * @exception Exception thrown under any exceptional condition.
063: */
064: protected void setUp() throws Exception {
065: super .setUp();
066:
067: // set ourself up
068: }
069:
070: //-------------------------------------------------------------------------
071: // Tests
072:
073: private static class MyAction implements IAction {
074: public void performAction(ISystem s, IErrors e) {
075: }
076: }
077:
078: public void testInnerStateConstructor1() {
079: try {
080: new BreadthPathGenerator.InnerState(null, null);
081: fail("Did not throw IllegalArgumentException");
082: } catch (IllegalArgumentException e) {
083: // check exception
084: }
085: }
086:
087: public void testInnerStateConstructor2() {
088: try {
089: new BreadthPathGenerator.InnerState(null, new Hashtable());
090: fail("Did not throw IllegalArgumentException");
091: } catch (IllegalArgumentException e) {
092: // check exception
093: }
094: }
095:
096: public void testInnerStateConstructor3() {
097: AsmblState state = new AsmblState();
098: state.setName("state");
099: AsmblTransitionSet ats = new AsmblTransitionSet();
100: try {
101: new BreadthPathGenerator.InnerState(state.createState(ats),
102: null);
103: fail("Did not throw IllegalArgumentException");
104: } catch (IllegalArgumentException e) {
105: // check exception
106: }
107: }
108:
109: public void testConstructor1() {
110: try {
111: new BreadthPathGenerator(null, null);
112: fail("did not throw IllegalArgumentException");
113: } catch (IllegalArgumentException iae) {
114: // check exception
115: }
116: }
117:
118: public void testStructure1() {
119: AsmblState state1 = new AsmblState();
120: state1.setName("state1");
121: state1.addTransitionName("trans1");
122: AsmblStateSet ass = new AsmblStateSet();
123: ass.addState(state1);
124:
125: AsmblTransition trans1 = new AsmblTransition();
126: trans1.setName("trans1");
127: trans1.setNextStateName("state1");
128: trans1.setAction(new MyAction());
129: AsmblTransitionSet ats = new AsmblTransitionSet();
130: ats.addTransition(trans1);
131:
132: Assembler asm = new Assembler(ats, ass);
133:
134: new BreadthPathGenerator(asm.getStates(), null);
135: }
136:
137: //-------------------------------------------------------------------------
138: // Helpers
139:
140: public void assertEquals(String msg, Object[] left, Object[] right) {
141: if (left == null) {
142: assertNull(msg, right);
143: } else {
144: assertNotNull(msg, right);
145: assertEquals(msg, left.length, right.length);
146: for (int i = left.length; ++i >= 0;) {
147: assertEquals(msg, left[i], right[i]);
148: }
149: }
150: }
151:
152: //-------------------------------------------------------------------------
153: // Standard JUnit declarations
154:
155: public static Test suite() {
156: TestSuite suite = new TestSuite(THIS_CLASS);
157:
158: // Test the implementation's interface conformity.
159: /*
160: suite.addTest( IxUTestI.suite(
161: new ImplementationCreator[] {
162: new ImplementationCreator() {
163: public Object createImplementedObject() {
164: // XXXXXXXXXXXXXXXXXXXXXXXX
165: }
166: },
167: } ) );
168: */
169: return suite;
170: }
171:
172: public static void main(String[] args) {
173: String[] name = { THIS_CLASS.getName() };
174:
175: // junit.textui.TestRunner.main( name );
176: // junit.swingui.TestRunner.main( name );
177:
178: junit.textui.TestRunner.main(name);
179: }
180:
181: /**
182: *
183: * @exception Exception thrown under any exceptional condition.
184: */
185: protected void tearDown() throws Exception {
186: // tear ourself down
187:
188: super.tearDown();
189: }
190: }
|