KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > mockobjects > dynamic > StubTest


1 /*
2  * Created on 07-Apr-2003
3  */

4 package test.mockobjects.dynamic;
5
6 import com.mockobjects.dynamic.*;
7
8 import junit.framework.*;
9
10 /**
11  * @author dev
12  */

13 public class StubTest extends TestCase {
14
15     public StubTest(String JavaDoc name) {
16         super(name);
17     }
18     
19     public void testReturnStub() throws Throwable JavaDoc {
20         final String JavaDoc result = "result";
21         
22         ReturnStub stub = new ReturnStub(result);
23         String JavaDoc ignoredMethodName = "methodName";
24         Mock ignoredMock = null;
25         Object JavaDoc[] ignoredArgs = new Object JavaDoc[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 JavaDoc throwable = new DummyThrowable();
33         
34         ThrowStub stub = new ThrowStub(throwable);
35         String JavaDoc ignoredMethodName = "methodName";
36         Mock ignoredMock = null;
37         Object JavaDoc[] ignoredArgs = new Object JavaDoc[0];
38         
39         try {
40             stub.call( ignoredMock, ignoredMethodName, ignoredArgs );
41         }
42         catch( Throwable JavaDoc t ) {
43             assertSame( "Should be the same throwable", throwable, t );
44         }
45     }
46 }
47
Popular Tags