| org.custommonkey.xmlunit.XMLAssert
XMLAssert | public class XMLAssert extends Assert implements XSLTConstants(Code) | | 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 similar
assertXMLNotEqual
assert that two pieces of XML markup are different
assertXMLIdentical
assert that two pieces of XML markup are identical. In most cases
this assertion is too strong and assertXMLEqual is sufficient
assertXpathExists
assert that an XPath expression matches at least one node
assertXpathNotExists
assert that an XPath expression does not match any nodes
assertXpathsEqual
assert that the nodes obtained by executing two Xpaths
are similar
assertXpathsNotEqual
assert that the nodes obtained by executing two Xpaths
are different
assertXpathValuesEqual
assert that the flattened String obtained by executing two Xpaths
are similar
assertXpathValuesNotEqual
assert that the flattened String obtained by executing two Xpaths
are different
assertXpathEvaluatesTo
assert that the flattened String obtained by executing an Xpath
is a particular value
assertXMLValid
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 DTD
assertNodeTestPasses
assert that a piece of XML markup passes a
NodeTest NodeTest
All underlying similarity and difference testing is done using
Diff Diff instances which can be instantiated and evaluated
independently of this class.
See Also: Diff.similar See Also: Diff.identical See Also: Examples and more at xmlunit.sourceforge.net |
Method Summary | |
public static void | assertNodeTestPasses(InputSource xml, NodeTester tester, short nodeType) Execute a NodeTest for a single node type
and assert that it passes
Parameters: xml - XML to be tested Parameters: tester - The test strategy Parameters: nodeType - The node type to be tested: constants definedin Node org.w3c.dom.Node e.g. | public static void | assertNodeTestPasses(String xmlString, NodeTester tester, short nodeType) Execute a NodeTest for a single node type
and assert that it passes
Parameters: xmlString - XML to be tested Parameters: tester - The test strategy Parameters: nodeType - The node type to be tested: constants definedin Node org.w3c.dom.Node e.g. | public static void | assertNodeTestPasses(NodeTest test, NodeTester tester, short[] nodeTypes, boolean assertion) Execute a NodeTest 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 tested Parameters: tester - The test strategy Parameters: nodeTypes - The node types to be tested: constants definedin Node org.w3c.dom.Node e.g. | public static void | assertXMLEqual(Diff diff, boolean assertion) Assert that the result of an XML comparison is or is not similar. | public static void | assertXMLEqual(String msg, Diff diff, boolean assertion) Assert that the result of an XML comparison is or is not similar. | public static void | assertXMLEqual(InputSource control, InputSource test) | public static void | assertXMLEqual(String control, String test) | public static void | assertXMLEqual(Document control, Document test) | public static void | assertXMLEqual(Reader control, Reader test) | public static void | assertXMLEqual(String err, InputSource control, InputSource test) | public static void | assertXMLEqual(String err, String control, String test) | public static void | assertXMLEqual(String err, Document control, Document test) | public static void | assertXMLEqual(String err, Reader control, Reader test) | public static void | assertXMLIdentical(Diff diff, boolean assertion) | public static void | assertXMLIdentical(String msg, Diff diff, boolean assertion) | public static void | assertXMLNotEqual(InputSource control, InputSource test) | public static void | assertXMLNotEqual(String control, String test) | public static void | assertXMLNotEqual(Document control, Document test) | public static void | assertXMLNotEqual(Reader control, Reader test) | public static void | assertXMLNotEqual(String err, InputSource control, InputSource test) | public static void | assertXMLNotEqual(String err, String control, String test) | public static void | assertXMLNotEqual(String err, Document control, Document test) | public static void | assertXMLNotEqual(String err, Reader control, Reader test) | public static void | assertXMLValid(InputSource xml) | public static void | assertXMLValid(String xmlString) | public static void | assertXMLValid(InputSource xml, String systemId) | public static void | assertXMLValid(String xmlString, String systemId) | public static void | assertXMLValid(InputSource xml, String systemId, 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. | public static void | assertXMLValid(String xmlString, String systemId, 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. | public static void | assertXMLValid(Validator validator) | public static void | assertXpathEvaluatesTo(String expectedValue, String xpathExpression, InputSource control) Assert the value of an Xpath expression in an XML document. | public static void | assertXpathEvaluatesTo(String expectedValue, String xpathExpression, String inXMLString) | public static void | assertXpathEvaluatesTo(String expectedValue, String xpathExpression, Document inDocument) | public static void | assertXpathExists(String xPathExpression, InputSource control) | public static void | assertXpathExists(String xPathExpression, String inXMLString) | public static void | assertXpathExists(String xPathExpression, Document inDocument) | public static void | assertXpathNotExists(String xPathExpression, InputSource control) | public static void | assertXpathNotExists(String xPathExpression, String inXMLString) | public static void | assertXpathNotExists(String xPathExpression, Document inDocument) | public static void | assertXpathValuesEqual(String controlXpath, String testXpath, Document document) | public static void | assertXpathValuesEqual(String controlXpath, String testXpath, InputSource document) | public static void | assertXpathValuesEqual(String controlXpath, String testXpath, String inXMLString) | public static void | assertXpathValuesEqual(String controlXpath, InputSource control, String testXpath, InputSource test) | public static void | assertXpathValuesEqual(String controlXpath, String inControlXMLString, String testXpath, String inTestXMLString) | public static void | assertXpathValuesEqual(String controlXpath, Document controlDocument, String testXpath, Document testDocument) | public static void | assertXpathValuesNotEqual(String controlXpath, String testXpath, InputSource control) | public static void | assertXpathValuesNotEqual(String controlXpath, String testXpath, String inXMLString) | public static void | assertXpathValuesNotEqual(String controlXpath, String testXpath, Document document) | public static void | assertXpathValuesNotEqual(String controlXpath, InputSource control, String testXpath, InputSource test) | public static void | assertXpathValuesNotEqual(String controlXpath, String inControlXMLString, String testXpath, String inTestXMLString) | public static void | assertXpathValuesNotEqual(String controlXpath, Document controlDocument, String testXpath, Document testDocument) | public static void | assertXpathsEqual(String controlXpath, String testXpath, Document document) | public static void | assertXpathsEqual(String controlXpath, String testXpath, InputSource document) | public static void | assertXpathsEqual(String controlXpath, String testXpath, String inXMLString) | public static void | assertXpathsEqual(String controlXpath, InputSource controlDocument, String testXpath, InputSource testDocument) | public static void | assertXpathsEqual(String controlXpath, String inControlXMLString, String testXpath, String inTestXMLString) | public static void | assertXpathsEqual(String controlXpath, Document controlDocument, String testXpath, Document testDocument) | public static void | assertXpathsNotEqual(String controlXpath, String testXpath, Document document) | public static void | assertXpathsNotEqual(String controlXpath, String testXpath, InputSource document) | public static void | assertXpathsNotEqual(String controlXpath, String testXpath, String inXMLString) | public static void | assertXpathsNotEqual(String controlXpath, String inControlXMLString, String testXpath, String inTestXMLString) | public static void | assertXpathsNotEqual(String controlXpath, InputSource controlDocument, String testXpath, InputSource testDocument) | public static void | assertXpathsNotEqual(String controlXpath, Document controlDocument, String testXpath, Document testDocument) |
XMLAssert | protected XMLAssert()(Code) | | |
assertNodeTestPasses | public static void assertNodeTestPasses(NodeTest test, NodeTester tester, short[] nodeTypes, boolean assertion)(Code) | | Execute a NodeTest 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 tested Parameters: tester - The test strategy Parameters: nodeTypes - The node types to be tested: constants definedin Node org.w3c.dom.Node e.g. Node.ELEMENT_NODE Parameters: assertion - true if the test is expected to pass, false otherwise See Also: AbstractNodeTester See Also: CountingNodeTester |
assertXMLEqual | public static void assertXMLEqual(Diff diff, boolean assertion)(Code) | | Assert that the result of an XML comparison is or is not similar.
Parameters: diff - the result of an XML comparison Parameters: assertion - true if asserting that result is similar |
assertXMLEqual | public static void assertXMLEqual(String msg, Diff diff, boolean assertion)(Code) | | Assert that the result of an XML comparison is or is not similar.
Parameters: msg - additional message to display if assertion fails Parameters: diff - the result of an XML comparison Parameters: assertion - true if asserting that result is similar |
assertXMLEqual | public static void assertXMLEqual(Document control, Document test)(Code) | | Assert that two XML documents are similar
Parameters: control - XML to be compared against Parameters: test - XML to be tested |
assertXMLEqual | public static void assertXMLEqual(String err, String control, String test) throws SAXException, IOException(Code) | | Assert that two XML documents are similar
Parameters: err - Message to be displayed on assertion failure Parameters: control - XML to be compared against Parameters: test - XML to be tested throws: SAXException - throws: IOException - |
assertXMLEqual | public static void assertXMLEqual(String err, Document control, Document test)(Code) | | Assert that two XML documents are similar
Parameters: err - Message to be displayed on assertion failure Parameters: control - XML to be compared against Parameters: test - XML to be tested |
assertXMLEqual | public static void assertXMLEqual(String err, Reader control, Reader test) throws SAXException, IOException(Code) | | Assert that two XML documents are similar
Parameters: err - Message to be displayed on assertion failure Parameters: control - XML to be compared against Parameters: test - XML to be tested throws: SAXException - throws: IOException - |
assertXMLIdentical | public static void assertXMLIdentical(Diff diff, boolean assertion)(Code) | | Assert that the result of an XML comparison is or is not identical
Parameters: diff - the result of an XML comparison Parameters: assertion - true if asserting that result is identical |
assertXMLIdentical | public static void assertXMLIdentical(String msg, Diff diff, boolean assertion)(Code) | | Assert that the result of an XML comparison is or is not identical
Parameters: msg - Message to display if assertion fails Parameters: diff - the result of an XML comparison Parameters: assertion - true if asserting that result is identical |
assertXMLNotEqual | public static void assertXMLNotEqual(Document control, Document test)(Code) | | Assert that two XML documents are NOT similar
Parameters: control - XML to be compared against Parameters: test - XML to be tested |
assertXMLNotEqual | public static void assertXMLNotEqual(String err, String control, String test) throws SAXException, IOException(Code) | | Assert that two XML documents are NOT similar
Parameters: err - Message to be displayed on assertion failure Parameters: control - XML to be compared against Parameters: test - XML to be tested throws: SAXException - throws: IOException - |
assertXMLNotEqual | public static void assertXMLNotEqual(String err, Document control, Document test)(Code) | | Assert that two XML documents are NOT similar
Parameters: err - Message to be displayed on assertion failure Parameters: control - XML to be compared against Parameters: test - XML to be tested |
assertXMLNotEqual | public static void assertXMLNotEqual(String err, Reader control, Reader test) throws SAXException, IOException(Code) | | Assert that two XML documents are NOT similar
Parameters: err - Message to be displayed on assertion failure Parameters: control - XML to be compared against Parameters: test - XML to be tested throws: SAXException - throws: IOException - |
assertXMLValid | public static void assertXMLValid(String xmlString, String systemId, String doctype) throws SAXException, ConfigurationException(Code) | | 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 - Parameters: systemId - Parameters: doctype - throws: SAXException - throws: ConfigurationException - if validation could not be turned on See Also: Validator |
assertXMLValid | public static void assertXMLValid(Validator validator)(Code) | | Assert that a Validator instance returns isValid() == true
Parameters: validator - |
assertXpathEvaluatesTo | public static void assertXpathEvaluatesTo(String expectedValue, String xpathExpression, Document inDocument) throws XpathException(Code) | | Assert the value of an Xpath expression in an DOM Document
Parameters: expectedValue - Parameters: xpathExpression - Parameters: inDocument - See Also: XpathEngine See Also: which provides the underlying evaluation mechanism |
assertXpathExists | public static void assertXpathExists(String xPathExpression, String inXMLString) throws IOException, SAXException, XpathException(Code) | | Assert that a specific XPath exists in some given XML
Parameters: inXpathExpression - Parameters: inXMLString - See Also: XpathEngine See Also: which provides the underlying evaluation mechanism |
assertXpathExists | public static void assertXpathExists(String xPathExpression, Document inDocument) throws XpathException(Code) | | Assert that a specific XPath exists in some given XML
Parameters: inXpathExpression - Parameters: inDocument - See Also: XpathEngine See Also: which provides the underlying evaluation mechanism |
assertXpathNotExists | public static void assertXpathNotExists(String xPathExpression, InputSource control) throws IOException, SAXException, XpathException(Code) | | Assert that a specific XPath does NOT exist in some given XML
Parameters: inXpathExpression - Parameters: control - See Also: XpathEngine See Also: which provides the underlying evaluation mechanism |
assertXpathNotExists | public static void assertXpathNotExists(String xPathExpression, String inXMLString) throws IOException, SAXException, XpathException(Code) | | Assert that a specific XPath does NOT exist in some given XML
Parameters: inXpathExpression - Parameters: inXMLString - See Also: XpathEngine See Also: which provides the underlying evaluation mechanism |
assertXpathNotExists | public static void assertXpathNotExists(String xPathExpression, Document inDocument) throws XpathException(Code) | | Assert that a specific XPath does NOT exist in some given XML
Parameters: inXpathExpression - Parameters: inDocument - See Also: XpathEngine See Also: which provides the underlying evaluation mechanism |
assertXpathValuesEqual | public static void assertXpathValuesEqual(String controlXpath, String testXpath, Document document) throws XpathException(Code) | | Assert that the evaluation of two Xpaths in the same document are equal
Parameters: xpathOne - Parameters: xpathTwo - Parameters: document - See Also: XpathEngine |
assertXpathValuesEqual | public static void assertXpathValuesEqual(String controlXpath, Document controlDocument, String testXpath, Document testDocument) throws XpathException(Code) | | Assert that the evaluation of two Xpaths in two documents are equal
Parameters: xpathOne - Parameters: xpathTwo - Parameters: document - See Also: XpathEngine |
assertXpathValuesNotEqual | public static void assertXpathValuesNotEqual(String controlXpath, String testXpath, Document document) throws XpathException(Code) | | Assert that the evaluation of two Xpaths in the same document are
NOT equal
Parameters: xpathOne - Parameters: xpathTwo - Parameters: document - |
assertXpathValuesNotEqual | public static void assertXpathValuesNotEqual(String controlXpath, Document controlDocument, String testXpath, Document testDocument) throws XpathException(Code) | | Assert that the evaluation of two Xpaths in two documents are
NOT equal
Parameters: xpathOne - Parameters: xpathTwo - Parameters: document - |
assertXpathsEqual | public static void assertXpathsEqual(String controlXpath, String testXpath, Document document) throws XpathException(Code) | | Assert that the node lists of two Xpaths in the same document are equal
Parameters: xpathOne - Parameters: xpathTwo - Parameters: document - See Also: XpathEngine |
assertXpathsEqual | public static void assertXpathsEqual(String controlXpath, Document controlDocument, String testXpath, Document testDocument) throws XpathException(Code) | | Assert that the node lists of two Xpaths in two documents are equal
Parameters: xpathOne - Parameters: xpathTwo - Parameters: controlDocument - Parameters: testDocument - See Also: XpathEngine |
assertXpathsNotEqual | public static void assertXpathsNotEqual(String controlXpath, String testXpath, Document document) throws XpathException(Code) | | Assert that the node lists of two Xpaths in the same document are NOT equal
Parameters: xpathOne - Parameters: xpathTwo - Parameters: document - See Also: XpathEngine |
assertXpathsNotEqual | public static void assertXpathsNotEqual(String controlXpath, Document controlDocument, String testXpath, Document testDocument) throws XpathException(Code) | | Assert that the node lists of two Xpaths in two documents are NOT equal
Parameters: xpathOne - Parameters: xpathTwo - Parameters: document - See Also: XpathEngine |
|
|