1 3 package test.jmock.core.testsupport; 4 5 import junit.framework.AssertionFailedError; 6 import org.jmock.core.Invocation; 7 import org.jmock.core.Invokable; 8 import org.jmock.expectation.ExpectationValue; 9 10 11 public class MockInvokable extends MockVerifiable implements Invokable 12 { 13 14 public boolean matchesResult; 15 public ExpectationValue matchesInvocation = new ExpectationValue("matches.invocation"); 16 17 public Object invokeResult; 18 public ExpectationValue invokeInvocation = new ExpectationValue("invoke.invocation"); 19 public Throwable invokeThrow; 20 21 22 public boolean matches( Invocation invocation ) { 23 matchesInvocation.setActual(invocation); 24 return matchesResult; 25 } 26 27 public Object invoke( Invocation invocation ) throws Throwable { 28 invokeInvocation.setActual(invocation); 29 if (invokeThrow != null) { 30 throw invokeThrow; 31 } 32 return invokeResult; 33 } 34 35 public boolean hasDescription() { 36 return true; 37 } 38 39 public StringBuffer describeTo( StringBuffer buffer ) { 40 throw new AssertionFailedError("should implement describeTo"); 41 } 42 } 43 | Popular Tags |