KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > core > matcher > InvokedRecorder


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

3 package org.jmock.core.matcher;
4
5 import junit.framework.Assert;
6 import org.jmock.core.Invocation;
7 import org.jmock.core.InvocationMatcher;
8
9
10 public class InvokedRecorder
11         implements InvocationMatcher
12 {
13     private boolean hasBeenInvoked = false;
14
15     public boolean hasBeenInvoked() {
16         return hasBeenInvoked;
17     }
18
19     public boolean matches( Invocation invocation ) {
20         return true;
21     }
22
23     public void invoked( Invocation invocation ) {
24         hasBeenInvoked = true;
25     }
26
27     public boolean hasDescription() {
28         return false;
29     }
30
31     public StringBuffer JavaDoc describeTo( StringBuffer JavaDoc buffer ) {
32         return buffer;
33     }
34
35     public void verify() {
36         // always verifies
37
}
38
39     public void verifyHasBeenInvoked() {
40         Assert.assertTrue("expected method was not invoked", hasBeenInvoked);
41     }
42 }
43
Popular Tags