KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > jmock > core > testsupport > MockDynamicMock


1 /* Copyright (c) 2000-2004 jMock.org
2  */

3 package test.jmock.core.testsupport;
4
5 import java.lang.reflect.Method JavaDoc;
6 import org.jmock.core.DynamicMock;
7 import org.jmock.core.Invokable;
8 import org.jmock.core.Stub;
9 import org.jmock.expectation.AssertMo;
10 import org.jmock.expectation.ExpectationCounter;
11 import org.jmock.expectation.ExpectationValue;
12
13
14 public class MockDynamicMock
15         extends MockVerifiable
16         implements DynamicMock
17 {
18     public ExpectationCounter getMockedTypeCalls =
19             new ExpectationCounter("getMockedTypes #calls");
20     public Class JavaDoc getMockedTypeResult;
21
22     public Class JavaDoc getMockedType() {
23         getMockedTypeCalls.inc();
24         return getMockedTypeResult;
25     }
26
27     public ExpectationCounter addInvokableCalls = new ExpectationCounter("addInvokable #calls");
28     public ExpectationValue addInvokable = new ExpectationValue("addInvokable invokable");
29
30     public void addInvokable( Invokable invokable ) {
31         AssertMo.assertNotNull("invokable", invokable);
32         addInvokable.setActual(invokable);
33         addInvokableCalls.inc();
34     }
35
36     public ExpectationValue setDefaultStub = new ExpectationValue("setDefaultStub");
37
38     public void setDefaultStub( Stub newDefaultStub ) {
39         setDefaultStub.setActual(newDefaultStub);
40     }
41
42     public Object JavaDoc proxyResult;
43
44     public Object JavaDoc proxy() {
45         return proxyResult;
46     }
47
48     public ExpectationCounter resetCalls = new ExpectationCounter("reset #calls");
49
50     public void reset() {
51         resetCalls.inc();
52     }
53
54     public Object JavaDoc invoke( Object JavaDoc arg0, Method JavaDoc arg1, Object JavaDoc[] arg2 )
55             throws Throwable JavaDoc {
56         return null;
57     }
58
59     public String JavaDoc toStringResult;
60
61     public String JavaDoc toString() {
62         return toStringResult;
63     }
64 }
65
Popular Tags