]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Tweak - Make sure that proper distinction is made between real RuntimeException ...
authorAndreas L. Delmelle <adelmelle@apache.org>
Thu, 26 Nov 2015 17:04:44 +0000 (17:04 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Thu, 26 Nov 2015 17:04:44 +0000 (17:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1716744 13f79535-47bb-0310-9956-ffa450edef68

test/java/org/apache/fop/layoutengine/ElementListCheck.java
test/java/org/apache/fop/layoutengine/EvalCheck.java
test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java
test/java/org/apache/fop/layoutengine/ResultCheck.java
test/java/org/apache/fop/layoutengine/TrueCheck.java

index 4d33d670bacd1d04e32956b987c98500007efc45..e515285524bc8dacf0c1b40e54a4cc97ce671223 100644 (file)
@@ -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() {
index 8065512a7f59e7346aabebd8621e0b182c7dd291..2af8884dd03845d3d2b51abbf6665ada6a9f1538 100644 (file)
@@ -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 + ")");
             }
index 901969a71b9d25da21705e07a656c22e725ab276..57607e475ecd40cb89078d230fd54cf98886aa0e 100644 (file)
@@ -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());
             }
index 3b3a9cd989bb38ea5aab4d7fee95e4d24e1f80d8..7289757fbfbbc15d453e6a530f72d11a919fd9d3 100644 (file)
@@ -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 + ")");
         }
index 77d76b91d3974c8bdca80e278d0c4e8433521f31..5509d754dfc2890fe3ac6555e179e20f35c8ff4c 100644 (file)
@@ -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 + ")");
             }