1 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 ; 36 37 import net.sourceforge.groboutils.mbtf.v1.assembler.*; 38 import net.sourceforge.groboutils.mbtf.v1.*; 39 40 47 public class BreadthPathGeneratorUTest extends TestCase 48 { 49 52 private static final Class THIS_CLASS = BreadthPathGeneratorUTest.class; 53 54 public BreadthPathGeneratorUTest( String name ) 55 { 56 super( name ); 57 } 58 59 60 63 67 protected void setUp() throws Exception 68 { 69 super.setUp(); 70 71 } 73 74 75 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 e) 94 { 95 } 97 } 98 99 public void testInnerStateConstructor2() 100 { 101 try 102 { 103 new BreadthPathGenerator.InnerState( null, new Hashtable () ); 104 fail("Did not throw IllegalArgumentException"); 105 } 106 catch (IllegalArgumentException e) 107 { 108 } 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 e) 123 { 124 } 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 iae) 137 { 138 } 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 168 public void assertEquals( String msg, Object [] left, Object [] 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 188 189 public static Test suite() 190 { 191 TestSuite suite = new TestSuite( THIS_CLASS ); 192 193 204 return suite; 205 } 206 207 public static void main( String [] args ) 208 { 209 String [] name = { THIS_CLASS.getName() }; 210 211 214 junit.textui.TestRunner.main( name ); 215 } 216 217 218 222 protected void tearDown() throws Exception 223 { 224 226 super.tearDown(); 227 } 228 } 229 230 | Popular Tags |