diff options
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/URIResolutionTestCase.java | 17 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java | 28 |
2 files changed, 23 insertions, 22 deletions
diff --git a/fop-core/src/test/java/org/apache/fop/URIResolutionTestCase.java b/fop-core/src/test/java/org/apache/fop/URIResolutionTestCase.java index e01271f2b..40eb72212 100644 --- a/fop-core/src/test/java/org/apache/fop/URIResolutionTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/URIResolutionTestCase.java @@ -36,6 +36,10 @@ import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; import org.junit.BeforeClass; import org.junit.Test; @@ -46,8 +50,6 @@ import static org.junit.Assert.assertTrue; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.xpath.XPathAPI; -import org.apache.xpath.objects.XObject; import org.apache.xmlgraphics.io.Resource; import org.apache.xmlgraphics.io.ResourceResolver; @@ -155,14 +157,9 @@ public class URIResolutionTestCase { return doc; } - private String evalXPath(Document doc, String xpath) { - XObject res; - try { - res = XPathAPI.eval(doc, xpath); - } catch (TransformerException e) { - throw new RuntimeException("XPath evaluation failed: " + e.getMessage()); - } - return res.str(); + private String evalXPath(Document doc, String xpath) throws XPathExpressionException { + XPath xPath = XPathFactory.newInstance().newXPath(); + return (String) xPath.compile(xpath).evaluate(doc, XPathConstants.STRING); } /** diff --git a/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java b/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java index 4f56f9c7d..901bef2e6 100644 --- a/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java +++ b/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java @@ -35,13 +35,14 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.apache.xpath.XPathAPI; -import org.apache.xpath.objects.XObject; - import org.apache.fop.apps.EnvironmentProfile; import org.apache.fop.apps.EnvironmentalProfileFactory; import org.apache.fop.apps.FopFactory; @@ -128,33 +129,36 @@ public class TestAssistant { private boolean isBase14KerningEnabled(Document testDoc) { try { - XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/base14kerning"); - String s = xo.str(); + String s = eval(testDoc, "/testcase/cfg/base14kerning"); return ("true".equalsIgnoreCase(s)); - } catch (TransformerException e) { + } catch (XPathExpressionException e) { throw new RuntimeException("Error while evaluating XPath expression", e); } } private boolean isStrictValidation(Document testDoc) { try { - XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/strict-validation"); - return !("false".equalsIgnoreCase(xo.str())); - } catch (TransformerException e) { + String s = eval(testDoc, "/testcase/cfg/strict-validation"); + return !("false".equalsIgnoreCase(s)); + } catch (XPathExpressionException e) { throw new RuntimeException("Error while evaluating XPath expression", e); } } private boolean isTableBorderOverpaint(Document testDoc) { try { - XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/table-border-overpaint"); - String s = xo.str(); + String s = eval(testDoc, "/testcase/cfg/table-border-overpaint"); return "true".equalsIgnoreCase(s); - } catch (TransformerException e) { + } catch (XPathExpressionException e) { throw new RuntimeException("Error while evaluating XPath expression", e); } } + private String eval(Document doc, String xpath) throws XPathExpressionException { + XPath xPath = XPathFactory.newInstance().newXPath(); + return (String) xPath.compile(xpath).evaluate(doc, XPathConstants.STRING); + } + /** * Loads a test case into a DOM document. * @param testFile the test file |