Package org.opensaml.core.testing
Class XMLObjectBaseTestCase
java.lang.Object
org.opensaml.core.testing.OpenSAMLInitBaseTestCase
org.opensaml.core.testing.XMLObjectBaseTestCase
- Direct Known Subclasses:
XMLObjectProviderBaseTestCase
Base test case class for tests that operate on XMLObjects.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static XMLObjectBuilderFactoryXMLObject builder factory.private final org.slf4j.LoggerLogger.protected static MarshallerFactoryXMLObject marshaller factory.protected static ParserPoolParser pool.protected static QNameQName for SimpleXMLObject.protected static UnmarshallerFactoryXMLObject unmarshaller factory. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassertXMLEquals(String failMessage, Document expectedDOM, XMLObject xmlObject) Asserts a given XMLObject is equal to an expected DOM.protected voidassertXMLEquals(Document expectedDOM, XMLObject xmlObject) Asserts a given XMLObject is equal to an expected DOM.protected <T extends XMLObject>
TbuildXMLObject(QName name) Builds the requested XMLObject.protected <T extends XMLObject>
XMLObjectBuilder<T>getBuilder(QName qname) Lookup the XMLObjectBuilder for a QName.protected MarshallergetMarshaller(QName qname) Lookup the marshaller for a QName.protected MarshallergetMarshaller(XMLObject xmlObject) Lookup the marshaller for an XMLObject.protected UnmarshallergetUnmarshaller(QName qname) Lookup the unmarshaller for a QName.protected UnmarshallergetUnmarshaller(XMLObject xmlObject) Lookup the unmarshaller for an XMLObject.protected UnmarshallergetUnmarshaller(Element element) Lookup the unmarshaller for a DOM Element.protected voidInit support of XMLObjects.protected DocumentparseXMLDocument(String xmlFilename) Parse an XML file as a classpath resource.protected voidFor convenience when testing, pretty-print the specified XMLObject to a file, or to the console if filename is null.protected voidFor convenience when testing, pretty-print the specified DOM node to a file, or to the console if filename is null.protected <T extends XMLObject>
TunmarshallElement(String elementFile) Unmarshalls an element file into its XMLObject.protected <T extends XMLObject>
TunmarshallElement(String elementFile, boolean propagateErrors) Unmarshalls an element file into its XMLObject.Methods inherited from class org.opensaml.core.testing.OpenSAMLInitBaseTestCase
initOpenSAML
-
Field Details
-
parserPool
Parser pool. -
builderFactory
XMLObject builder factory. -
marshallerFactory
XMLObject marshaller factory. -
unmarshallerFactory
XMLObject unmarshaller factory. -
simpleXMLObjectQName
QName for SimpleXMLObject. -
log
@Nonnull private final org.slf4j.Logger logLogger.
-
-
Constructor Details
-
XMLObjectBaseTestCase
public XMLObjectBaseTestCase()
-
-
Method Details
-
initXMLObjectSupport
Init support of XMLObjects.- Throws:
Exception- on error
-
assertXMLEquals
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 DOMxmlObject- the XMLObject to be marshalled and compared against the expected DOM
-
assertXMLEquals
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 equalexpectedDOM- the expected DOMxmlObject- the XMLObject to be marshalled and compared against the expected DOM
-
buildXMLObject
Builds the requested XMLObject.- Type Parameters:
T- type of the result- Parameters:
name- name of the XMLObject- Returns:
- the built XMLObject
-
unmarshallElement
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
@Nullable protected <T extends XMLObject> T unmarshallElement(@Nonnull 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 unmarshallpropagateErrors- 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
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 printfilename- name of file to print to
-
printXML
For convenience when testing, pretty-print the specified XMLObject to a file, or to the console if filename is null.- Parameters:
xmlObject-XMLObjectto printfilename- name of file to print to
-
getBuilder
Lookup the XMLObjectBuilder for a QName.- Type Parameters:
T- type of result for theXMLObjectBuilder- Parameters:
qname- the QName for which to find the builder- Returns:
- the XMLObjectBuilder
-
getMarshaller
Lookup the marshaller for a QName.- Parameters:
qname- the QName for which to find the marshaller- Returns:
- the marshaller
-
getMarshaller
Lookup the marshaller for an XMLObject.- Parameters:
xmlObject- the XMLObject for which to find the marshaller- Returns:
- the marshaller
-
getUnmarshaller
Lookup the unmarshaller for a QName.- Parameters:
qname- the QName for which to find the unmarshaller- Returns:
- the unmarshaller
-
getUnmarshaller
Lookup the unmarshaller for an XMLObject.- Parameters:
xmlObject- the XMLObject for which to find the unmarshaller- Returns:
- the unmarshaller
-
getUnmarshaller
Lookup the unmarshaller for a DOM Element.- Parameters:
element- the Element for which to find the unmarshaller- Returns:
- the unmarshaller
-
parseXMLDocument
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
-