Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-08-13 01:50:45 -0400
committerEike Stepper2013-08-13 01:50:45 -0400
commitf298aab9b6d2fc43cbe47171eee9aa862fc3944b (patch)
treebd945947621156df4dfaf17b22fe02cd509dd644 /plugins/org.eclipse.net4j.tests/src/org
parent23cd938d3736f9a888bc013698c3c9fcb85d5dcf (diff)
downloadcdo-f298aab9b6d2fc43cbe47171eee9aa862fc3944b.tar.gz
cdo-f298aab9b6d2fc43cbe47171eee9aa862fc3944b.tar.xz
cdo-f298aab9b6d2fc43cbe47171eee9aa862fc3944b.zip
Convert AssertionError to AssertionFailedError
Diffstat (limited to 'plugins/org.eclipse.net4j.tests/src/org')
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java33
1 files changed, 32 insertions, 1 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
index 89ba6d4345..4d49282ff0 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
@@ -31,6 +31,8 @@ import org.eclipse.net4j.util.om.log.PrintLogHandler;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+import org.junit.Assert;
+
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -45,7 +47,6 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
-import org.junit.Assert;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import junit.framework.TestResult;
@@ -298,6 +299,12 @@ public abstract class AbstractOMTest extends TestCase
}
catch (Throwable t)
{
+ AssertionFailedError assertionFailedError = getAssertionFailedError(t);
+ if (assertionFailedError != null)
+ {
+ t = assertionFailedError;
+ }
+
if (!SUPPRESS_OUTPUT)
{
t.printStackTrace(IOUtil.OUT());
@@ -331,6 +338,12 @@ public abstract class AbstractOMTest extends TestCase
}
catch (Error err)
{
+ AssertionFailedError assertionFailedError = getAssertionFailedError(err);
+ if (assertionFailedError != null)
+ {
+ err = assertionFailedError;
+ }
+
if (!SUPPRESS_OUTPUT)
{
err.printStackTrace(IOUtil.OUT());
@@ -340,6 +353,24 @@ public abstract class AbstractOMTest extends TestCase
}
}
+ private AssertionFailedError getAssertionFailedError(Throwable err)
+ {
+ if (err.getClass() == AssertionError.class)
+ {
+ // JUnit4 seems to throw java.lang.AssertionError, which the JUNit view displays as error rather than failure
+ AssertionFailedError replacementError = new AssertionFailedError(err.getMessage());
+ replacementError.initCause(err.getCause());
+ return replacementError;
+ }
+
+ if (err instanceof AssertionFailedError)
+ {
+ return (AssertionFailedError)err;
+ }
+
+ return null;
+ }
+
protected void enableConsole()
{
if (!SUPPRESS_OUTPUT)

Back to the top