Class XmlSnapshot
- java.lang.Object
-
- de.skuzzle.test.snapshots.data.xml.XmlSnapshot
-
- All Implemented Interfaces:
StructuredDataProvider
@API(status=STABLE) public final class XmlSnapshot extends Object implements StructuredDataProvider
StructuredDatabuilder for serializing test results to XML, relying on JAXB and XML-Unit.You can either use a pre-configured default instance via
xmlor use any of the static factory methods to customize the construction.- Author:
- Simon Taddiken
-
-
Field Summary
Fields Modifier and Type Field Description static StructuredDataProviderxmlSimple defaultStructuredDatainstance which infers the JAXB context from a test's actual result object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StructuredDatabuild()XmlSnapshotcompareUsing(Consumer<org.xmlunit.assertj.CompareAssert> xmls)Defines which Xml-Assert assertion method will actually be used.static XmlSnapshotinferJaxbContext()Tries to infer the JAXBContext from the passed in actual test result.static XmlSnapshotwith(javax.xml.bind.JAXBContext jaxbContext)Uses the given JAXBContext as entry point for serializing snapshots.XmlSnapshotwithMarshaller(de.skuzzle.test.snapshots.data.xml.XmlSnapshot.MarshallerSupplier marshallerSupplier)Supplies theMarshallerwhich will be used to serialize the snapshot to xml.
-
-
-
Field Detail
-
xml
public static final StructuredDataProvider xml
Simple defaultStructuredDatainstance which infers the JAXB context from a test's actual result object.If you need control over how the
JAXBContextand theMarshallerare being set up, use the static factory methods inXmlSnapshotinstead of this static constant.- See Also:
with(JAXBContext),inferJaxbContext()
-
-
Method Detail
-
inferJaxbContext
public static XmlSnapshot inferJaxbContext()
Tries to infer the JAXBContext from the passed in actual test result.- Returns:
- A builder for building
StructuredData.
-
with
public static XmlSnapshot with(javax.xml.bind.JAXBContext jaxbContext)
Uses the given JAXBContext as entry point for serializing snapshots.- Parameters:
jaxbContext- The JAXBContext to use.- Returns:
- A builder for building
StructuredData.
-
withMarshaller
public XmlSnapshot withMarshaller(de.skuzzle.test.snapshots.data.xml.XmlSnapshot.MarshallerSupplier marshallerSupplier)
Supplies theMarshallerwhich will be used to serialize the snapshot to xml.- Parameters:
marshallerSupplier- The supplier.- Returns:
- This builder instance.
-
compareUsing
@API(status=EXPERIMENTAL) public XmlSnapshot compareUsing(Consumer<org.xmlunit.assertj.CompareAssert> xmls)
Defines which Xml-Assert assertion method will actually be used. Defaults toCompareAssert.areIdentical().- Parameters:
xmls- Consumes theCompareAssertwhich compares the actual and expected xml.- Returns:
- This builder instance.
-
build
public StructuredData build()
- Specified by:
buildin interfaceStructuredDataProvider
-
-