KickJava   Java API By Example, From Geeks To Geeks.

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


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

3 package org.jmock.core.matcher;
4
5 import junit.framework.AssertionFailedError;
6 import org.jmock.core.Invocation;
7 import org.jmock.core.InvocationMatcher;
8
9
10 public class TestFailureMatcher
11         implements InvocationMatcher
12 {
13     private String JavaDoc errorMessage;
14
15     public TestFailureMatcher( String JavaDoc errorMessage ) {
16         this.errorMessage = errorMessage;
17     }
18
19     public boolean matches( Invocation invocation ) {
20         return true;
21     }
22
23     public boolean hasDescription() {
24         return true;
25     }
26
27     public StringBuffer JavaDoc describeTo( StringBuffer JavaDoc buffer ) {
28         return buffer.append(errorMessage);
29     }
30
31     public void invoked( Invocation invocation ) {
32         throw new AssertionFailedError(errorMessage);
33     }
34
35     public void verify() {
36         // Always verify
37
}
38 }
39
Popular Tags