You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2005/11/21 13:39:09 UTC
svn commit: r345896 -
/jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertTagSupport.java
Author: dion
Date: Mon Nov 21 04:38:59 2005
New Revision: 345896
URL: http://svn.apache.org/viewcvs?rev=345896&view=rev
Log:
Add assertFalse/True methods
Modified:
jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertTagSupport.java
Modified: jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertTagSupport.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertTagSupport.java?rev=345896&r1=345895&r2=345896&view=diff
==============================================================================
--- jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertTagSupport.java (original)
+++ jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertTagSupport.java Mon Nov 21 04:38:59 2005
@@ -26,6 +26,9 @@
*/
public abstract class AssertTagSupport extends XPathTagSupport {
+ /** the default message to display if none is given */
+ private static String DEFAULT_MESSAGE = "assertion failed";
+
public AssertTagSupport() {
}
@@ -34,13 +37,23 @@
/**
* Produces a failure assertion with the given message
+ * @throws JellyAssertionFailedError to signify failure
*/
protected void fail(String message) throws JellyAssertionFailedError {
throw new JellyAssertionFailedError(message);
}
/**
+ * Produces a failure assertion with a default message
+ * @throws JellyAssertionFailedError to signify failure
+ */
+ protected void fail() throws JellyAssertionFailedError {
+ throw new JellyAssertionFailedError(DEFAULT_MESSAGE);
+ }
+
+ /**
* Produces a failure assertion with the given message and added detail.
+ * @throws JellyAssertionFailedError to signify failure
*/
protected void fail(String message, String detail) throws JellyAssertionFailedError {
if (message == null || message.length() == 0) {
@@ -53,6 +66,7 @@
/**
* Produces a failure if the actual value was not equal to the expected value
+ * @throws JellyAssertionFailedError if expected != actual.
*/
protected void failNotEquals(String message, Object expected, Object actual, String expressions) throws JellyAssertionFailedError {
String formatted= "";
@@ -61,5 +75,46 @@
}
fail(formatted + "expected:[" + expected + "] but was:[" + actual + "]" + expressions);
}
+
+ /**
+ * Fail if actual is not true
+ * @param message failure message
+ * @param actual value to test
+ * @throws JellyAssertionFailedError to signify failure
+ */
+ protected void assertTrue(String message, boolean actual) throws JellyAssertionFailedError
+ {
+ if (!actual) fail(message);
+ }
+
+ /**
+ * Fail if actual is not true
+ * @param actual value to test
+ * @throws JellyAssertionFailedError to signify failure
+ */
+ protected void assertTrue(boolean actual) throws JellyAssertionFailedError
+ {
+ assertTrue(DEFAULT_MESSAGE, actual);
+ }
+ /**
+ * Fail if actual is true
+ * @param message failure message
+ * @param actual value to test
+ * @throws JellyAssertionFailedError to signify failure
+ */
+ protected void assertFalse(String message, boolean actual) throws JellyAssertionFailedError
+ {
+ if (actual) fail(message);
+ }
+
+ /**
+ * Fail if actual is true
+ * @param actual value to test
+ * @throws JellyAssertionFailedError to signify failure
+ */
+ protected void assertFalse(boolean actual) throws JellyAssertionFailedError
+ {
+ assertFalse(DEFAULT_MESSAGE, actual);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org