org.apache.commons.configuration
Class TestXMLConfiguration

java.lang.Object
  extended by org.apache.commons.configuration.TestXMLConfiguration

public class TestXMLConfiguration
extends Object

test for loading and saving xml properties files

Version:
$Id: TestXMLConfiguration.java 1330666 2012-04-26 06:12:30Z oheger $

Constructor Summary
TestXMLConfiguration()
           
 
Method Summary
 void setUp()
           
 void testAddAttribute()
           
 void testAddList()
           
 void testAddNodesAndSave()
          Tests saving a configuration after a node was added.
 void testAddNodesAttributeNode()
          Tests adding an attribute node using the addNodes() method.
 void testAddNodesCopy()
          Tests adding nodes from another configuration.
 void testAddNodesToSubnodeConfiguration()
          Tests whether it is possible to add nodes to a XMLConfiguration through a SubnodeConfiguration and whether these nodes have the correct type.
 void testAddObjectAttribute()
           
 void testAddObjectProperty()
           
 void testAddProperty()
           
 void testAddPropertyListWithDelimiterParsingDisabled()
          Tests whether list properties are added correctly if delimiter parsing is disabled.
 void testAppend()
          Tests if a second file can be appended to a first.
 void testAttributeSplittingAndDelimiterParsingDisabled()
          Tests disabling both delimiter parsing and attribute splitting.
 void testAttributeSplittingDisabled()
          Tests whether attribute splitting can be disabled.
 void testAutoSave()
           
 void testAutoSaveAddNodes()
          Tests whether the addNodes() method triggers an auto save.
 void testAutoSaveWithReloadingStrategy()
          Tests a combination of auto save = true and an associated reloading strategy.
 void testAutoSaveWithSubnodeConfig()
          Tests whether the auto save mechanism is triggered by changes at a subnode configuration.
 void testAutoSaveWithSubSubnodeConfig()
          Tests whether a subnode configuration created from another subnode configuration of a XMLConfiguration can trigger the auto save mechanism.
 void testClearAttribute()
           
 void testClearProperty()
           
 void testClearTextRootElement()
          Tests removing the text of the root element.
 void testClone()
          Tests the clone() method.
 void testCloneWithSave()
          Tests saving a configuration after cloning to ensure that the clone and the original are completely detached.
 void testComplexNames()
          Tests access to tag names with delimiter characters.
 void testConcurrentGetAndReload()
           
 void testConfigurationAtWithReload()
          Tests if reloads are recognized by configurationAt().
 void testConfigurationsAtWithReload()
          Tests if reloads are recognized by configurationsAt().
 void testCopyRootName()
          Tests whether the name of the root element is copied when a configuration is created using the copy constructor.
 void testCopyRootNameNoDocument()
          Tests whether the name of the root element is copied for a configuration for which not yet a document exists.
 void testCustomDocBuilder()
          Tests setting a custom document builder.
 void testCustomDocBuilderValidationError()
          Tests whether a validating document builder detects a validation error.
 void testCustomDocBuilderValidationSuccess()
          Tests whether a valid document can be loaded with a validating document builder.
 void testDelimiterParsingDisabled()
          Tests string properties with list delimiters when delimiter parsing is disabled
 void testDelimiterParsingDisabledMultiAttrValues()
          Tests multiple attribute values in delimiter parsing disabled mode.
 void testDtd()
          Tests whether a DTD can be accessed.
 void testEmptyAttribute()
          Tests whether an attribute can be set to an empty string.
 void testEmptyElements()
          Tests handling of empty elements.
 void testEmptyReload()
          Tests the isEmpty() method for an empty configuration that was reloaded.
 void testGetAttribute()
           
 void testGetCommentedProperty()
           
 void testGetComplexProperty()
           
 void testGetKeysWithReload()
          Tests whether reloads are recognized when querying the configuration's keys.
 void testgetProperty()
           
 void testGetProperty()
           
 void testGetPropertyWithXMLEntity()
           
 void testGetRootReference()
          Tests whether the configuration's root node is initialized with a reference to the corresponding XML element.
 void testInitCopy()
          Tests the copy constructor.
 void testListWithAttributes()
          Tests list nodes with multiple values and attributes.
 void testListWithAttributesMultiValue()
          Tests a list node with attributes that has multiple values separated by the list delimiter.
 void testListWithMultiAttributesMultiValue()
          Tests a list node with a multi-value attribute and multiple values.
 void testLoad()
           
 void testLoadAndSaveFromFile()
          Tests constructing an XMLConfiguration from a non existing file and later saving to this file.
 void testLoadFromStream()
          Tests loading from a stream.
 void testLoadFromURL()
          Tests loading a configuration from a URL.
 void testLoadInvalidXML()
          Tests loading a non well formed XML from a string.
 void testLoadWithBasePath()
           
 void testLoadWithEncoding()
          Tests whether the encoding is correctly detected by the XML parser.
 void testMultipleAttrValuesEscaped()
          Tests using multiple attribute values, which are partly escaped when delimiter parsing is not disabled.
 void testPreserveSpace()
          Tests whether spaces are preserved when the xml:space attribute is set.
 void testPreserveSpaceInvalid()
          Tests an xml:space attribute with an invalid value.
 void testPreserveSpaceOverride()
          Tests whether the xml:space attribute can be overridden in nested elements.
 void testRefresh()
          Tests the refresh() method.
 void testRefreshNoFile()
          Tries to call refresh() when the configuration is not associated with a file.
 void testRegisterEntityId()
          Tests registering the publicId of a DTD.
 void testRegisterEntityIdNull()
          Tries to register a null public ID.
 void testReloading()
          Tests collaboration between XMLConfiguration and a reloading strategy.
 void testReloadingOOM()
           
 void testSave()
           
 void testSaveAfterCreateWithCopyConstructor()
          Tests saving a configuration that was created from a hierarchical configuration.
 void testSaveAttributes()
          Tests saving attributes (related to issue 34442).
 void testSaveDelimiterParsingDisabled()
          Tests saving and loading a configuration when delimiter parsing is disabled.
 void testSaveDelimiterParsingDisabledAttrs()
          Tests saving and loading a configuration when delimiter parsing is disabled and attributes are involved.
 void testSaveToStream()
          Tests saving to a stream.
 void testSaveToURL()
          Tests saving to a URL.
 void testSaveWindowsPath()
          Tests whether a windows path can be saved correctly.
 void testSaveWithDelimiterParsingDisabled()
          Tests string properties with list delimiters when delimiter parsing is disabled
 void testSaveWithDoctype()
          Tests whether the DOCTYPE survives a save operation.
 void testSaveWithDoctypeIDs()
          Tests setting public and system IDs for the D'OCTYPE and then saving the configuration.
 void testSaveWithEncoding()
          Tests whether the encoding is written to the generated XML file.
 void testSaveWithInvalidTransformerFactory()
          Tests saving a configuration when an invalid transformer factory is specified.
 void testSaveWithNullEncoding()
          Tests whether a default encoding is used if no specific encoding is set.
 void testSaveWithValidation()
          Tests modifying an XML document and saving it with schema validation enabled.
 void testSaveWithValidationFailure()
          Tests modifying an XML document and validating it against the schema.
 void testSetAttribute()
           
 void testSetProperty()
           
 void testSetPropertyListWithDelimiterParsingDisabled()
          Tests whether list properties are set correctly if delimiter parsing is disabled.
 void testSetRootAttribute()
          Tests setting an attribute on the root element.
 void testSetTextRootElement()
          Tests setting text of the root element.
 void testSettingFileNames()
           
 void testSplitLists()
          Tests string properties with list delimiters and escaped delimiters.
 void testSubset()
          Tests the subset() method.
 void testSubsetWithReload()
          Tests if reloads are recognized by subset().
 void testValidating()
          Tests DTD validation using the setValidating() method.
 void testXPathExpressionEngine()
          Tests accessing properties when the XPATH expression engine is set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestXMLConfiguration

public TestXMLConfiguration()
Method Detail

setUp

public void setUp()
           throws Exception
Throws:
Exception

testGetProperty

public void testGetProperty()

testGetCommentedProperty

public void testGetCommentedProperty()

testGetPropertyWithXMLEntity

public void testGetPropertyWithXMLEntity()

testClearProperty

public void testClearProperty()
                       throws Exception
Throws:
Exception

testgetProperty

public void testgetProperty()

testGetAttribute

public void testGetAttribute()

testClearAttribute

public void testClearAttribute()
                        throws Exception
Throws:
Exception

testSetAttribute

public void testSetAttribute()

testAddAttribute

public void testAddAttribute()

testAddObjectAttribute

public void testAddObjectAttribute()

testSetRootAttribute

public void testSetRootAttribute()
                          throws ConfigurationException
Tests setting an attribute on the root element.

Throws:
ConfigurationException

testGetRootReference

public void testGetRootReference()
Tests whether the configuration's root node is initialized with a reference to the corresponding XML element.


testAddList

public void testAddList()

testGetComplexProperty

public void testGetComplexProperty()

testSettingFileNames

public void testSettingFileNames()

testLoad

public void testLoad()
              throws Exception
Throws:
Exception

testLoadWithBasePath

public void testLoadWithBasePath()
                          throws Exception
Throws:
Exception

testLoadAndSaveFromFile

public void testLoadAndSaveFromFile()
                             throws Exception
Tests constructing an XMLConfiguration from a non existing file and later saving to this file.

Throws:
Exception

testLoadFromURL

public void testLoadFromURL()
                     throws Exception
Tests loading a configuration from a URL.

Throws:
Exception

testLoadFromStream

public void testLoadFromStream()
                        throws Exception
Tests loading from a stream.

Throws:
Exception

testLoadInvalidXML

public void testLoadInvalidXML()
                        throws Exception
Tests loading a non well formed XML from a string.

Throws:
Exception

testSetProperty

public void testSetProperty()
                     throws Exception
Throws:
Exception

testAddProperty

public void testAddProperty()

testAddObjectProperty

public void testAddObjectProperty()

testSave

public void testSave()
              throws Exception
Throws:
Exception

testSaveToURL

public void testSaveToURL()
                   throws Exception
Tests saving to a URL.

Throws:
Exception

testSaveToStream

public void testSaveToStream()
                      throws Exception
Tests saving to a stream.

Throws:
Exception

testAutoSave

public void testAutoSave()
                  throws Exception
Throws:
Exception

testAppend

public void testAppend()
                throws Exception
Tests if a second file can be appended to a first.

Throws:
Exception

testSaveAttributes

public void testSaveAttributes()
                        throws Exception
Tests saving attributes (related to issue 34442).

Throws:
Exception

testReloading

public void testReloading()
                   throws Exception
Tests collaboration between XMLConfiguration and a reloading strategy.

Throws:
Exception

testReloadingOOM

public void testReloadingOOM()
                      throws Exception
Throws:
Exception

testRefresh

public void testRefresh()
                 throws ConfigurationException
Tests the refresh() method.

Throws:
ConfigurationException

testRefreshNoFile

public void testRefreshNoFile()
                       throws ConfigurationException
Tries to call refresh() when the configuration is not associated with a file.

Throws:
ConfigurationException

testComplexNames

public void testComplexNames()
Tests access to tag names with delimiter characters.


testCustomDocBuilder

public void testCustomDocBuilder()
                          throws Exception
Tests setting a custom document builder.

Throws:
Exception

testCustomDocBuilderValidationError

public void testCustomDocBuilderValidationError()
                                         throws Exception
Tests whether a validating document builder detects a validation error.

Throws:
Exception

testCustomDocBuilderValidationSuccess

public void testCustomDocBuilderValidationSuccess()
                                           throws Exception
Tests whether a valid document can be loaded with a validating document builder.

Throws:
Exception

testClone

public void testClone()
Tests the clone() method.


testCloneWithSave

public void testCloneWithSave()
                       throws ConfigurationException
Tests saving a configuration after cloning to ensure that the clone and the original are completely detached.

Throws:
ConfigurationException

testSubset

public void testSubset()
                throws ConfigurationException
Tests the subset() method. There was a bug that calling subset() had undesired side effects.

Throws:
ConfigurationException

testSplitLists

public void testSplitLists()
Tests string properties with list delimiters and escaped delimiters.


testDelimiterParsingDisabled

public void testDelimiterParsingDisabled()
                                  throws ConfigurationException
Tests string properties with list delimiters when delimiter parsing is disabled

Throws:
ConfigurationException

testSaveWithDelimiterParsingDisabled

public void testSaveWithDelimiterParsingDisabled()
                                          throws ConfigurationException
Tests string properties with list delimiters when delimiter parsing is disabled

Throws:
ConfigurationException

testDtd

public void testDtd()
             throws ConfigurationException
Tests whether a DTD can be accessed.

Throws:
ConfigurationException

testValidating

public void testValidating()
                    throws ConfigurationException
Tests DTD validation using the setValidating() method.

Throws:
ConfigurationException

testEmptyElements

public void testEmptyElements()
                       throws ConfigurationException
Tests handling of empty elements.

Throws:
ConfigurationException

testEmptyReload

public void testEmptyReload()
                     throws ConfigurationException
Tests the isEmpty() method for an empty configuration that was reloaded.

Throws:
ConfigurationException

testLoadWithEncoding

public void testLoadWithEncoding()
                          throws ConfigurationException
Tests whether the encoding is correctly detected by the XML parser. This is done by loading an XML file with the encoding "UTF-16". If this encoding is not detected correctly, an exception will be thrown that "Content is not allowed in prolog". This test case is related to issue 34204.

Throws:
ConfigurationException

testSaveWithEncoding

public void testSaveWithEncoding()
                          throws ConfigurationException
Tests whether the encoding is written to the generated XML file.

Throws:
ConfigurationException

testSaveWithNullEncoding

public void testSaveWithNullEncoding()
                              throws ConfigurationException
Tests whether a default encoding is used if no specific encoding is set. According to the XSLT specification (http://www.w3.org/TR/xslt#output) this should be either UTF-8 or UTF-16.

Throws:
ConfigurationException

testSaveWithDoctype

public void testSaveWithDoctype()
                         throws ConfigurationException
Tests whether the DOCTYPE survives a save operation.

Throws:
ConfigurationException

testSaveWithDoctypeIDs

public void testSaveWithDoctypeIDs()
                            throws ConfigurationException
Tests setting public and system IDs for the D'OCTYPE and then saving the configuration. This should generate a DOCTYPE declaration.

Throws:
ConfigurationException

testSaveWithInvalidTransformerFactory

public void testSaveWithInvalidTransformerFactory()
Tests saving a configuration when an invalid transformer factory is specified. In this case the error thrown by the TransformerFactory class should be caught and re-thrown as a ConfigurationException.


testSubsetWithReload

public void testSubsetWithReload()
                          throws ConfigurationException
Tests if reloads are recognized by subset().

Throws:
ConfigurationException

testConfigurationAtWithReload

public void testConfigurationAtWithReload()
                                   throws ConfigurationException
Tests if reloads are recognized by configurationAt().

Throws:
ConfigurationException

testConfigurationsAtWithReload

public void testConfigurationsAtWithReload()
                                    throws ConfigurationException
Tests if reloads are recognized by configurationsAt().

Throws:
ConfigurationException

testGetKeysWithReload

public void testGetKeysWithReload()
                           throws ConfigurationException
Tests whether reloads are recognized when querying the configuration's keys.

Throws:
ConfigurationException

testXPathExpressionEngine

public void testXPathExpressionEngine()
Tests accessing properties when the XPATH expression engine is set.


testInitCopy

public void testInitCopy()
                  throws ConfigurationException
Tests the copy constructor.

Throws:
ConfigurationException

testSetTextRootElement

public void testSetTextRootElement()
                            throws ConfigurationException
Tests setting text of the root element.

Throws:
ConfigurationException

testClearTextRootElement

public void testClearTextRootElement()
                              throws ConfigurationException
Tests removing the text of the root element.

Throws:
ConfigurationException

testListWithAttributes

public void testListWithAttributes()
Tests list nodes with multiple values and attributes.


testListWithAttributesMultiValue

public void testListWithAttributesMultiValue()
Tests a list node with attributes that has multiple values separated by the list delimiter. In this scenario the attribute should be added to the node with the first value.


testListWithMultiAttributesMultiValue

public void testListWithMultiAttributesMultiValue()
Tests a list node with a multi-value attribute and multiple values. All attribute values should be assigned to the node with the first value.


testAutoSaveWithSubnodeConfig

public void testAutoSaveWithSubnodeConfig()
                                   throws ConfigurationException
Tests whether the auto save mechanism is triggered by changes at a subnode configuration.

Throws:
ConfigurationException

testAutoSaveWithSubSubnodeConfig

public void testAutoSaveWithSubSubnodeConfig()
                                      throws ConfigurationException
Tests whether a subnode configuration created from another subnode configuration of a XMLConfiguration can trigger the auto save mechanism.

Throws:
ConfigurationException

testSaveDelimiterParsingDisabled

public void testSaveDelimiterParsingDisabled()
                                      throws ConfigurationException
Tests saving and loading a configuration when delimiter parsing is disabled.

Throws:
ConfigurationException

testSaveDelimiterParsingDisabledAttrs

public void testSaveDelimiterParsingDisabledAttrs()
                                           throws ConfigurationException
Tests saving and loading a configuration when delimiter parsing is disabled and attributes are involved.

Throws:
ConfigurationException

testDelimiterParsingDisabledMultiAttrValues

public void testDelimiterParsingDisabledMultiAttrValues()
                                                 throws ConfigurationException
Tests multiple attribute values in delimiter parsing disabled mode.

Throws:
ConfigurationException

testMultipleAttrValuesEscaped

public void testMultipleAttrValuesEscaped()
                                   throws ConfigurationException
Tests using multiple attribute values, which are partly escaped when delimiter parsing is not disabled.

Throws:
ConfigurationException

testAutoSaveWithReloadingStrategy

public void testAutoSaveWithReloadingStrategy()
                                       throws ConfigurationException
Tests a combination of auto save = true and an associated reloading strategy.

Throws:
ConfigurationException

testAddNodesCopy

public void testAddNodesCopy()
                      throws ConfigurationException
Tests adding nodes from another configuration.

Throws:
ConfigurationException

testAutoSaveAddNodes

public void testAutoSaveAddNodes()
                          throws ConfigurationException
Tests whether the addNodes() method triggers an auto save.

Throws:
ConfigurationException

testAddNodesAndSave

public void testAddNodesAndSave()
                         throws ConfigurationException
Tests saving a configuration after a node was added. Test for CONFIGURATION-294.

Throws:
ConfigurationException

testRegisterEntityId

public void testRegisterEntityId()
                          throws Exception
Tests registering the publicId of a DTD.

Throws:
Exception

testRegisterEntityIdNull

public void testRegisterEntityIdNull()
                              throws IOException
Tries to register a null public ID. This should cause an exception.

Throws:
IOException

testSaveAfterCreateWithCopyConstructor

public void testSaveAfterCreateWithCopyConstructor()
                                            throws ConfigurationException
Tests saving a configuration that was created from a hierarchical configuration. This test exposes bug CONFIGURATION-301.

Throws:
ConfigurationException

testCopyRootName

public void testCopyRootName()
                      throws ConfigurationException
Tests whether the name of the root element is copied when a configuration is created using the copy constructor.

Throws:
ConfigurationException

testCopyRootNameNoDocument

public void testCopyRootNameNoDocument()
                                throws ConfigurationException
Tests whether the name of the root element is copied for a configuration for which not yet a document exists.

Throws:
ConfigurationException

testAddNodesAttributeNode

public void testAddNodesAttributeNode()
Tests adding an attribute node using the addNodes() method.


testPreserveSpace

public void testPreserveSpace()
Tests whether spaces are preserved when the xml:space attribute is set.


testPreserveSpaceOverride

public void testPreserveSpaceOverride()
Tests whether the xml:space attribute can be overridden in nested elements.


testPreserveSpaceInvalid

public void testPreserveSpaceInvalid()
Tests an xml:space attribute with an invalid value. This will be interpreted as default.


testAttributeSplittingDisabled

public void testAttributeSplittingDisabled()
                                    throws ConfigurationException
Tests whether attribute splitting can be disabled.

Throws:
ConfigurationException

testAttributeSplittingAndDelimiterParsingDisabled

public void testAttributeSplittingAndDelimiterParsingDisabled()
                                                       throws ConfigurationException
Tests disabling both delimiter parsing and attribute splitting.

Throws:
ConfigurationException

testSaveWithValidation

public void testSaveWithValidation()
                            throws Exception
Tests modifying an XML document and saving it with schema validation enabled.

Throws:
Exception

testSaveWithValidationFailure

public void testSaveWithValidationFailure()
                                   throws Exception
Tests modifying an XML document and validating it against the schema.

Throws:
Exception

testConcurrentGetAndReload

public void testConcurrentGetAndReload()
                                throws Exception
Throws:
Exception

testSaveWindowsPath

public void testSaveWindowsPath()
                         throws ConfigurationException
Tests whether a windows path can be saved correctly. This test is related to CONFIGURATION-428.

Throws:
ConfigurationException

testEmptyAttribute

public void testEmptyAttribute()
                        throws ConfigurationException
Tests whether an attribute can be set to an empty string. This test is related to CONFIGURATION-446.

Throws:
ConfigurationException

testAddNodesToSubnodeConfiguration

public void testAddNodesToSubnodeConfiguration()
                                        throws Exception
Tests whether it is possible to add nodes to a XMLConfiguration through a SubnodeConfiguration and whether these nodes have the correct type. This test is related to CONFIGURATION-472.

Throws:
Exception

testSetPropertyListWithDelimiterParsingDisabled

public void testSetPropertyListWithDelimiterParsingDisabled()
                                                     throws ConfigurationException
Tests whether list properties are set correctly if delimiter parsing is disabled. This test is related to CONFIGURATION-495.

Throws:
ConfigurationException

testAddPropertyListWithDelimiterParsingDisabled

public void testAddPropertyListWithDelimiterParsingDisabled()
                                                     throws ConfigurationException
Tests whether list properties are added correctly if delimiter parsing is disabled. This test is related to CONFIGURATION-495.

Throws:
ConfigurationException


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.