KickJava   Java API By Example, From Geeks To Geeks.

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


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

3 package test.jmock.core.testsupport;
4
5 import org.jmock.core.Invocation;
6 import org.jmock.core.Stub;
7 import org.jmock.core.Verifiable;
8 import org.jmock.expectation.ExpectationValue;
9 import org.jmock.util.Verifier;
10
11
12 public class MockStub
13         implements Stub, Verifiable
14 {
15     private String JavaDoc name;
16
17     public MockStub() {
18         this("mockStub");
19     }
20
21     public MockStub( String JavaDoc name ) {
22         this.name = name;
23     }
24
25     public String JavaDoc toString() {
26         return name;
27     }
28
29     public ExpectationValue invokeInvocation =
30             new ExpectationValue("invoke invocation");
31     public Object JavaDoc invokeResult;
32
33     public Object JavaDoc invoke( Invocation invocation ) throws Throwable JavaDoc {
34         invokeInvocation.setActual(invocation);
35         return invokeResult;
36     }
37
38
39     public ExpectationValue describeToBuffer = new ExpectationValue("describeTo buffer");
40     public String JavaDoc describeToOutput = "";
41
42     public StringBuffer JavaDoc describeTo( StringBuffer JavaDoc buffer ) {
43         describeToBuffer.setActual(buffer);
44         buffer.append(describeToOutput);
45         return buffer;
46     }
47
48     public void verify() {
49         Verifier.verifyObject(this);
50     }
51 }
52
Popular Tags