1 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 48 public class AsmblTransitionUTest extends TestCase 49 { 50 53 private static final Class THIS_CLASS = AsmblTransitionUTest.class; 54 55 public AsmblTransitionUTest( String name ) 56 { 57 super( name ); 58 } 59 60 61 64 68 protected void setUp() throws Exception 69 { 70 super.setUp(); 71 72 } 74 75 76 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 iae) 142 { 143 } 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 e) 174 { 175 } 177 } 178 179 180 183 184 187 188 public static Test suite() 189 { 190 TestSuite suite = new TestSuite( THIS_CLASS ); 191 192 203 return suite; 204 } 205 206 public static void main( String [] args ) 207 { 208 String [] name = { THIS_CLASS.getName() }; 209 210 213 junit.textui.TestRunner.main( name ); 214 } 215 216 217 221 protected void tearDown() throws Exception 222 { 223 225 super.tearDown(); 226 } 227 } 228 229 | Popular Tags |