Class XmlTest<T>

  • Direct Known Subclasses:
    XmlTestNoCastor

    public abstract class XmlTest<T>
    extends java.lang.Object
    • Constructor Detail

      • XmlTest

        public XmlTest​(T sampleObject,
                       java.lang.Object sampleXml,
                       java.lang.String schemaFile)
    • Method Detail

      • initXmlUnit

        public static void initXmlUnit()
      • setUp

        public void setUp()
      • getSampleObject

        protected T getSampleObject()
      • getSampleXml

        protected java.lang.String getSampleXml()
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • getSampleXmlInputStream

        protected java.io.ByteArrayInputStream getSampleXmlInputStream()
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getSchemaFile

        protected java.lang.String getSchemaFile()
      • ignoreNamespace

        protected boolean ignoreNamespace​(java.lang.String namespace)
      • ignorePrefix

        protected boolean ignorePrefix​(java.lang.String prefix)
      • ignoreDifference

        protected boolean ignoreDifference​(org.custommonkey.xmlunit.Difference d)
      • validateXmlString

        protected void validateXmlString​(java.lang.String xml)
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • marshalToXmlWithJaxb

        protected java.lang.String marshalToXmlWithJaxb()
      • marshalJaxbAndCompareToXml

        public void marshalJaxbAndCompareToXml()
                                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • unmarshalJaxbMarshalJaxb

        public void unmarshalJaxbMarshalJaxb()
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • marshalJaxbUnmarshalJaxb

        public void marshalJaxbUnmarshalJaxb()
      • unmarshalXmlAndCompareToJaxb

        public void unmarshalXmlAndCompareToJaxb()
                                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • validateJaxbXmlAgainstSchema

        public void validateJaxbXmlAgainstSchema()
                                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • marshalToXmlWithJaxb

        public static <T> java.lang.String marshalToXmlWithJaxb​(T sampleObject)
      • unmarshalFromXmlWithJaxb

        public static <T> T unmarshalFromXmlWithJaxb​(java.lang.String xml,
                                                     java.lang.Class<T> type)
      • assertXmlEquals

        public static void assertXmlEquals​(java.lang.String expectedXml,
                                           java.lang.String actualXml)
      • _assertXmlEquals

        protected void _assertXmlEquals​(java.lang.String expectedXml,
                                        java.lang.String actualXml)
      • assertXpathDoesNotMatch

        public static void assertXpathDoesNotMatch​(java.lang.String xml,
                                                   java.lang.String expression)
                                            throws javax.xml.xpath.XPathExpressionException
        Throws:
        javax.xml.xpath.XPathExpressionException
      • assertXpathDoesNotMatch

        public static void assertXpathDoesNotMatch​(java.lang.String description,
                                                   java.lang.String xml,
                                                   java.lang.String expression)
                                            throws javax.xml.xpath.XPathExpressionException
        Throws:
        javax.xml.xpath.XPathExpressionException
      • assertXpathMatches

        public static void assertXpathMatches​(java.lang.String xml,
                                              java.lang.String expression)
                                       throws javax.xml.xpath.XPathExpressionException
        Throws:
        javax.xml.xpath.XPathExpressionException
      • assertXpathMatches

        public static void assertXpathMatches​(java.lang.String description,
                                              java.lang.String xml,
                                              java.lang.String expression)
                                       throws javax.xml.xpath.XPathExpressionException
        Throws:
        javax.xml.xpath.XPathExpressionException
      • getDifferences

        protected java.util.List<org.custommonkey.xmlunit.Difference> getDifferences​(java.lang.String xmlA,
                                                                                     java.lang.String xmlB)
      • getDifferencesSimple

        public static java.util.List<org.custommonkey.xmlunit.Difference> getDifferencesSimple​(java.lang.String xmlA,
                                                                                               java.lang.String xmlB)
      • getDifferences

        public static java.util.List<org.custommonkey.xmlunit.Difference> getDifferences​(java.lang.String xmlA,
                                                                                         java.lang.String xmlB,
                                                                                         java.util.function.Predicate<java.lang.String> ignoreNamespace,
                                                                                         java.util.function.Predicate<java.lang.String> ignorePrefix,
                                                                                         java.util.function.Predicate<org.custommonkey.xmlunit.Difference> ignoreDifference)
      • xpathGetNodesMatching

        protected static org.w3c.dom.NodeList xpathGetNodesMatching​(java.lang.String xml,
                                                                    java.lang.String expression)
                                                             throws javax.xml.xpath.XPathExpressionException
        Throws:
        javax.xml.xpath.XPathExpressionException
      • assertDepthEquals

        public static void assertDepthEquals​(java.lang.Object expected,
                                             java.lang.Object actual)