1 5 package org.easymock.tests; 6 7 import junit.framework.TestCase; 8 9 import org.easymock.MockControl; 10 import org.easymock.internal.RecordState; 11 12 public class RecordStateInvalidStateChangeTest extends TestCase { 13 MockControl<IMethods> control; 14 15 IMethods mock; 16 17 protected void setUp() { 18 control = MockControl.createControl(IMethods.class); 19 mock = control.getMock(); 20 } 21 22 public void testActivateWithoutReturnValue() { 23 mock.oneArgumentMethod(false); 24 try { 25 control.replay(); 26 fail("IllegalStateException expected"); 27 } catch (IllegalStateException e) { 28 assertEquals( 29 "missing behavior definition for the preceeding method call oneArgumentMethod(false)", 30 e.getMessage()); 31 assertTrue("stack trace must be cut", Util.getStackTrace(e) 32 .indexOf(RecordState.class.getName()) == -1); 33 } 34 } 35 36 public void testSecondCallWithoutReturnValue() { 37 mock.oneArgumentMethod(false); 38 try { 39 mock.oneArgumentMethod(false); 40 fail("IllegalStateException expected"); 41 } catch (IllegalStateException e) { 42 assertEquals( 43 "missing behavior definition for the preceeding method call oneArgumentMethod(false)", 44 e.getMessage()); 45 assertTrue("stack trace must be cut", Util.getStackTrace(e) 46 .indexOf(RecordState.class.getName()) == -1); 47 } 48 } 49 50 public void testVerifyWithoutActivation() { 51 try { 52 control.verify(); 53 fail("IllegalStateException expected"); 54 } catch (IllegalStateException e) { 55 assertEquals("calling verify is not allowed in record state", e 56 .getMessage()); 57 } 58 } 59 } 60
| Popular Tags
|