KickJava   Java API By Example, From Geeks To Geeks.

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


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

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 JavaDoc invokeResult;
18     public ExpectationValue invokeInvocation = new ExpectationValue("invoke.invocation");
19     public Throwable JavaDoc invokeThrow;
20
21
22     public boolean matches( Invocation invocation ) {
23         matchesInvocation.setActual(invocation);
24         return matchesResult;
25     }
26
27     public Object JavaDoc invoke( Invocation invocation ) throws Throwable JavaDoc {
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 JavaDoc describeTo( StringBuffer JavaDoc buffer ) {
40         throw new AssertionFailedError("should implement describeTo");
41     }
42 }
43
Popular Tags