Class NodeTest

java.lang.Object
org.custommonkey.xmlunit.NodeTest

public class NodeTest extends Object
Encapsulation of the Node-by-Node testing of a DOM Document Uses a nodetype-specific NodeFilter to pass the DOM Nodes to a NodeTester instance that performs the acual Node validation.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    NodeTest(Reader reader)
    Construct a NodeTest for the DOM built using the Reader and JAXP
    NodeTest(String xmlString)
    Construct a NodeTest for the DOM built using the String and JAXP
    NodeTest(Document document)
    Construct a NodeTest for the specified Document
    NodeTest(org.w3c.dom.traversal.DocumentTraversal documentTraversal, Node rootNode)
    Construct a NodeTest using the specified DocumentTraversal, starting at the specified root node
    Construct a NodeTest for the DOM built using the InputSource.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    performTest(NodeTester tester, short singleNodeType)
    Does this NodeTest pass using the specified NodeTester instance?
    void
    performTest(NodeTester tester, short[] nodeTypes)
    Does this NodeTest pass using the specified NodeTester instance?

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NodeTest

      public NodeTest(String xmlString) throws SAXException, IOException
      Construct a NodeTest for the DOM built using the String and JAXP
      Parameters:
      xmlString - the XML to test
      Throws:
      SAXException - if the parser says so
      IOException - on I/O errors
    • NodeTest

      public NodeTest(Reader reader) throws SAXException, IOException
      Construct a NodeTest for the DOM built using the Reader and JAXP
      Parameters:
      reader - the XML to test
      Throws:
      SAXException - if the parser says so
      IOException - on I/O errors
    • NodeTest

      public NodeTest(InputSource src) throws SAXException, IOException
      Construct a NodeTest for the DOM built using the InputSource.
      Parameters:
      src - the XML to test
      Throws:
      SAXException - if the parser says so
      IOException - on I/O errors
    • NodeTest

      public NodeTest(Document document)
      Construct a NodeTest for the specified Document
      Parameters:
      document - the XML to test
      Throws:
      IllegalArgumentException - if the Document does not support the DOM DocumentTraversal interface (most DOM implementations should provide this support)
    • NodeTest

      public NodeTest(org.w3c.dom.traversal.DocumentTraversal documentTraversal, Node rootNode)
      Construct a NodeTest using the specified DocumentTraversal, starting at the specified root node
      Parameters:
      documentTraversal - traversal
      rootNode - starting node for test
  • Method Details

    • performTest

      public void performTest(NodeTester tester, short singleNodeType) throws NodeTestException
      Does this NodeTest pass using the specified NodeTester instance?
      Parameters:
      tester - actually performs the tests
      singleNodeType - note Node.ATTRIBUTE_NODE is not exposed by the DocumentTraversal node iterator unless the root node is itself an attribute - so a NodeTester that needs to test attributes should obtain those attributes from Node.ELEMENT_NODE nodes
      Throws:
      NodeTestException - if test fails
    • performTest

      public void performTest(NodeTester tester, short[] nodeTypes) throws NodeTestException
      Does this NodeTest pass using the specified NodeTester instance?
      Parameters:
      tester - actually performs the tests
      nodeTypes - note Node.ATTRIBUTE_NODE is not exposed by the DocumentTraversal node iterator unless the root node is itself an attribute - so a NodeTester that needs to test attributes should obtain those attributes from Node.ELEMENT_NODE nodes instead
      Throws:
      NodeTestException - if test fails