1 3 package test.jmock.core.testsupport; 4 5 import java.lang.reflect.Method ; 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 getMockedTypeResult; 21 22 public Class 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 proxyResult; 43 44 public Object 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 invoke( Object arg0, Method arg1, Object [] arg2 ) 55 throws Throwable { 56 return null; 57 } 58 59 public String toStringResult; 60 61 public String toString() { 62 return toStringResult; 63 } 64 } 65 | Popular Tags |