Package org.codice.ddf.itests.common
Class XmlSearch
java.lang.Object
org.codice.ddf.itests.common.XmlSearch
Simpler helper class for XPath searches. Use with the XmlDocument helper class.
The purpose is to reduce the amount of duplicated code used in the test classes.
This class is not thread-safe. It not optimized-- it creates new factories and builders for every invocation. It is not suitable for use in production code.
This class does not catch errors. It passes errors up the call chain to provide developers with the most information possible when debugging test cases.
For XML related test assertions, use an org.custommonkey.xmlunit.XMLAssert methods like assertXpathEvaluatesTo().
For XML related test assertions in REST Assured responses, use the Hamcrest matcher method hasXpath().
-
Method Summary
-
Method Details
-
evaluate
- Parameters:
xPathExpression- string representation of an XPath expressionxml- string representation of an XML document- Returns:
- string representation of query result
- Throws:
Exception
-
evaluate
public static String evaluate(String xPathExpression, String xml, boolean isNamespaceAware) throws Exception - Parameters:
xPathExpression- string representation of an XPath expressionxml- string representation of an XML documentisNamespaceAware- true if xpath expression uses namespaces, other wise pass false. For example, if the XPath query "/csw:GetRecordsResponse", pass true. If the Xpath query is "/GetRecordsResponse", pass false.- Returns:
- string representation of query result
- Throws:
Exception
-
compile
- Parameters:
xPathExpression- string representation of an xpath expression- Returns:
- instance of XPathExpression
- Throws:
Exception
-
getXPath
-