net.shibboleth.metadata.dom
Class BaseDomTest

java.lang.Object
  extended by net.shibboleth.metadata.dom.BaseDomTest
Direct Known Subclasses:
ContactPersonFilterStageTest, ElementFormattingStageTest, ElementStrippingStageTest, EmptyContainerStrippingStageTest, EntitiesDescriptorAssemblerStageTest, EntitiesDescriptorDisassemblerStageTest, EntityDescriptorItemIdPopulationStageTest, EntityFilterStageTest, EntityRegistrationAuthorityFilterStageTest, EntityRoleFilterStageTest, MultiOutputXSLTtransformationStageTest, NamespaceStrippingStageTest, PullUpCacheDurationStageTest, PullUpValidUntilStageTest, RemoveOrganizationStageTest, ValidateValidUntilStageTest, XMLSignatureSigningStageTest, XMLSignatureValidationStageTest, XPathFilteringStageTest, XPathItemSelectionStrategyTest, XSLTtransformationStageTest, XSLValidationStageTest

public abstract class BaseDomTest
extends Object

A base class for DOM related tests.


Field Summary
private  net.shibboleth.utilities.java.support.xml.BasicParserPool parserPool
          Initialized parser pool used to parser data.
 
Constructor Summary
BaseDomTest()
           
 
Method Summary
 void assertXmlIdentical(Node expected, Node actual)
          Checks whether two nodes are identical based on Diff.identical().
 net.shibboleth.utilities.java.support.xml.ParserPool getParserPool()
          Gets an initialized parser pool.
 Element readTestRelativeXmlData(Class classBeingTested, String dataFile)
          Parses and XML data file located in the resource directory named for the class that is being tested.
 Element readXmlData(String path)
          Reads in an XML file, parses it, and returns the document element.
 void setUp()
          Setup test class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parserPool

private net.shibboleth.utilities.java.support.xml.BasicParserPool parserPool
Initialized parser pool used to parser data.

Constructor Detail

BaseDomTest

public BaseDomTest()
Method Detail

setUp

public void setUp()
           throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
Setup test class. Creates and initializes the parser pool. Set BouncyCastle as a JCE provider.

Throws:
net.shibboleth.utilities.java.support.component.ComponentInitializationException - thrown if there is a problem initializing the parser pool

getParserPool

public net.shibboleth.utilities.java.support.xml.ParserPool getParserPool()
Gets an initialized parser pool.

Returns:
initialized parser pool, never null

readTestRelativeXmlData

public Element readTestRelativeXmlData(Class classBeingTested,
                                       String dataFile)
                                throws net.shibboleth.utilities.java.support.xml.XMLParserException
Parses and XML data file located in the resource directory named for the class that is being tested. For example, for the class net.shibboleth.metadata.dom.saml.RemoveContactPersonStage, the data file will be looked for in src/test/resources/net/shibboleth/metadata/dom/saml/RemoveContactPersonStage/.

Parameters:
classBeingTested - the class that is being unit tested
dataFile - the data file to be loaded in and read
Returns:
the document root element
Throws:
net.shibboleth.utilities.java.support.xml.XMLParserException - thrown if the data file does not exist or is not valid XML

readXmlData

public Element readXmlData(String path)
                    throws net.shibboleth.utilities.java.support.xml.XMLParserException
Reads in an XML file, parses it, and returns the document element. If the given path is relative (i.e., does not start with a '/') it is assumed to be relative to /data.

Parameters:
path - classpath path to the data file, never null
Returns:
the document root of the data file, never null
Throws:
net.shibboleth.utilities.java.support.xml.XMLParserException - thrown if the file does not exists or there is a problem parsing it

assertXmlIdentical

public void assertXmlIdentical(Node expected,
                               Node actual)
Checks whether two nodes are identical based on Diff.identical().

Parameters:
expected - the expected node against which the actual node will be tested, never null
actual - the actual node tested against the expected node, never null


Copyright © 1999-2012. All Rights Reserved.