]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Optional attribute "fail-msg" for the "true" check so a custom error message can...
authorJeremias Maerki <jeremias@apache.org>
Tue, 26 Jul 2005 07:37:41 +0000 (07:37 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 26 Jul 2005 07:37:41 +0000 (07:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@225248 13f79535-47bb-0310-9956-ffa450edef68

test/java/org/apache/fop/layoutengine/TrueCheck.java

index 8ecaf9b0b7ac5813be0542216692fd7777742c7d..eb2c3a40b849f9e64e8fedb9a36712e4c1e4d195 100644 (file)
@@ -31,6 +31,7 @@ import org.w3c.dom.Node;
 public class TrueCheck implements LayoutEngineCheck {
 
     private String xpath;
+    private String failureMessage;
     
     /**
      * Creates a new instance
@@ -46,6 +47,10 @@ public class TrueCheck implements LayoutEngineCheck {
      */
     public TrueCheck(Node node) {
         this.xpath = node.getAttributes().getNamedItem("xpath").getNodeValue();
+        Node nd = node.getAttributes().getNamedItem("fail-msg");
+        if (nd != null) {
+            this.failureMessage = nd.getNodeValue();
+        }
     }
     
     /** @see org.apache.fop.layoutengine.LayoutEngineCheck */
@@ -57,9 +62,13 @@ public class TrueCheck implements LayoutEngineCheck {
             throw new RuntimeException("XPath evaluation failed: " + e.getMessage());
         }
         if (!XBoolean.S_TRUE.equals(res)) {
-            throw new RuntimeException(
-                    "Expected XPath expression to evaluate to 'true', but got '" 
-                    + res + "' (" + this + ")");
+            if (failureMessage != null) {
+                throw new RuntimeException(failureMessage);
+            } else {
+                throw new RuntimeException(
+                        "Expected XPath expression to evaluate to 'true', but got '" 
+                        + res + "' (" + this + ")");
+            }
         }
 
     }