Package org.opennms.core.test.xml
Class XmlTest<T>
- java.lang.Object
-
- org.opennms.core.test.xml.XmlTest<T>
-
- Direct Known Subclasses:
XmlTestNoCastor
public abstract class XmlTest<T> extends Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_assertXmlEquals(String expectedXml, String actualXml)
static void
assertDepthEquals(Object expected, Object actual)
static void
assertXmlEquals(String expectedXml, String actualXml)
static void
assertXpathDoesNotMatch(String xml, String expression)
static void
assertXpathDoesNotMatch(String description, String xml, String expression)
static void
assertXpathMatches(String xml, String expression)
static void
assertXpathMatches(String description, String xml, String expression)
protected List<org.custommonkey.xmlunit.Difference>
getDifferences(String xmlA, String xmlB)
static List<org.custommonkey.xmlunit.Difference>
getDifferences(String xmlA, String xmlB, java.util.function.Predicate<String> ignoreNamespace, java.util.function.Predicate<String> ignorePrefix, java.util.function.Predicate<org.custommonkey.xmlunit.Difference> ignoreDifference)
static List<org.custommonkey.xmlunit.Difference>
getDifferencesSimple(String xmlA, String xmlB)
protected T
getSampleObject()
protected String
getSampleXml()
protected ByteArrayInputStream
getSampleXmlInputStream()
protected String
getSchemaFile()
protected boolean
ignoreDifference(org.custommonkey.xmlunit.Difference d)
protected boolean
ignoreNamespace(String namespace)
protected boolean
ignorePrefix(String prefix)
static void
initXmlUnit()
void
marshalJaxbAndCompareToXml()
void
marshalJaxbUnmarshalJaxb()
protected String
marshalToXmlWithJaxb()
static <T> String
marshalToXmlWithJaxb(T sampleObject)
void
setUp()
static <T> T
unmarshalFromXmlWithJaxb(String xml, Class<T> type)
void
unmarshalJaxbMarshalJaxb()
void
unmarshalXmlAndCompareToJaxb()
void
validateJaxbXmlAgainstSchema()
protected void
validateXmlString(String xml)
protected static NodeList
xpathGetNodesMatching(String xml, String expression)
-
-
-
Method Detail
-
initXmlUnit
public static void initXmlUnit()
-
setUp
public void setUp()
-
getSampleObject
protected T getSampleObject()
-
getSampleXml
protected String getSampleXml() throws IOException
- Throws:
IOException
-
getSampleXmlInputStream
protected ByteArrayInputStream getSampleXmlInputStream() throws IOException
- Throws:
IOException
-
getSchemaFile
protected String getSchemaFile()
-
ignoreNamespace
protected boolean ignoreNamespace(String namespace)
-
ignorePrefix
protected boolean ignorePrefix(String prefix)
-
ignoreDifference
protected boolean ignoreDifference(org.custommonkey.xmlunit.Difference d)
-
marshalToXmlWithJaxb
protected String marshalToXmlWithJaxb()
-
marshalJaxbAndCompareToXml
public void marshalJaxbAndCompareToXml() throws Exception
- Throws:
Exception
-
marshalJaxbUnmarshalJaxb
public void marshalJaxbUnmarshalJaxb()
-
unmarshalXmlAndCompareToJaxb
public void unmarshalXmlAndCompareToJaxb() throws Exception
- Throws:
Exception
-
validateJaxbXmlAgainstSchema
public void validateJaxbXmlAgainstSchema() throws Exception
- Throws:
Exception
-
marshalToXmlWithJaxb
public static <T> String marshalToXmlWithJaxb(T sampleObject)
-
assertXpathDoesNotMatch
public static void assertXpathDoesNotMatch(String xml, String expression) throws XPathExpressionException
- Throws:
XPathExpressionException
-
assertXpathDoesNotMatch
public static void assertXpathDoesNotMatch(String description, String xml, String expression) throws XPathExpressionException
- Throws:
XPathExpressionException
-
assertXpathMatches
public static void assertXpathMatches(String xml, String expression) throws XPathExpressionException
- Throws:
XPathExpressionException
-
assertXpathMatches
public static void assertXpathMatches(String description, String xml, String expression) throws XPathExpressionException
- Throws:
XPathExpressionException
-
getDifferences
protected List<org.custommonkey.xmlunit.Difference> getDifferences(String xmlA, String xmlB)
-
getDifferencesSimple
public static List<org.custommonkey.xmlunit.Difference> getDifferencesSimple(String xmlA, String xmlB)
-
getDifferences
public static List<org.custommonkey.xmlunit.Difference> getDifferences(String xmlA, String xmlB, java.util.function.Predicate<String> ignoreNamespace, java.util.function.Predicate<String> ignorePrefix, java.util.function.Predicate<org.custommonkey.xmlunit.Difference> ignoreDifference)
-
xpathGetNodesMatching
protected static NodeList xpathGetNodesMatching(String xml, String expression) throws XPathExpressionException
- Throws:
XPathExpressionException
-
-