Class AbstractSourceCodeAwareNodeProcessingTest

    • Constructor Detail

      • AbstractSourceCodeAwareNodeProcessingTest

        public AbstractSourceCodeAwareNodeProcessingTest()
    • Method Detail

      • setupSharedState

        public final void setupSharedState()
                                    throws Exception
        Throws:
        Exception
      • getJaxbAnnotatedClassesForJaxbContext

        protected abstract List<Class<?>> getJaxbAnnotatedClassesForJaxbContext()
        Returns:
        A List containing all classes which should be part of the JAXBContext.
      • getBasedir

        protected File getBasedir()
        Returns:
        The basedir directory, corresponding to the root of this project.
      • createDocument

        protected final Document createDocument​(String xmlContent)
        Creates a DOM Document from the supplied XML.
        Parameters:
        xmlContent - The non-empty XML which should be converted into a Document.
        Returns:
        The Document created from the supplied XML Content.
      • process

        public final void process​(Node node,
                                  boolean recurseToChildren,
                                  NodeProcessor visitor)
        Drives the supplied visitor to process the provided Node and all its children, should the recurseToChildren flag be set to true. All attributes of the current node are processed before recursing to children (i.e. breadth first recursion).
        Parameters:
        node - The Node to process.
        recurseToChildren - if true, processes all children of the supplied node recursively.
        visitor - The NodeProcessor instance which should process the nodes.
      • onAcceptedNode

        protected void onAcceptedNode​(Node aNode)
        Event callback when a nodeProcessor has accepted a Node.
        Parameters:
        aNode - the accepted Node
      • onAcceptedAttribute

        protected void onAcceptedAttribute​(Node anAttribute)
        Event callback when a nodeProcessor has accepted an Attribute.
        Parameters:
        anAttribute - the accepted attribute.
      • readFully

        protected static String readFully​(String path)
        Utility method to read all (string formatted) data from the given classpath-relative file and return the data as a string.
        Parameters:
        path - The classpath-relative file path.
        Returns:
        The content of the supplied file.
      • compareXmlIgnoringWhitespace

        protected static org.custommonkey.xmlunit.Diff compareXmlIgnoringWhitespace​(String expected,
                                                                                    String actual)
                                                                             throws SAXException,
                                                                                    IOException
        Compares XML documents provided by the two Readers.
        Parameters:
        expected - The expected document data.
        actual - The actual document data.
        Returns:
        A DetailedDiff object, describing all differences in documents supplied.
        Throws:
        SAXException - If a SAXException was raised during parsing of the two Documents.
        IOException - If an I/O-related exception was raised while acquiring the data from the Readers.
      • printDocument

        public static String printDocument​(Document doc)
        Prints the content of the supplied DOM Document as a string.
        Parameters:
        doc - A non-null DOM Document.
        Returns:
        A String holding the pretty-printed version of the supplied doc.