01: package org.uispec4j.assertion;
02:
03: import junit.framework.AssertionFailedError;
04:
05: public class DummyAssertion extends Assertion {
06: public static final Assertion TRUE = new DummyAssertion(true);
07: public static final Assertion FALSE = new DummyAssertion(false);
08: public static final String DEFAULT_ERROR_MSG = "custom error";
09:
10: private Error error = null;
11: private Exception exception = null;
12:
13: public DummyAssertion() {
14: }
15:
16: public DummyAssertion(boolean success) {
17: if (!success) {
18: setError(DEFAULT_ERROR_MSG);
19: }
20: }
21:
22: public DummyAssertion(String errorMessage) {
23: setError(errorMessage);
24: }
25:
26: public void setError(String errorMessage) {
27: this .error = new AssertionFailedError(errorMessage);
28: }
29:
30: public void setException(Exception exception) {
31: this .exception = exception;
32: }
33:
34: public void check() throws Exception {
35: if (error != null) {
36: throw error;
37: }
38: if (exception != null) {
39: throw exception;
40: }
41: }
42: }
|