You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mo...@apache.org on 2003/01/25 00:23:48 UTC
cvs commit: jakarta-commons-sandbox/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit AssertEqualsTag.java AssertTag.java AssertThrowsTag.java
morgand 2003/01/24 15:23:47
Modified: jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit
AssertEqualsTag.java AssertTag.java
AssertThrowsTag.java
Log:
converting junit tags from Exceptions to JellyTagExceptions
Revision Changes Path
1.2 +7 -6 jakarta-commons-sandbox/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertEqualsTag.java
Index: AssertEqualsTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertEqualsTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AssertEqualsTag.java 19 Jan 2003 06:17:10 -0000 1.1
+++ AssertEqualsTag.java 24 Jan 2003 23:23:47 -0000 1.2
@@ -61,6 +61,7 @@
*/
package org.apache.commons.jelly.tags.junit;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.expression.Expression;
@@ -79,7 +80,7 @@
// Tag interface
//-------------------------------------------------------------------------
- public void doTag(XMLOutput output) throws Exception {
+ public void doTag(XMLOutput output) throws JellyTagException {
String message = getBodyText();
Object expectedValue = expected.evaluate(context);
1.2 +16 -10 jakarta-commons-sandbox/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertTag.java
Index: AssertTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AssertTag.java 19 Jan 2003 06:17:10 -0000 1.1
+++ AssertTag.java 24 Jan 2003 23:23:47 -0000 1.2
@@ -61,14 +61,15 @@
*/
package org.apache.commons.jelly.tags.junit;
-import org.apache.commons.jelly.XMLOutput;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.MissingAttributeException;
+import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.expression.Expression;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
+import org.jaxen.JaxenException;
import org.jaxen.XPath;
/**
@@ -94,7 +95,7 @@
// Tag interface
//-------------------------------------------------------------------------
- public void doTag(XMLOutput output) throws Exception {
+ public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
if (test == null && xpath == null) {
throw new MissingAttributeException( "test" );
}
@@ -105,8 +106,13 @@
}
else {
Object xpathContext = getXPathContext();
- if (! xpath.booleanValueOf(xpathContext)) {
- fail( getBodyText(), "evaluating xpath: "+ xpath );
+ try {
+ if (! xpath.booleanValueOf(xpathContext)) {
+ fail( getBodyText(), "evaluating xpath: "+ xpath );
+ }
+ }
+ catch (JaxenException e) {
+ throw new JellyTagException(e);
}
}
1.2 +21 -13 jakarta-commons-sandbox/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertThrowsTag.java
Index: AssertThrowsTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertThrowsTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AssertThrowsTag.java 19 Jan 2003 06:17:10 -0000 1.1
+++ AssertThrowsTag.java 24 Jan 2003 23:23:47 -0000 1.2
@@ -56,6 +56,7 @@
package org.apache.commons.jelly.tags.junit;
import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -86,17 +87,23 @@
private String expected;
/**
- * Sets the ClassLoader to be used when loading an exception class
*/
+ * Sets the ClassLoader to be used when loading an exception class
+ */
private ClassLoader classLoader;
- // Tag interface
- //-------------------------------------------------------------------------
- public void doTag(XMLOutput output) throws Exception {
- Class throwableClass = getThrowableClass();
-
- try {
- invokeBody(output);
- }
+ // Tag interface
+ //-------------------------------------------------------------------------
+ public void doTag(XMLOutput output) throws JellyTagException {
+ Class throwableClass = null;
+ try {
+ throwableClass = getThrowableClass();
+ } catch (ClassNotFoundException e) {
+ throw new JellyTagException(e);
+ }
+
+ try {
+ invokeBody(output);
+ }
catch (Throwable t) {
if (t instanceof JellyException) {
// unwrap Jelly exceptions which wrap other exceptions
@@ -110,10 +117,10 @@
}
if (throwableClass != null && !throwableClass.isAssignableFrom(t.getClass())) {
fail("Unexpected exception: " + t);
- }
+ }
else {
- return;
- }
+ return;
+ }
}
fail("No exception was thrown.");
}
@@ -138,7 +145,8 @@
}
/**
- * Sets the class loader to be used to load the exception type
*/
+ * Sets the class loader to be used to load the exception type
+ */
public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>