KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > core > stub > TestFailureStub


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

3 package org.jmock.core.stub;
4
5 import junit.framework.AssertionFailedError;
6 import org.jmock.core.Invocation;
7 import org.jmock.core.Stub;
8
9
10 public class TestFailureStub implements Stub
11 {
12     String JavaDoc errorMessage;
13
14     public TestFailureStub( String JavaDoc errorMessage ) {
15         this.errorMessage = errorMessage;
16     }
17
18     public Object JavaDoc invoke( Invocation invocation ) throws Throwable JavaDoc {
19         throw new AssertionFailedError(errorMessage);
20     }
21
22     public StringBuffer JavaDoc describeTo( StringBuffer JavaDoc buffer ) {
23         return buffer.append("fails the test and reports \"" + errorMessage + "\"");
24     }
25 }
26
Popular Tags