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 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 ; 44 45 52 public class PathIteratorImplUTest extends TestCase 53 { 54 57 private static final Class THIS_CLASS = PathIteratorImplUTest.class; 58 59 public PathIteratorImplUTest( String name ) 60 { 61 super( name ); 62 } 63 64 65 68 72 protected void setUp() throws Exception 73 { 74 super.setUp(); 75 76 } 78 79 80 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 e) 98 { 99 } 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 120 public void assertEquals( String msg, Object [] left, Object [] 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 140 141 public static Test suite() 142 { 143 TestSuite suite = new TestSuite( THIS_CLASS ); 144 145 156 return suite; 157 } 158 159 public static void main( String [] args ) 160 { 161 String [] name = { THIS_CLASS.getName() }; 162 163 166 junit.textui.TestRunner.main( name ); 167 } 168 169 170 174 protected void tearDown() throws Exception 175 { 176 178 super.tearDown(); 179 } 180 } 181 182 | Popular Tags |