1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.junit;
17
18 import org.apache.commons.jelly.xpath.XPathTagSupport;
19
20 /***
21 * The abstract base class of any assertion tag which is
22 * useful for implementation inheritence.
23 *
24 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
25 * @version $Revision: 155420 $
26 */
27 public abstract class AssertTagSupport extends XPathTagSupport {
28
29 public AssertTagSupport() {
30 }
31
32
33
34
35 /***
36 * Produces a failure assertion with the given message
37 */
38 protected void fail(String message) throws JellyAssertionFailedError {
39 throw new JellyAssertionFailedError(message);
40 }
41
42 /***
43 * Produces a failure assertion with the given message and added detail.
44 */
45 protected void fail(String message, String detail) throws JellyAssertionFailedError {
46 if (message == null || message.length() == 0) {
47 fail(detail);
48 }
49 else {
50 fail(message + ". Assertion failed while " + detail);
51 }
52 }
53
54 /***
55 * Produces a failure if the actual value was not equal to the expected value
56 */
57 protected void failNotEquals(String message, Object expected, Object actual, String expressions) throws JellyAssertionFailedError {
58 String formatted= "";
59 if (message != null) {
60 formatted = message +" ";
61 }
62 fail(formatted + "expected:[" + expected + "] but was:[" + actual + "]" + expressions);
63 }
64
65 }