dion 2004/09/07 21:50:39
Modified: jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit
AssertThrowsTag.java JellyAssertionFailedError.java
JUnitTagLibrary.java
Log:
detab
Revision Changes Path
1.5 +74 -74
jakarta-commons/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertThrowsTag.java
Index: AssertThrowsTag.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertThrowsTag.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AssertThrowsTag.java 25 Feb 2004 01:31:53 -0000 1.4
+++ AssertThrowsTag.java 8 Sep 2004 04:50:39 -0000 1.5
@@ -1,12 +1,12 @@
/*
* Copyright 2002,2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,25 +32,25 @@
*/
public class AssertThrowsTag extends AssertTagSupport {
- /** The Log to which logging calls will be made. */
- private static final Log log = LogFactory.getLog(AssertThrowsTag.class);
+ /** The Log to which logging calls will be made. */
+ private static final Log log = LogFactory.getLog(AssertThrowsTag.class);
- /**
- * The variable name to export the caught exception to.
- */
- private String var;
-
- /**
- * The class name (fully qualified) of the exception expected to be thrown
- * by the body. Also a superclass of the expected exception can be given.
- */
- private String expected;
+ /**
+ * The variable name to export the caught exception to.
+ */
+ private String var;
+
+ /**
+ * The class name (fully qualified) of the exception expected to be thrown
+ * by the body. Also a superclass of the expected exception can be given.
+ */
+ private String expected;
/**
* Sets the ClassLoader to be used when loading an exception class
*/
private ClassLoader classLoader;
-
+
// Tag interface
//-------------------------------------------------------------------------
public void doTag(XMLOutput output) throws JellyTagException {
@@ -63,7 +63,7 @@
try {
invokeBody(output);
- }
+ }
catch (Throwable t) {
if (t instanceof JellyException) {
// unwrap Jelly exceptions which wrap other exceptions
@@ -72,37 +72,37 @@
t = je.getCause();
}
}
- if (var != null) {
- context.setVariable(var, t);
- }
- if (throwableClass != null &&
!throwableClass.isAssignableFrom(t.getClass())) {
- fail("Unexpected exception: " + t);
- }
+ if (var != null) {
+ context.setVariable(var, t);
+ }
+ if (throwableClass != null &&
!throwableClass.isAssignableFrom(t.getClass())) {
+ fail("Unexpected exception: " + t);
+ }
else {
return;
}
- }
- fail("No exception was thrown.");
- }
-
- // Properties
- //-------------------------------------------------------------------------
- /**
- * Sets the class name of exception expected to be thrown by the body. The
- * class name must be fully qualified and can either be the expected
- * exception class itself or any supertype of it, but must be a subtype of
- * <code>java.lang.Throwable</code>.
- */
- public void setExpected(String expected) {
- this.expected = expected;
- }
-
- /**
- * Sets the variable name to define for this expression.
- */
- public void setVar(String var) {
- this.var = var;
- }
+ }
+ fail("No exception was thrown.");
+ }
+
+ // Properties
+ //-------------------------------------------------------------------------
+ /**
+ * Sets the class name of exception expected to be thrown by the body. The
+ * class name must be fully qualified and can either be the expected
+ * exception class itself or any supertype of it, but must be a subtype of
+ * <code>java.lang.Throwable</code>.
+ */
+ public void setExpected(String expected) {
+ this.expected = expected;
+ }
+
+ /**
+ * Sets the variable name to define for this expression.
+ */
+ public void setVar(String var) {
+ this.var = var;
+ }
/**
* Sets the class loader to be used to load the exception type
@@ -110,35 +110,35 @@
public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
-
+
public ClassLoader getClassLoader() {
if (classLoader == null) {
return getClass().getClassLoader();
}
return classLoader;
}
-
- // Implementation methods
- //-------------------------------------------------------------------------
-
- /**
- * Returns the <code>Class</code> corresponding to the class
- * specified by <code>expected</code>. If
- * <code>expected</code> was either not specified then <code>java. lang.
- * Throwable</code> is returned.
+
+ // Implementation methods
+ //-------------------------------------------------------------------------
+
+ /**
+ * Returns the <code>Class</code> corresponding to the class
+ * specified by <code>expected</code>. If
+ * <code>expected</code> was either not specified then <code>java. lang.
+ * Throwable</code> is returned.
* Otherwise if the class couldn't be
- * found or doesn't denote an exception class then an exception is thrown.
- *
- * @return Class The class of the exception to expect
- */
- protected Class getThrowableClass() throws ClassNotFoundException {
- if (expected == null) {
- return Throwable.class;
- }
-
- Class throwableClass = null;
- try {
- throwableClass = getClassLoader().loadClass(expected);
+ * found or doesn't denote an exception class then an exception is thrown.
+ *
+ * @return Class The class of the exception to expect
+ */
+ protected Class getThrowableClass() throws ClassNotFoundException {
+ if (expected == null) {
+ return Throwable.class;
+ }
+
+ Class throwableClass = null;
+ try {
+ throwableClass = getClassLoader().loadClass(expected);
}
catch (ClassNotFoundException e) {
try {
@@ -149,11 +149,11 @@
throw e;
}
}
-
- if (!Throwable.class.isAssignableFrom(throwableClass)) {
- log.warn( "The class: " + expected + " is not an Exception
class.");
- return null;
- }
- return throwableClass;
- }
+
+ if (!Throwable.class.isAssignableFrom(throwableClass)) {
+ log.warn( "The class: " + expected + " is not an Exception class.");
+ return null;
+ }
+ return throwableClass;
+ }
}
1.5 +40 -40
jakarta-commons/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JellyAssertionFailedError.java
Index: JellyAssertionFailedError.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JellyAssertionFailedError.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JellyAssertionFailedError.java 25 Feb 2004 01:31:53 -0000 1.4
+++ JellyAssertionFailedError.java 8 Sep 2004 04:50:39 -0000 1.5
@@ -1,12 +1,12 @@
/*
* Copyright 2002,2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,8 +23,8 @@
import org.apache.commons.jelly.LocationAware;
-/**
- * <p><code>JellyAssertionFailedError</code> is
+/**
+ * <p><code>JellyAssertionFailedError</code> is
* a JUnit AssertionFailedError which is LocationAware so that it can include
* details of where in the JellyUnit test case that the failure occurred.</p>
*
@@ -33,7 +33,7 @@
*/
public class JellyAssertionFailedError extends AssertionFailedError implements
LocationAware {
-
+
/** the underlying cause of the exception */
private Throwable cause;
@@ -45,10 +45,10 @@
/** the line number in the script of the error */
private int lineNumber = -1;
-
+
/** the column number in the script of the error */
private int columnNumber = -1;
-
+
public JellyAssertionFailedError() {
}
@@ -60,75 +60,75 @@
super(message);
this.cause = cause;
}
-
+
public JellyAssertionFailedError(Throwable cause) {
super(cause.getLocalizedMessage());
this.cause = cause;
}
-
+
public Throwable getCause() {
return cause;
}
-
- /**
- * @return the line number of the tag
+
+ /**
+ * @return the line number of the tag
*/
public int getLineNumber() {
return lineNumber;
}
-
- /**
- * Sets the line number of the tag
+
+ /**
+ * Sets the line number of the tag
*/
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
}
- /**
- * @return the column number of the tag
+ /**
+ * @return the column number of the tag
*/
public int getColumnNumber() {
return columnNumber;
}
-
- /**
- * Sets the column number of the tag
+
+ /**
+ * Sets the column number of the tag
*/
public void setColumnNumber(int columnNumber) {
this.columnNumber = columnNumber;
}
- /**
- * @return the Jelly file which caused the problem
+ /**
+ * @return the Jelly file which caused the problem
*/
public String getFileName() {
return fileName;
}
- /**
- * Sets the Jelly file which caused the problem
+ /**
+ * Sets the Jelly file which caused the problem
*/
public void setFileName(String fileName) {
this.fileName = fileName;
}
-
- /**
+
+ /**
* @return the element name which caused the problem
*/
public String getElementName() {
return elementName;
}
- /**
+ /**
* Sets the element name which caused the problem
*/
public void setElementName(String elementName) {
this.elementName = elementName;
}
-
-
+
+
public String getMessage() {
return fileName + ":" + lineNumber + ":" + columnNumber + ": <" +
elementName + "> " + super.getMessage();
}
@@ -138,7 +138,7 @@
}
// #### overload the printStackTrace methods...
- public void printStackTrace(PrintWriter s) {
+ public void printStackTrace(PrintWriter s) {
synchronized (s) {
super.printStackTrace(s);
if (cause != null) {
@@ -147,7 +147,7 @@
}
}
}
-
+
public void printStackTrace(PrintStream s) {
synchronized (s) {
super.printStackTrace(s);
@@ -158,11 +158,11 @@
}
}
- public void printStackTrace() {
- super.printStackTrace();
- if (cause != null) {
- System.out.println("Root cause");
- cause.printStackTrace();
- }
- }
+ public void printStackTrace() {
+ super.printStackTrace();
+ if (cause != null) {
+ System.out.println("Root cause");
+ cause.printStackTrace();
+ }
+ }
}
1.5 +11 -11
jakarta-commons/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java
Index: JUnitTagLibrary.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JUnitTagLibrary.java 25 Feb 2004 01:31:53 -0000 1.4
+++ JUnitTagLibrary.java 8 Sep 2004 04:50:39 -0000 1.5
@@ -1,12 +1,12 @@
/*
* Copyright 2002,2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,11 +38,11 @@
/** The Log to which logging calls will be made. */
private Log log = LogFactory.getLog(JUnitTagLibrary.class);
-
+
public JUnitTagLibrary() {
registerTag("assert", AssertTag.class);
registerTag("assertEquals", AssertEqualsTag.class);
- registerTag("assertThrows", AssertThrowsTag.class);
+ registerTag("assertThrows", AssertThrowsTag.class);
registerTag("fail", FailTag.class);
registerTag("run", RunTag.class );
registerTag("case", CaseTag.class );
@@ -56,21 +56,21 @@
String attributeValue) throws JellyException {
// #### may need to include some namespace URI information in the XPath
instance?
-
- if (attributeName.equals("xpath")) {
+
+ if (attributeName.equals("xpath")) {
if ( log.isDebugEnabled() ) {
log.debug( "Parsing XPath expression: " + attributeValue );
}
-
+
// XPath xpath = new Dom4jXPath(attributeValue);
Expression xpathExpr = super.createExpression( factory,
tagScript,
attributeName,
attributeValue );
- return new XPathExpression(attributeValue, xpathExpr, tagScript);
+ return new XPathExpression(attributeValue, xpathExpr, tagScript);
}
-
+
// will use the default expression instead
return super.createExpression(factory, tagScript, attributeName,
attributeValue);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]