1 4 package test.mockobjects.dynamic; 5 6 import com.mockobjects.dynamic.*; 7 8 import junit.framework.*; 9 10 13 public class StubTest extends TestCase { 14 15 public StubTest(String name) { 16 super(name); 17 } 18 19 public void testReturnStub() throws Throwable { 20 final String result = "result"; 21 22 ReturnStub stub = new ReturnStub(result); 23 String ignoredMethodName = "methodName"; 24 Mock ignoredMock = null; 25 Object [] ignoredArgs = new Object [0]; 26 27 assertSame( "Should be the same result object", 28 result, stub.call( ignoredMock, ignoredMethodName, ignoredArgs ) ); 29 } 30 31 public void testThrowStub() { 32 final Throwable throwable = new DummyThrowable(); 33 34 ThrowStub stub = new ThrowStub(throwable); 35 String ignoredMethodName = "methodName"; 36 Mock ignoredMock = null; 37 Object [] ignoredArgs = new Object [0]; 38 39 try { 40 stub.call( ignoredMock, ignoredMethodName, ignoredArgs ); 41 } 42 catch( Throwable t ) { 43 assertSame( "Should be the same throwable", throwable, t ); 44 } 45 } 46 } 47 | Popular Tags |