Package org.custommonkey.xmlunit
Class XMLAssert
- java.lang.Object
-
- junit.framework.Assert
-
- org.custommonkey.xmlunit.XMLAssert
-
- All Implemented Interfaces:
XMLConstants
,XSLTConstants
public class XMLAssert extends junit.framework.Assert implements XSLTConstants
Collection of static methods so that XML assertion facilities are available in any class, not just test suites. Thanks to Andrew McCormick and others for suggesting this refactoring.
Available assertion methods are:assertXMLEqual
assert that two pieces of XML markup are similarassertXMLNotEqual
assert that two pieces of XML markup are differentassertXMLIdentical
assert that two pieces of XML markup are identical. In most cases this assertion is too strong andassertXMLEqual
is sufficientassertXpathExists
assert that an XPath expression matches at least one nodeassertXpathNotExists
assert that an XPath expression does not match any nodesassertXpathsEqual
assert that the nodes obtained by executing two Xpaths are similarassertXpathsNotEqual
assert that the nodes obtained by executing two Xpaths are differentassertXpathValuesEqual
assert that the flattened String obtained by executing two Xpaths are similarassertXpathValuesNotEqual
assert that the flattened String obtained by executing two Xpaths are differentassertXpathEvaluatesTo
assert that the flattened String obtained by executing an Xpath is a particular valueassertXMLValid
assert that a piece of XML markup is valid with respect to a DTD: either by using the markup's own DTD or a different DTDassertNodeTestPasses
assert that a piece of XML markup passes aNodeTest
Diff
instances which can be instantiated and evaluated independently of this class.- See Also:
Diff.similar()
,Diff.identical()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
XMLAssert.NodeBasedNamespaceContext
-
Field Summary
-
Fields inherited from interface org.custommonkey.xmlunit.XMLConstants
CLOSE_NODE, END_CDATA, END_COMMENT, END_PROCESSING_INSTRUCTION, NULL_NS_URI, OPEN_END_NODE, OPEN_START_NODE, START_CDATA, START_COMMENT, START_DOCTYPE, START_PROCESSING_INSTRUCTION, W3C_XML_SCHEMA_INSTANCE_NO_NAMESPACE_SCHEMA_LOCATION_ATTR, W3C_XML_SCHEMA_INSTANCE_NS_URI, W3C_XML_SCHEMA_INSTANCE_SCHEMA_LOCATION_ATTR, W3C_XML_SCHEMA_NS_URI, XML_DECLARATION, XMLNS_PREFIX, XPATH_ATTRIBUTE_IDENTIFIER, XPATH_CHARACTER_NODE_IDENTIFIER, XPATH_COMMENT_IDENTIFIER, XPATH_NODE_INDEX_END, XPATH_NODE_INDEX_START, XPATH_PROCESSING_INSTRUCTION_IDENTIFIER, XPATH_SEPARATOR
-
Fields inherited from interface org.custommonkey.xmlunit.XSLTConstants
JAVA5_XSLTC_FACTORY_NAME, XSLT_END, XSLT_IDENTITY_TEMPLATE, XSLT_START, XSLT_START_NO_VERSION, XSLT_STRIP_COMMENTS_TEMPLATE, XSLT_STRIP_WHITESPACE, XSLT_XML_OUTPUT_NOINDENT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
XMLAssert()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
assertNodeTestPasses(java.lang.String xmlString, NodeTester tester, short nodeType)
Execute aNodeTest
for a single node type and assert that it passesstatic void
assertNodeTestPasses(NodeTest test, NodeTester tester, short[] nodeTypes, boolean assertion)
Execute aNodeTest
for multiple node types and make an assertion about it whether it is expected to passstatic void
assertNodeTestPasses(org.xml.sax.InputSource xml, NodeTester tester, short nodeType)
Execute aNodeTest
for a single node type and assert that it passesstatic void
assertXMLEqual(java.io.Reader control, java.io.Reader test)
Assert that two XML documents are similarstatic void
assertXMLEqual(java.lang.String err, java.io.Reader control, java.io.Reader test)
Assert that two XML documents are similarstatic void
assertXMLEqual(java.lang.String control, java.lang.String test)
Assert that two XML documents are similarstatic void
assertXMLEqual(java.lang.String err, java.lang.String control, java.lang.String test)
Assert that two XML documents are similarstatic void
assertXMLEqual(java.lang.String msg, Diff diff, boolean assertion)
Assert that the result of an XML comparison is or is not similar.static void
assertXMLEqual(java.lang.String err, org.w3c.dom.Document control, org.w3c.dom.Document test)
Assert that two XML documents are similarstatic void
assertXMLEqual(java.lang.String err, org.xml.sax.InputSource control, org.xml.sax.InputSource test)
Assert that two XML documents are similarstatic void
assertXMLEqual(Diff diff, boolean assertion)
Assert that the result of an XML comparison is or is not similar.static void
assertXMLEqual(org.w3c.dom.Document control, org.w3c.dom.Document test)
Assert that two XML documents are similarstatic void
assertXMLEqual(org.xml.sax.InputSource control, org.xml.sax.InputSource test)
Assert that two XML documents are similarstatic void
assertXMLIdentical(java.lang.String msg, Diff diff, boolean assertion)
Assert that the result of an XML comparison is or is not identicalstatic void
assertXMLIdentical(Diff diff, boolean assertion)
Assert that the result of an XML comparison is or is not identicalstatic void
assertXMLNotEqual(java.io.Reader control, java.io.Reader test)
Assert that two XML documents are NOT similarstatic void
assertXMLNotEqual(java.lang.String err, java.io.Reader control, java.io.Reader test)
Assert that two XML documents are NOT similarstatic void
assertXMLNotEqual(java.lang.String control, java.lang.String test)
Assert that two XML documents are NOT similarstatic void
assertXMLNotEqual(java.lang.String err, java.lang.String control, java.lang.String test)
Assert that two XML documents are NOT similarstatic void
assertXMLNotEqual(java.lang.String err, org.w3c.dom.Document control, org.w3c.dom.Document test)
Assert that two XML documents are NOT similarstatic void
assertXMLNotEqual(java.lang.String err, org.xml.sax.InputSource control, org.xml.sax.InputSource test)
Assert that two XML documents are NOT similarstatic void
assertXMLNotEqual(org.w3c.dom.Document control, org.w3c.dom.Document test)
Assert that two XML documents are NOT similarstatic void
assertXMLNotEqual(org.xml.sax.InputSource control, org.xml.sax.InputSource test)
Assert that two XML documents are NOT similarstatic void
assertXMLValid(java.lang.String xmlString)
Assert that a String containing XML contains valid XML: the String must contain a DOCTYPE declaration to be validatedstatic void
assertXMLValid(java.lang.String xmlString, java.lang.String systemId)
Assert that a String containing XML contains valid XML: the String must contain a DOCTYPE to be validated, but the validation will use the systemId to obtain the DTDstatic void
assertXMLValid(java.lang.String xmlString, java.lang.String systemId, java.lang.String doctype)
Assert that a String containing XML contains valid XML: the String will be given a DOCTYPE to be validated with the name and systemId specified regardless of whether it already contains a doctype declaration.static void
assertXMLValid(Validator validator)
Assert that a Validator instance returnsisValid() == true
static void
assertXMLValid(org.xml.sax.InputSource xml)
Assert that an InputSource containing XML contains valid XML: the document must contain a DOCTYPE declaration to be validatedstatic void
assertXMLValid(org.xml.sax.InputSource xml, java.lang.String systemId)
Assert that an InputSource containing XML contains valid XML: the document must contain a DOCTYPE to be validated, but the validation will use the systemId to obtain the DTDstatic void
assertXMLValid(org.xml.sax.InputSource xml, java.lang.String systemId, java.lang.String doctype)
Assert that a piece of XML contains valid XML: the document will be given a DOCTYPE to be validated with the name and systemId specified regardless of whether it already contains a doctype declaration.private static void
assertXpathEquality(java.lang.String controlXpath, org.w3c.dom.Document controlDocument, java.lang.String testXpath, org.w3c.dom.Document testDocument, boolean equal)
Assert that the node lists of two Xpaths in two documents are equal or not.static void
assertXpathEvaluatesTo(java.lang.String expectedValue, java.lang.String xpathExpression, java.lang.String inXMLString)
Assert the value of an Xpath expression in an XML Stringstatic void
assertXpathEvaluatesTo(java.lang.String expectedValue, java.lang.String xpathExpression, org.w3c.dom.Document inDocument)
Assert the value of an Xpath expression in an DOM Documentstatic void
assertXpathEvaluatesTo(java.lang.String expectedValue, java.lang.String xpathExpression, org.xml.sax.InputSource control)
Assert the value of an Xpath expression in an XML document.static void
assertXpathEvaluatesTo(QualifiedName expectedValue, java.lang.String xpathExpression, java.lang.String inXMLString)
Assert the value of an Xpath expression in an XML Stringstatic void
assertXpathEvaluatesTo(QualifiedName expectedValue, java.lang.String xpathExpression, org.w3c.dom.Document inDocument)
Assert the value of an Xpath expression in an DOM Documentstatic void
assertXpathEvaluatesTo(QualifiedName expectedValue, java.lang.String xpathExpression, org.xml.sax.InputSource control)
Assert the value of an Xpath expression in an XML document.static void
assertXpathExists(java.lang.String xPathExpression, java.lang.String inXMLString)
Assert that a specific XPath exists in some given XMLstatic void
assertXpathExists(java.lang.String xPathExpression, org.w3c.dom.Document inDocument)
Assert that a specific XPath exists in some given XMLstatic void
assertXpathExists(java.lang.String xPathExpression, org.xml.sax.InputSource control)
Assert that a specific XPath exists in some given XMLstatic void
assertXpathNotExists(java.lang.String xPathExpression, java.lang.String inXMLString)
Assert that a specific XPath does NOT exist in some given XMLstatic void
assertXpathNotExists(java.lang.String xPathExpression, org.w3c.dom.Document inDocument)
Assert that a specific XPath does NOT exist in some given XMLstatic void
assertXpathNotExists(java.lang.String xPathExpression, org.xml.sax.InputSource control)
Assert that a specific XPath does NOT exist in some given XMLstatic void
assertXpathsEqual(java.lang.String controlXpath, java.lang.String testXpath, java.lang.String inXMLString)
Assert that the node lists of two Xpaths in the same XML string are equalstatic void
assertXpathsEqual(java.lang.String controlXpath, java.lang.String inControlXMLString, java.lang.String testXpath, java.lang.String inTestXMLString)
Assert that the node lists of two Xpaths in two XML strings are equalstatic void
assertXpathsEqual(java.lang.String controlXpath, java.lang.String testXpath, org.w3c.dom.Document document)
Assert that the node lists of two Xpaths in the same document are equalstatic void
assertXpathsEqual(java.lang.String controlXpath, java.lang.String testXpath, org.xml.sax.InputSource document)
Assert that the node lists of two Xpaths in the same document are equalstatic void
assertXpathsEqual(java.lang.String controlXpath, org.w3c.dom.Document controlDocument, java.lang.String testXpath, org.w3c.dom.Document testDocument)
Assert that the node lists of two Xpaths in two documents are equalstatic void
assertXpathsEqual(java.lang.String controlXpath, org.xml.sax.InputSource controlDocument, java.lang.String testXpath, org.xml.sax.InputSource testDocument)
Assert that the node lists of two Xpaths in two documents are equalstatic void
assertXpathsNotEqual(java.lang.String controlXpath, java.lang.String testXpath, java.lang.String inXMLString)
Assert that the node lists of two Xpaths in the same XML string are NOT equalstatic void
assertXpathsNotEqual(java.lang.String controlXpath, java.lang.String inControlXMLString, java.lang.String testXpath, java.lang.String inTestXMLString)
Assert that the node lists of two Xpaths in two XML strings are NOT equalstatic void
assertXpathsNotEqual(java.lang.String controlXpath, java.lang.String testXpath, org.w3c.dom.Document document)
Assert that the node lists of two Xpaths in the same document are NOT equalstatic void
assertXpathsNotEqual(java.lang.String controlXpath, java.lang.String testXpath, org.xml.sax.InputSource document)
Assert that the node lists of two Xpaths in the same document are NOT equalstatic void
assertXpathsNotEqual(java.lang.String controlXpath, org.w3c.dom.Document controlDocument, java.lang.String testXpath, org.w3c.dom.Document testDocument)
Assert that the node lists of two Xpaths in two documents are NOT equalstatic void
assertXpathsNotEqual(java.lang.String controlXpath, org.xml.sax.InputSource controlDocument, java.lang.String testXpath, org.xml.sax.InputSource testDocument)
Assert that the node lists of two Xpaths in two XML strings are NOT equalstatic void
assertXpathValuesEqual(java.lang.String controlXpath, java.lang.String testXpath, java.lang.String inXMLString)
Assert that the evaluation of two Xpaths in the same XML string are equalstatic void
assertXpathValuesEqual(java.lang.String controlXpath, java.lang.String inControlXMLString, java.lang.String testXpath, java.lang.String inTestXMLString)
Assert that the evaluation of two Xpaths in two XML strings are equalstatic void
assertXpathValuesEqual(java.lang.String controlXpath, java.lang.String testXpath, org.w3c.dom.Document document)
Assert that the evaluation of two Xpaths in the same document are equalstatic void
assertXpathValuesEqual(java.lang.String controlXpath, java.lang.String testXpath, org.xml.sax.InputSource document)
Assert that the evaluation of two Xpaths in the same XML string are equalstatic void
assertXpathValuesEqual(java.lang.String controlXpath, org.w3c.dom.Document controlDocument, java.lang.String testXpath, org.w3c.dom.Document testDocument)
Assert that the evaluation of two Xpaths in two documents are equalstatic void
assertXpathValuesEqual(java.lang.String controlXpath, org.xml.sax.InputSource control, java.lang.String testXpath, org.xml.sax.InputSource test)
Assert that the evaluation of two Xpaths in two XML strings are equalstatic void
assertXpathValuesNotEqual(java.lang.String controlXpath, java.lang.String testXpath, java.lang.String inXMLString)
Assert that the evaluation of two Xpaths in the same XML string are NOT equalstatic void
assertXpathValuesNotEqual(java.lang.String controlXpath, java.lang.String inControlXMLString, java.lang.String testXpath, java.lang.String inTestXMLString)
Assert that the evaluation of two Xpaths in two XML strings are NOT equalstatic void
assertXpathValuesNotEqual(java.lang.String controlXpath, java.lang.String testXpath, org.w3c.dom.Document document)
Assert that the evaluation of two Xpaths in the same document are NOT equalstatic void
assertXpathValuesNotEqual(java.lang.String controlXpath, java.lang.String testXpath, org.xml.sax.InputSource control)
Assert that the evaluation of two Xpaths in the same XML string are NOT equalstatic void
assertXpathValuesNotEqual(java.lang.String controlXpath, org.w3c.dom.Document controlDocument, java.lang.String testXpath, org.w3c.dom.Document testDocument)
Assert that the evaluation of two Xpaths in two documents are NOT equalstatic void
assertXpathValuesNotEqual(java.lang.String controlXpath, org.xml.sax.InputSource control, java.lang.String testXpath, org.xml.sax.InputSource test)
Assert that the evaluation of two Xpaths in two XML strings are NOT equalprivate static org.w3c.dom.Document
asXpathResultDocument(javax.xml.parsers.DocumentBuilder builder, org.w3c.dom.NodeList nodes)
private static java.lang.String
getFailMessage(java.lang.String msg, Diff diff)
-
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
-
-
-
-
Method Detail
-
assertXMLEqual
public static void assertXMLEqual(Diff diff, boolean assertion)
Assert that the result of an XML comparison is or is not similar.- Parameters:
diff
- the result of an XML comparisonassertion
- true if asserting that result is similar
-
assertXMLEqual
public static void assertXMLEqual(java.lang.String msg, Diff diff, boolean assertion)
Assert that the result of an XML comparison is or is not similar.- Parameters:
msg
- additional message to display if assertion failsdiff
- the result of an XML comparisonassertion
- true if asserting that result is similar
-
getFailMessage
private static java.lang.String getFailMessage(java.lang.String msg, Diff diff)
-
assertXMLIdentical
public static void assertXMLIdentical(Diff diff, boolean assertion)
Assert that the result of an XML comparison is or is not identical- Parameters:
diff
- the result of an XML comparisonassertion
- true if asserting that result is identical
-
assertXMLIdentical
public static void assertXMLIdentical(java.lang.String msg, Diff diff, boolean assertion)
Assert that the result of an XML comparison is or is not identical- Parameters:
msg
- Message to display if assertion failsdiff
- the result of an XML comparisonassertion
- true if asserting that result is identical
-
assertXMLEqual
public static void assertXMLEqual(org.xml.sax.InputSource control, org.xml.sax.InputSource test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are similar- Parameters:
control
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLEqual
public static void assertXMLEqual(java.lang.String control, java.lang.String test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are similar- Parameters:
control
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLEqual
public static void assertXMLEqual(org.w3c.dom.Document control, org.w3c.dom.Document test)
Assert that two XML documents are similar- Parameters:
control
- XML to be compared againsttest
- XML to be tested
-
assertXMLEqual
public static void assertXMLEqual(java.io.Reader control, java.io.Reader test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are similar- Parameters:
control
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLEqual
public static void assertXMLEqual(java.lang.String err, org.xml.sax.InputSource control, org.xml.sax.InputSource test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are similar- Parameters:
err
- Message to be displayed on assertion failurecontrol
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLEqual
public static void assertXMLEqual(java.lang.String err, java.lang.String control, java.lang.String test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are similar- Parameters:
err
- Message to be displayed on assertion failurecontrol
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLEqual
public static void assertXMLEqual(java.lang.String err, org.w3c.dom.Document control, org.w3c.dom.Document test)
Assert that two XML documents are similar- Parameters:
err
- Message to be displayed on assertion failurecontrol
- XML to be compared againsttest
- XML to be tested
-
assertXMLEqual
public static void assertXMLEqual(java.lang.String err, java.io.Reader control, java.io.Reader test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are similar- Parameters:
err
- Message to be displayed on assertion failurecontrol
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLNotEqual
public static void assertXMLNotEqual(org.xml.sax.InputSource control, org.xml.sax.InputSource test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are NOT similar- Parameters:
control
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLNotEqual
public static void assertXMLNotEqual(java.lang.String control, java.lang.String test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are NOT similar- Parameters:
control
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLNotEqual
public static void assertXMLNotEqual(org.w3c.dom.Document control, org.w3c.dom.Document test)
Assert that two XML documents are NOT similar- Parameters:
control
- XML to be compared againsttest
- XML to be tested
-
assertXMLNotEqual
public static void assertXMLNotEqual(java.io.Reader control, java.io.Reader test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are NOT similar- Parameters:
control
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLNotEqual
public static void assertXMLNotEqual(java.lang.String err, org.xml.sax.InputSource control, org.xml.sax.InputSource test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are NOT similar- Parameters:
err
- Message to be displayed on assertion failurecontrol
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLNotEqual
public static void assertXMLNotEqual(java.lang.String err, java.lang.String control, java.lang.String test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are NOT similar- Parameters:
err
- Message to be displayed on assertion failurecontrol
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXMLNotEqual
public static void assertXMLNotEqual(java.lang.String err, org.w3c.dom.Document control, org.w3c.dom.Document test)
Assert that two XML documents are NOT similar- Parameters:
err
- Message to be displayed on assertion failurecontrol
- XML to be compared againsttest
- XML to be tested
-
assertXMLNotEqual
public static void assertXMLNotEqual(java.lang.String err, java.io.Reader control, java.io.Reader test) throws org.xml.sax.SAXException, java.io.IOException
Assert that two XML documents are NOT similar- Parameters:
err
- Message to be displayed on assertion failurecontrol
- XML to be compared againsttest
- XML to be tested- Throws:
org.xml.sax.SAXException
java.io.IOException
-
assertXpathsEqual
public static void assertXpathsEqual(java.lang.String controlXpath, java.lang.String testXpath, org.w3c.dom.Document document) throws XpathException
Assert that the node lists of two Xpaths in the same document are equal- Parameters:
controlXpath
-testXpath
-document
-- Throws:
XpathException
- See Also:
XpathEngine
-
assertXpathsEqual
public static void assertXpathsEqual(java.lang.String controlXpath, java.lang.String testXpath, org.xml.sax.InputSource document) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the node lists of two Xpaths in the same document are equal- Parameters:
controlXpath
-testXpath
-document
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
- See Also:
XpathEngine
-
assertXpathsEqual
public static void assertXpathsEqual(java.lang.String controlXpath, java.lang.String testXpath, java.lang.String inXMLString) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the node lists of two Xpaths in the same XML string are equal- Parameters:
controlXpath
-testXpath
-inXMLString
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathsEqual
public static void assertXpathsEqual(java.lang.String controlXpath, org.xml.sax.InputSource controlDocument, java.lang.String testXpath, org.xml.sax.InputSource testDocument) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the node lists of two Xpaths in two documents are equal- Parameters:
controlXpath
-testXpath
-controlDocument
-testDocument
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
- See Also:
XpathEngine
-
assertXpathsEqual
public static void assertXpathsEqual(java.lang.String controlXpath, java.lang.String inControlXMLString, java.lang.String testXpath, java.lang.String inTestXMLString) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the node lists of two Xpaths in two XML strings are equal- Parameters:
controlXpath
-inControlXMLString
-testXpath
-inTestXMLString
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathsEqual
public static void assertXpathsEqual(java.lang.String controlXpath, org.w3c.dom.Document controlDocument, java.lang.String testXpath, org.w3c.dom.Document testDocument) throws XpathException
Assert that the node lists of two Xpaths in two documents are equal- Parameters:
controlXpath
-testXpath
-controlDocument
-testDocument
-- Throws:
XpathException
- See Also:
XpathEngine
-
assertXpathsNotEqual
public static void assertXpathsNotEqual(java.lang.String controlXpath, java.lang.String testXpath, org.w3c.dom.Document document) throws XpathException
Assert that the node lists of two Xpaths in the same document are NOT equal- Parameters:
controlXpath
-testXpath
-document
-- Throws:
XpathException
- See Also:
XpathEngine
-
assertXpathsNotEqual
public static void assertXpathsNotEqual(java.lang.String controlXpath, java.lang.String testXpath, org.xml.sax.InputSource document) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the node lists of two Xpaths in the same document are NOT equal- Parameters:
controlXpath
-testXpath
-document
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
- See Also:
XpathEngine
-
assertXpathsNotEqual
public static void assertXpathsNotEqual(java.lang.String controlXpath, java.lang.String testXpath, java.lang.String inXMLString) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the node lists of two Xpaths in the same XML string are NOT equal- Parameters:
controlXpath
-testXpath
-inXMLString
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathsNotEqual
public static void assertXpathsNotEqual(java.lang.String controlXpath, java.lang.String inControlXMLString, java.lang.String testXpath, java.lang.String inTestXMLString) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the node lists of two Xpaths in two XML strings are NOT equal- Parameters:
controlXpath
-inControlXMLString
-testXpath
-inTestXMLString
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathsNotEqual
public static void assertXpathsNotEqual(java.lang.String controlXpath, org.xml.sax.InputSource controlDocument, java.lang.String testXpath, org.xml.sax.InputSource testDocument) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the node lists of two Xpaths in two XML strings are NOT equal- Parameters:
controlXpath
-controlDocument
-testXpath
-testDocument
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathsNotEqual
public static void assertXpathsNotEqual(java.lang.String controlXpath, org.w3c.dom.Document controlDocument, java.lang.String testXpath, org.w3c.dom.Document testDocument) throws XpathException
Assert that the node lists of two Xpaths in two documents are NOT equal- Parameters:
controlXpath
-testXpath
-controlDocument
-testDocument
-- Throws:
XpathException
- See Also:
XpathEngine
-
assertXpathEquality
private static void assertXpathEquality(java.lang.String controlXpath, org.w3c.dom.Document controlDocument, java.lang.String testXpath, org.w3c.dom.Document testDocument, boolean equal) throws XpathException
Assert that the node lists of two Xpaths in two documents are equal or not.- Parameters:
controlXpath
-testXpath
-controlDocument
-testDocument
-equal
- whether the values should be equal.- Throws:
XpathException
- See Also:
XpathEngine
-
assertXpathValuesEqual
public static void assertXpathValuesEqual(java.lang.String controlXpath, java.lang.String testXpath, org.w3c.dom.Document document) throws XpathException
Assert that the evaluation of two Xpaths in the same document are equal- Parameters:
controlXpath
-testXpath
-document
-- Throws:
XpathException
- See Also:
XpathEngine
-
assertXpathValuesEqual
public static void assertXpathValuesEqual(java.lang.String controlXpath, java.lang.String testXpath, org.xml.sax.InputSource document) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the evaluation of two Xpaths in the same XML string are equal- Parameters:
controlXpath
-testXpath
-document
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathValuesEqual
public static void assertXpathValuesEqual(java.lang.String controlXpath, java.lang.String testXpath, java.lang.String inXMLString) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the evaluation of two Xpaths in the same XML string are equal- Parameters:
controlXpath
-testXpath
-inXMLString
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathValuesEqual
public static void assertXpathValuesEqual(java.lang.String controlXpath, org.xml.sax.InputSource control, java.lang.String testXpath, org.xml.sax.InputSource test) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the evaluation of two Xpaths in two XML strings are equal- Parameters:
controlXpath
-control
-testXpath
-test
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathValuesEqual
public static void assertXpathValuesEqual(java.lang.String controlXpath, java.lang.String inControlXMLString, java.lang.String testXpath, java.lang.String inTestXMLString) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the evaluation of two Xpaths in two XML strings are equal- Parameters:
controlXpath
-inControlXMLString
-testXpath
-inTestXMLString
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathValuesEqual
public static void assertXpathValuesEqual(java.lang.String controlXpath, org.w3c.dom.Document controlDocument, java.lang.String testXpath, org.w3c.dom.Document testDocument) throws XpathException
Assert that the evaluation of two Xpaths in two documents are equal- Parameters:
controlXpath
-testXpath
-controlDocument
-testDocument
-- Throws:
XpathException
- See Also:
XpathEngine
-
assertXpathValuesNotEqual
public static void assertXpathValuesNotEqual(java.lang.String controlXpath, java.lang.String testXpath, org.xml.sax.InputSource control) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the evaluation of two Xpaths in the same XML string are NOT equal- Parameters:
controlXpath
-testXpath
-control
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathValuesNotEqual
public static void assertXpathValuesNotEqual(java.lang.String controlXpath, java.lang.String testXpath, java.lang.String inXMLString) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the evaluation of two Xpaths in the same XML string are NOT equal- Parameters:
controlXpath
-testXpath
-inXMLString
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathValuesNotEqual
public static void assertXpathValuesNotEqual(java.lang.String controlXpath, java.lang.String testXpath, org.w3c.dom.Document document) throws XpathException
Assert that the evaluation of two Xpaths in the same document are NOT equal- Parameters:
controlXpath
-testXpath
-document
-- Throws:
XpathException
-
assertXpathValuesNotEqual
public static void assertXpathValuesNotEqual(java.lang.String controlXpath, org.xml.sax.InputSource control, java.lang.String testXpath, org.xml.sax.InputSource test) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the evaluation of two Xpaths in two XML strings are NOT equal- Parameters:
controlXpath
-control
-testXpath
-test
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathValuesNotEqual
public static void assertXpathValuesNotEqual(java.lang.String controlXpath, java.lang.String inControlXMLString, java.lang.String testXpath, java.lang.String inTestXMLString) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert that the evaluation of two Xpaths in two XML strings are NOT equal- Parameters:
controlXpath
-inControlXMLString
-testXpath
-inTestXMLString
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
-
assertXpathValuesNotEqual
public static void assertXpathValuesNotEqual(java.lang.String controlXpath, org.w3c.dom.Document controlDocument, java.lang.String testXpath, org.w3c.dom.Document testDocument) throws XpathException
Assert that the evaluation of two Xpaths in two documents are NOT equal- Parameters:
controlXpath
-testXpath
-controlDocument
-testDocument
-- Throws:
XpathException
-
assertXpathEvaluatesTo
public static void assertXpathEvaluatesTo(java.lang.String expectedValue, java.lang.String xpathExpression, org.xml.sax.InputSource control) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert the value of an Xpath expression in an XML document.- Parameters:
expectedValue
-xpathExpression
-control
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathEvaluatesTo
public static void assertXpathEvaluatesTo(java.lang.String expectedValue, java.lang.String xpathExpression, java.lang.String inXMLString) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert the value of an Xpath expression in an XML String- Parameters:
expectedValue
-xpathExpression
-inXMLString
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathEvaluatesTo
public static void assertXpathEvaluatesTo(java.lang.String expectedValue, java.lang.String xpathExpression, org.w3c.dom.Document inDocument) throws XpathException
Assert the value of an Xpath expression in an DOM Document- Parameters:
expectedValue
-xpathExpression
-inDocument
-- Throws:
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathEvaluatesTo
public static void assertXpathEvaluatesTo(QualifiedName expectedValue, java.lang.String xpathExpression, org.xml.sax.InputSource control) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert the value of an Xpath expression in an XML document.- Parameters:
expectedValue
-xpathExpression
-control
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathEvaluatesTo
public static void assertXpathEvaluatesTo(QualifiedName expectedValue, java.lang.String xpathExpression, java.lang.String inXMLString) throws org.xml.sax.SAXException, java.io.IOException, XpathException
Assert the value of an Xpath expression in an XML String- Parameters:
expectedValue
-xpathExpression
-inXMLString
-- Throws:
org.xml.sax.SAXException
java.io.IOException
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathEvaluatesTo
public static void assertXpathEvaluatesTo(QualifiedName expectedValue, java.lang.String xpathExpression, org.w3c.dom.Document inDocument) throws XpathException
Assert the value of an Xpath expression in an DOM Document- Parameters:
expectedValue
-xpathExpression
-inDocument
-- Throws:
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathExists
public static void assertXpathExists(java.lang.String xPathExpression, org.xml.sax.InputSource control) throws java.io.IOException, org.xml.sax.SAXException, XpathException
Assert that a specific XPath exists in some given XML- Parameters:
xPathExpression
-control
-- Throws:
java.io.IOException
org.xml.sax.SAXException
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathExists
public static void assertXpathExists(java.lang.String xPathExpression, java.lang.String inXMLString) throws java.io.IOException, org.xml.sax.SAXException, XpathException
Assert that a specific XPath exists in some given XML- Parameters:
xPathExpression
-inXMLString
-- Throws:
java.io.IOException
org.xml.sax.SAXException
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathExists
public static void assertXpathExists(java.lang.String xPathExpression, org.w3c.dom.Document inDocument) throws XpathException
Assert that a specific XPath exists in some given XML- Parameters:
xPathExpression
-inDocument
-- Throws:
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathNotExists
public static void assertXpathNotExists(java.lang.String xPathExpression, org.xml.sax.InputSource control) throws java.io.IOException, org.xml.sax.SAXException, XpathException
Assert that a specific XPath does NOT exist in some given XML- Parameters:
xPathExpression
-control
-- Throws:
java.io.IOException
org.xml.sax.SAXException
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathNotExists
public static void assertXpathNotExists(java.lang.String xPathExpression, java.lang.String inXMLString) throws java.io.IOException, org.xml.sax.SAXException, XpathException
Assert that a specific XPath does NOT exist in some given XML- Parameters:
xPathExpression
-inXMLString
-- Throws:
java.io.IOException
org.xml.sax.SAXException
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXpathNotExists
public static void assertXpathNotExists(java.lang.String xPathExpression, org.w3c.dom.Document inDocument) throws XpathException
Assert that a specific XPath does NOT exist in some given XML- Parameters:
xPathExpression
-inDocument
-- Throws:
XpathException
- See Also:
which provides the underlying evaluation mechanism
-
assertXMLValid
public static void assertXMLValid(org.xml.sax.InputSource xml) throws org.xml.sax.SAXException, ConfigurationException
Assert that an InputSource containing XML contains valid XML: the document must contain a DOCTYPE declaration to be validated- Parameters:
xml
-- Throws:
org.xml.sax.SAXException
ConfigurationException
- if validation could not be turned on- See Also:
Validator
-
assertXMLValid
public static void assertXMLValid(java.lang.String xmlString) throws org.xml.sax.SAXException, ConfigurationException
Assert that a String containing XML contains valid XML: the String must contain a DOCTYPE declaration to be validated- Parameters:
xmlString
-- Throws:
org.xml.sax.SAXException
ConfigurationException
- if validation could not be turned on- See Also:
Validator
-
assertXMLValid
public static void assertXMLValid(org.xml.sax.InputSource xml, java.lang.String systemId) throws org.xml.sax.SAXException, ConfigurationException
Assert that an InputSource containing XML contains valid XML: the document must contain a DOCTYPE to be validated, but the validation will use the systemId to obtain the DTD- Parameters:
xml
-systemId
-- Throws:
org.xml.sax.SAXException
ConfigurationException
- if validation could not be turned on- See Also:
Validator
-
assertXMLValid
public static void assertXMLValid(java.lang.String xmlString, java.lang.String systemId) throws org.xml.sax.SAXException, ConfigurationException
Assert that a String containing XML contains valid XML: the String must contain a DOCTYPE to be validated, but the validation will use the systemId to obtain the DTD- Parameters:
xmlString
-systemId
-- Throws:
org.xml.sax.SAXException
ConfigurationException
- if validation could not be turned on- See Also:
Validator
-
assertXMLValid
public static void assertXMLValid(org.xml.sax.InputSource xml, java.lang.String systemId, java.lang.String doctype) throws org.xml.sax.SAXException, ConfigurationException
Assert that a piece of XML contains valid XML: the document will be given a DOCTYPE to be validated with the name and systemId specified regardless of whether it already contains a doctype declaration.- Parameters:
xml
-systemId
-doctype
-- Throws:
org.xml.sax.SAXException
ConfigurationException
- if validation could not be turned on- See Also:
Validator
-
assertXMLValid
public static void assertXMLValid(java.lang.String xmlString, java.lang.String systemId, java.lang.String doctype) throws org.xml.sax.SAXException, ConfigurationException
Assert that a String containing XML contains valid XML: the String will be given a DOCTYPE to be validated with the name and systemId specified regardless of whether it already contains a doctype declaration.- Parameters:
xmlString
-systemId
-doctype
-- Throws:
org.xml.sax.SAXException
ConfigurationException
- if validation could not be turned on- See Also:
Validator
-
assertXMLValid
public static void assertXMLValid(Validator validator)
Assert that a Validator instance returnsisValid() == true
- Parameters:
validator
-
-
assertNodeTestPasses
public static void assertNodeTestPasses(org.xml.sax.InputSource xml, NodeTester tester, short nodeType) throws org.xml.sax.SAXException, java.io.IOException
Execute aNodeTest
for a single node type and assert that it passes- Parameters:
xml
- XML to be testedtester
- The test strategynodeType
- The node type to be tested: constants defined inorg.w3c.dom.Node
e.g.Node.ELEMENT_NODE
- Throws:
org.xml.sax.SAXException
java.io.IOException
- See Also:
AbstractNodeTester
,CountingNodeTester
-
assertNodeTestPasses
public static void assertNodeTestPasses(java.lang.String xmlString, NodeTester tester, short nodeType) throws org.xml.sax.SAXException, java.io.IOException
Execute aNodeTest
for a single node type and assert that it passes- Parameters:
xmlString
- XML to be testedtester
- The test strategynodeType
- The node type to be tested: constants defined inorg.w3c.dom.Node
e.g.Node.ELEMENT_NODE
- Throws:
org.xml.sax.SAXException
java.io.IOException
- See Also:
AbstractNodeTester
,CountingNodeTester
-
assertNodeTestPasses
public static void assertNodeTestPasses(NodeTest test, NodeTester tester, short[] nodeTypes, boolean assertion)
Execute aNodeTest
for multiple node types and make an assertion about it whether it is expected to pass- Parameters:
test
- a NodeTest instance containing the XML source to be testedtester
- The test strategynodeTypes
- The node types to be tested: constants defined inorg.w3c.dom.Node
e.g.Node.ELEMENT_NODE
assertion
- true if the test is expected to pass, false otherwise- See Also:
AbstractNodeTester
,CountingNodeTester
-
asXpathResultDocument
private static org.w3c.dom.Document asXpathResultDocument(javax.xml.parsers.DocumentBuilder builder, org.w3c.dom.NodeList nodes)
-
-