Class CountingNodeTester

  • All Implemented Interfaces:
    NodeTester

    public class CountingNodeTester
    extends java.lang.Object
    implements NodeTester
    Counts the number of nodes in a document to allow assertions to be made using a NodeTest.
    See Also:
    NodeTest
    • Constructor Summary

      Constructors 
      Constructor Description
      CountingNodeTester​(int expectedNumNodes)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void noMoreNodes​(NodeTest forTest)
      Called by NodeTest when all nodes have been iterated over: time to see if all the nodes that were expected were found.
      void resetCounter()
      Reset the counter so that an instance can be reused for another NodeTest
      void testNode​(org.w3c.dom.Node aNode, NodeTest forTest)
      A single Node is always valid
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • expectedNumNodes

        private final int expectedNumNodes
      • actualNumNodes

        private int actualNumNodes
    • Constructor Detail

      • CountingNodeTester

        public CountingNodeTester​(int expectedNumNodes)
    • Method Detail

      • testNode

        public void testNode​(org.w3c.dom.Node aNode,
                             NodeTest forTest)
        A single Node is always valid
        Specified by:
        testNode in interface NodeTester
        Parameters:
        aNode -
        forTest -
      • noMoreNodes

        public void noMoreNodes​(NodeTest forTest)
                         throws NodeTestException
        Called by NodeTest when all nodes have been iterated over: time to see if all the nodes that were expected were found. Note that this method also invokes resetCounter so that the instance can be reused.
        Specified by:
        noMoreNodes in interface NodeTester
        Throws:
        NodeTestException - if this instance was expecting more nodes
      • resetCounter

        public void resetCounter()
        Reset the counter so that an instance can be reused for another NodeTest