Class XMLObjectBaseTestCase

    • Field Detail

      • log

        private final org.slf4j.Logger log
        Logger
      • parserPool

        protected static ParserPool parserPool
        Parser pool
      • marshallerFactory

        protected static MarshallerFactory marshallerFactory
        XMLObject marshaller factory
      • unmarshallerFactory

        protected static UnmarshallerFactory unmarshallerFactory
        XMLObject unmarshaller factory
      • simpleXMLObjectQName

        protected static QName simpleXMLObjectQName
        QName for SimpleXMLObject
    • Constructor Detail

      • XMLObjectBaseTestCase

        public XMLObjectBaseTestCase()
    • Method Detail

      • initXMLObjectSupport

        @BeforeClass
        protected void initXMLObjectSupport()
                                     throws Exception
        Throws:
        Exception
      • assertXMLEquals

        protected void assertXMLEquals​(Document expectedDOM,
                                       XMLObject xmlObject)
        Asserts a given XMLObject is equal to an expected DOM. The XMLObject is marshalled and the resulting DOM object is compared against the expected DOM object for equality.
        Parameters:
        expectedDOM - the expected DOM
        xmlObject - the XMLObject to be marshalled and compared against the expected DOM
      • assertXMLEquals

        protected void assertXMLEquals​(String failMessage,
                                       Document expectedDOM,
                                       XMLObject xmlObject)
        Asserts a given XMLObject is equal to an expected DOM. The XMLObject is marshalled and the resulting DOM object is compared against the expected DOM object for equality.
        Parameters:
        failMessage - the message to display if the DOMs are not equal
        expectedDOM - the expected DOM
        xmlObject - the XMLObject to be marshalled and compared against the expected DOM
      • buildXMLObject

        protected <T extends XMLObject> T buildXMLObject​(QName name)
        Builds the requested XMLObject.
        Type Parameters:
        T - type of the result
        Parameters:
        name - name of the XMLObject
        Returns:
        the built XMLObject
      • unmarshallElement

        protected <T extends XMLObject> T unmarshallElement​(String elementFile)
        Unmarshalls an element file into its XMLObject.
        Type Parameters:
        T - expected type
        Parameters:
        elementFile - the element file to unmarshall
        Returns:
        the XMLObject from the file
      • unmarshallElement

        protected <T extends XMLObject> T unmarshallElement​(String elementFile,
                                                            boolean propagateErrors)
                                                     throws XMLParserException,
                                                            UnmarshallingException
        Unmarshalls an element file into its XMLObject.
        Type Parameters:
        T - expected type
        Parameters:
        elementFile - the element file to unmarshall
        propagateErrors - if true, checked exceptions will be thrown, if false then they cause assertion of test failure
        Returns:
        the XMLObject from the file
        Throws:
        XMLParserException - ...
        UnmarshallingException - ...
      • printXML

        protected void printXML​(Node node,
                                String filename)
        For convenience when testing, pretty-print the specified DOM node to a file, or to the console if filename is null.
        Parameters:
        node - node to print
        filename - name of file to print to
      • printXML

        protected void printXML​(XMLObject xmlObject,
                                String filename)
        For convenience when testing, pretty-print the specified XMLObject to a file, or to the console if filename is null.
        Parameters:
        xmlObject - XMLObject to print
        filename - name of file to print to
      • getBuilder

        protected <T extends XMLObjectXMLObjectBuilder<T> getBuilder​(QName qname)
        Lookup the XMLObjectBuilder for a QName.
        Type Parameters:
        T - type of result for the XMLObjectBuilder
        Parameters:
        qname - the QName for which to find the builder
        Returns:
        the XMLObjectBuilder
      • getMarshaller

        protected Marshaller getMarshaller​(QName qname)
        Lookup the marshaller for a QName
        Parameters:
        qname - the QName for which to find the marshaller
        Returns:
        the marshaller
      • getMarshaller

        protected Marshaller getMarshaller​(XMLObject xmlObject)
        Lookup the marshaller for an XMLObject.
        Parameters:
        xmlObject - the XMLObject for which to find the marshaller
        Returns:
        the marshaller
      • getUnmarshaller

        protected Unmarshaller getUnmarshaller​(QName qname)
        Lookup the unmarshaller for a QName.
        Parameters:
        qname - the QName for which to find the unmarshaller
        Returns:
        the unmarshaller
      • getUnmarshaller

        protected Unmarshaller getUnmarshaller​(XMLObject xmlObject)
        Lookup the unmarshaller for an XMLObject.
        Parameters:
        xmlObject - the XMLObject for which to find the unmarshaller
        Returns:
        the unmarshaller
      • getUnmarshaller

        protected Unmarshaller getUnmarshaller​(Element element)
        Lookup the unmarshaller for a DOM Element.
        Parameters:
        element - the Element for which to find the unmarshaller
        Returns:
        the unmarshaller
      • parseXMLDocument

        protected Document parseXMLDocument​(String xmlFilename)
                                     throws XMLParserException
        Parse an XML file as a classpath resource.
        Parameters:
        xmlFilename - the file to parse
        Returns:
        the parsed Document
        Throws:
        XMLParserException - if parsing did not succeed