Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19885/input/javasrc/biz/xsoftware/mock2
Added Files:
ExpectFailedException.java
Log Message:
add test that should fail and passes
--- NEW FILE: ExpectFailedException.java ---
/*
* Created on Apr 24, 2004
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package biz.xsoftware.mock2;
/**
* This Exception is thrown when something is expected to happen
* and doesn't. It is basically the assert failing. When
* MockSuperclass.expectEvent is called and the event doesn't come,
* this exception is thrown.
*
* @author Dean Hiller
*/
public class ExpectFailedException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Expect failed because an event never came and waiting finally timed out.
*/
public static final String TIMED_OUT = "timed out waiting for method";
/**
* Expect failed because a method you did not list in expected methods was called after
* all your expected methods were called.
*/
public static final String UNEXPECTED_CALL_AFTER =
"Another method that was not expected nor ignored was called after all the expected method calls";
/**
* Expect failed because a method you did not list in expected methods was called
* before or during the other methods you did expect.
*/
public static final String UNEXPECTED_CALL_BEFORE =
"Another method that was not expected nor ignored was called before all the expected method calls were called";
/**
* Expect failed because you expected no methods to be called, but a method was called.
*/
public static final String UNEXPECTED_ON_NONE = "Another method was called when no methods should have been called";
private String reason;
private CalledMethod[] methods;
/**
* Constructor for Expects that fail with a reason and message.
*
* @param message
*/
public ExpectFailedException(String message, CalledMethod[] methods, String reason) {
super(message);
this.reason = reason;
this.methods = methods;
}
/**
* Gets the reason expecting the call(s) failed.
*
* Returns either
* <ol>
* <li>{@link #TIMED_OUT}</li>
* <li>{@link #UNEXPECTED_CALL_AFTER}</li>
* <li>{@link #UNEXPECTED_CALL_BEFORE}</li>
* <li>{@link #UNEXPECTED_ON_NONE}</li>
* </ol>
* @return The reason for the failure. One of
*/
public String getReason() {
return reason;
}
/**
* Gives you back the CalledMethods giving you access to the
* parameters that were passed in and the stack traces of how
* they were called.
*
* @return
*/
public CalledMethod[] getCalledMethods() {
return methods;
}
}
|