KickJava   Java API By Example, From Geeks To Geeks.

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


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.InvocationMatcher;
7 import org.jmock.expectation.ExpectationValue;
8
9
10 public class MockInvocationMatcher
11         extends MockVerifiable
12         implements InvocationMatcher
13 {
14     private String JavaDoc name;
15
16     public MockInvocationMatcher( String JavaDoc name ) {
17         this.name = name;
18     }
19
20     public MockInvocationMatcher() {
21         this("mockInvocationMatcher");
22     }
23
24     public String JavaDoc toString() {
25         return name;
26     }
27
28
29     public ExpectationValue matchesInvocation = new ExpectationValue("matches invocation");
30     public boolean matchesResult = false;
31
32     public boolean matches( Invocation invocation ) {
33         matchesInvocation.setActual(invocation);
34         return matchesResult;
35     }
36
37     public ExpectationValue invokedInvocation = new ExpectationValue("invoked invocation");
38
39     public void invoked( Invocation invocation ) {
40         invokedInvocation.setActual(invocation);
41     }
42
43     public ExpectationValue describeToBuffer = new ExpectationValue("describeTo buffer");
44     public String JavaDoc describeToOutput = "";
45
46     public boolean hasDescription() {
47         return describeToOutput.length() > 0;
48     }
49
50     public StringBuffer JavaDoc describeTo( StringBuffer JavaDoc buffer ) {
51         describeToBuffer.setActual(buffer);
52         buffer.append(describeToOutput);
53         return buffer;
54     }
55 }
56
Popular Tags