From 89060b99d9e8f32d165a34c05f6cd8ca840b97b2 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 26 Jul 2005 07:37:41 +0000 Subject: [PATCH] Optional attribute "fail-msg" for the "true" check so a custom error message can be supplied. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@225248 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/layoutengine/TrueCheck.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/java/org/apache/fop/layoutengine/TrueCheck.java b/test/java/org/apache/fop/layoutengine/TrueCheck.java index 8ecaf9b0b..eb2c3a40b 100644 --- a/test/java/org/apache/fop/layoutengine/TrueCheck.java +++ b/test/java/org/apache/fop/layoutengine/TrueCheck.java @@ -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 + ")"); + } } } -- 2.39.5