You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2003/03/30 18:21:19 UTC
cvs commit: jakarta-cactus/framework/src/java/share/org/apache/cactus/client/connector/http DefaultHttpClient.java
vmassol 2003/03/30 08:21:19
Modified: samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit
TestServerSideExceptions.java
framework/src/java/share/org/apache/cactus/client/connector/http
DefaultHttpClient.java
Log:
Fixed bug http://issues.apache.org/bugzilla/show_bug.cgi?id=17012 (added support for JUnit ComparisonFailure)
Revision Changes Path
1.4 +31 -1 jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit/TestServerSideExceptions.java
Index: TestServerSideExceptions.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit/TestServerSideExceptions.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestServerSideExceptions.java 17 Mar 2003 19:30:32 -0000 1.3
+++ TestServerSideExceptions.java 30 Mar 2003 16:21:19 -0000 1.4
@@ -63,6 +63,7 @@
import org.apache.cactus.client.ServletExceptionWrapper;
import junit.framework.AssertionFailedError;
+import junit.framework.ComparisonFailure;
/**
* Verifies the correct handling of exceptions that happen when running
@@ -132,6 +133,21 @@
return;
}
}
+
+ // If the test case is "testComparisonFailure" and the exception
+ // is of type ComparisonFailure and contains the text
+ // "test comparison failure", then the test is ok.
+ else if (
+ this.getCurrentTestMethod().equals("testComparisonFailure"))
+ {
+ if (e.instanceOf(AssertionFailedError.class))
+ {
+ assertEquals("test comparison failure", e.getMessage());
+
+ return;
+ }
+ }
+
}
catch (ServletExceptionWrapper e)
{
@@ -216,4 +232,18 @@
{
throw new SerializableException("test serializable exception");
}
+
+ //-------------------------------------------------------------------------
+
+ /**
+ * Verify that the new {@link ComparisonFailure} introduced in JUnit 3.8.1
+ * is correctly reported as a failure and not as an error in the Test
+ * Runner when Cactus is used.
+ */
+ public void testComparisonFailure()
+ {
+ throw new ComparisonFailure("test comparison failure", "some value",
+ "other value");
+ }
+
}
1.3 +8 -2 jakarta-cactus/framework/src/java/share/org/apache/cactus/client/connector/http/DefaultHttpClient.java
Index: DefaultHttpClient.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/connector/http/DefaultHttpClient.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultHttpClient.java 8 Mar 2003 20:38:20 -0000 1.2
+++ DefaultHttpClient.java 30 Mar 2003 16:21:19 -0000 1.3
@@ -148,8 +148,14 @@
// an AssertionFailedError exception and print it differently in
// it's runner console). Otherwise we use an instance of
// ServletExceptionWrapper.
- if (result.getExceptionClassName().equals(
+
+ // Note: We have to test the exceptions by string name as the JUnit
+ // AssertionFailedError class is unfortunately not serializable...
+
+ if ((result.getExceptionClassName().equals(
"junit.framework.AssertionFailedError"))
+ || (result.getExceptionClassName().equals(
+ "junit.framework.ComparisonFailure")))
{
throw new AssertionFailedErrorWrapper(
result.getExceptionMessage(),
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org