aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2015-11-26 17:04:44 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2015-11-26 17:04:44 +0000
commit7525cefbad4cc2d1712d0875e2825e8b67cd6aaf (patch)
treeed2578eb17ccebc46cddbaaa6f5d56ca030d0473
parentebe63dcaf2b25e1da7101ff1a8af046605af1c50 (diff)
downloadxmlgraphics-fop-7525cefbad4cc2d1712d0875e2825e8b67cd6aaf.tar.gz
xmlgraphics-fop-7525cefbad4cc2d1712d0875e2825e8b67cd6aaf.zip
Tweak - Make sure that proper distinction is made between real RuntimeException (i.e. reported as errors) and AssertionException (i.e. reported as failure)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1716744 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--test/java/org/apache/fop/layoutengine/ElementListCheck.java43
-rw-r--r--test/java/org/apache/fop/layoutengine/EvalCheck.java4
-rw-r--r--test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java2
-rw-r--r--test/java/org/apache/fop/layoutengine/ResultCheck.java2
-rw-r--r--test/java/org/apache/fop/layoutengine/TrueCheck.java4
5 files changed, 29 insertions, 26 deletions
diff --git a/test/java/org/apache/fop/layoutengine/ElementListCheck.java b/test/java/org/apache/fop/layoutengine/ElementListCheck.java
index 4d33d670b..e51528552 100644
--- a/test/java/org/apache/fop/layoutengine/ElementListCheck.java
+++ b/test/java/org/apache/fop/layoutengine/ElementListCheck.java
@@ -28,8 +28,8 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.KnuthBox;
-import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.KnuthPenalty;
@@ -73,7 +73,7 @@ public class ElementListCheck implements LayoutEngineCheck {
if (node instanceof Element) {
pos++;
Element domEl = (Element)node;
- KnuthElement knuthEl = (KnuthElement)elementList.getElementList().get(pos);
+ ListElement knuthEl = (ListElement) elementList.getElementList().get(pos);
if ("skip".equals(domEl.getLocalName())) {
pos += Integer.parseInt(getElementText(domEl)) - 1;
} else if ("box".equals(domEl.getLocalName())) {
@@ -82,22 +82,23 @@ public class ElementListCheck implements LayoutEngineCheck {
+ " at position " + pos
+ " but got: " + knuthEl.getClass().getName());
}
+ KnuthBox box = (KnuthBox) knuthEl;
if (domEl.getAttribute("w").length() > 0) {
int w = Integer.parseInt(domEl.getAttribute("w"));
- if (w != knuthEl.getWidth()) {
+ if (w != box.getWidth()) {
fail("Expected w=" + w
+ " at position " + pos
- + " but got: " + knuthEl.getWidth());
+ + " but got: " + box.getWidth());
}
}
if ("true".equals(domEl.getAttribute("aux"))) {
- if (!knuthEl.isAuxiliary()) {
+ if (!box.isAuxiliary()) {
fail("Expected auxiliary box"
+ " at position " + pos);
}
}
if ("false".equals(domEl.getAttribute("aux"))) {
- if (knuthEl.isAuxiliary()) {
+ if (box.isAuxiliary()) {
fail("Expected a normal, not an auxiliary box"
+ " at position " + pos);
}
@@ -111,24 +112,24 @@ public class ElementListCheck implements LayoutEngineCheck {
KnuthPenalty pen = (KnuthPenalty)knuthEl;
if (domEl.getAttribute("w").length() > 0) {
int w = Integer.parseInt(domEl.getAttribute("w"));
- if (w != knuthEl.getWidth()) {
+ if (w != pen.getWidth()) {
fail("Expected w=" + w
+ " at position " + pos
- + " but got: " + knuthEl.getWidth());
+ + " but got: " + pen.getWidth());
}
}
if (domEl.getAttribute("p").length() > 0) {
if ("<0".equals(domEl.getAttribute("p"))) {
- if (knuthEl.getPenalty() >= 0) {
+ if (pen.getPenalty() >= 0) {
fail("Expected p<0"
+ " at position " + pos
- + " but got: " + knuthEl.getPenalty());
+ + " but got: " + pen.getPenalty());
}
} else if (">0".equals(domEl.getAttribute("p"))) {
- if (knuthEl.getPenalty() <= 0) {
+ if (pen.getPenalty() <= 0) {
fail("Expected p>0"
+ " at position " + pos
- + " but got: " + knuthEl.getPenalty());
+ + " but got: " + pen.getPenalty());
}
} else {
int p;
@@ -143,10 +144,10 @@ public class ElementListCheck implements LayoutEngineCheck {
} else {
p = Integer.parseInt(domEl.getAttribute("p"));
}
- if (p != knuthEl.getPenalty()) {
+ if (p != pen.getPenalty()) {
fail("Expected p=" + p
+ " at position " + pos
- + " but got: " + knuthEl.getPenalty());
+ + " but got: " + pen.getPenalty());
}
}
}
@@ -181,26 +182,26 @@ public class ElementListCheck implements LayoutEngineCheck {
KnuthGlue glue = (KnuthGlue)knuthEl;
if (domEl.getAttribute("w").length() > 0) {
int w = Integer.parseInt(domEl.getAttribute("w"));
- if (w != knuthEl.getWidth()) {
+ if (w != glue.getWidth()) {
fail("Expected w=" + w
+ " at position " + pos
- + " but got: " + knuthEl.getWidth());
+ + " but got: " + glue.getWidth());
}
}
if (domEl.getAttribute("y").length() > 0) {
int stretch = Integer.parseInt(domEl.getAttribute("y"));
- if (stretch != knuthEl.getStretch()) {
+ if (stretch != glue.getStretch()) {
fail("Expected y=" + stretch
+ " (stretch) at position " + pos
- + " but got: " + knuthEl.getStretch());
+ + " but got: " + glue.getStretch());
}
}
if (domEl.getAttribute("z").length() > 0) {
int shrink = Integer.parseInt(domEl.getAttribute("z"));
- if (shrink != knuthEl.getShrink()) {
+ if (shrink != glue.getShrink()) {
fail("Expected z=" + shrink
+ " (shrink) at position " + pos
- + " but got: " + knuthEl.getShrink());
+ + " but got: " + glue.getShrink());
}
}
} else {
@@ -220,7 +221,7 @@ public class ElementListCheck implements LayoutEngineCheck {
}
private void fail(String msg) {
- throw new RuntimeException(msg + " (" + this + ")");
+ throw new AssertionError(msg + " (" + this + ")");
}
private boolean haveID() {
diff --git a/test/java/org/apache/fop/layoutengine/EvalCheck.java b/test/java/org/apache/fop/layoutengine/EvalCheck.java
index 8065512a7..2af8884dd 100644
--- a/test/java/org/apache/fop/layoutengine/EvalCheck.java
+++ b/test/java/org/apache/fop/layoutengine/EvalCheck.java
@@ -77,13 +77,13 @@ public class EvalCheck implements LayoutEngineCheck, IFCheck {
double v1 = Double.parseDouble(expected);
double v2 = Double.parseDouble(actual);
if (Math.abs(v1 - v2) > tolerance) {
- throw new RuntimeException(
+ throw new AssertionError(
"Expected XPath expression to evaluate to '" + expected + "', but got '"
+ actual + "' (" + this + ", outside tolerance)");
}
} else {
if (!expected.equals(actual)) {
- throw new RuntimeException(
+ throw new AssertionError(
"Expected XPath expression to evaluate to '" + expected + "', but got '"
+ actual + "' (" + this + ")");
}
diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java
index 901969a71..57607e475 100644
--- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java
+++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java
@@ -325,6 +325,8 @@ public class LayoutEngineTestCase {
for (LayoutEngineCheck check : checks) {
try {
check.check(result);
+ } catch (AssertionError ae) {
+ throw new AssertionError("Layout test (" + testFile.getName() + "): " + ae.getMessage());
} catch (RuntimeException rte) {
throw new RuntimeException("Layout test (" + testFile.getName() + "): " + rte.getMessage());
}
diff --git a/test/java/org/apache/fop/layoutengine/ResultCheck.java b/test/java/org/apache/fop/layoutengine/ResultCheck.java
index 3b3a9cd98..7289757fb 100644
--- a/test/java/org/apache/fop/layoutengine/ResultCheck.java
+++ b/test/java/org/apache/fop/layoutengine/ResultCheck.java
@@ -50,7 +50,7 @@ public class ResultCheck implements LayoutEngineCheck {
throw new RuntimeException("No such property test: " + property);
}
if (!expected.equals(actual)) {
- throw new RuntimeException(
+ throw new AssertionError(
"Expected property to evaluate to '" + expected + "', but got '"
+ actual + "' (" + this + ")");
}
diff --git a/test/java/org/apache/fop/layoutengine/TrueCheck.java b/test/java/org/apache/fop/layoutengine/TrueCheck.java
index 77d76b91d..5509d754d 100644
--- a/test/java/org/apache/fop/layoutengine/TrueCheck.java
+++ b/test/java/org/apache/fop/layoutengine/TrueCheck.java
@@ -73,9 +73,9 @@ public class TrueCheck implements LayoutEngineCheck, IFCheck {
}
if (!XBoolean.S_TRUE.equals(res)) {
if (failureMessage != null) {
- throw new RuntimeException(failureMessage);
+ throw new AssertionError(failureMessage);
} else {
- throw new RuntimeException(
+ throw new AssertionError(
"Expected XPath expression to evaluate to 'true', but got '"
+ res + "' (" + this + ")");
}