org.apache.commons.configuration
Class TestPropertiesConfiguration

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

public class TestPropertiesConfiguration
extends Object

Test for loading and saving properties files.

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

Constructor Summary
TestPropertiesConfiguration()
           
 
Method Summary
 void setUp()
           
 void testAppend()
          Tests if properties can be appended by simply calling load() another time.
 void testAppendAndSave()
          Tests appending a configuration to the test configuration.
 void testBackslashEscapingInLists()
          Tests whether backslashes are correctly handled if lists are parsed.
 void testChangingDefaultListDelimiter()
           
 void testChangingListDelimiter()
           
 void testClone()
          Tests whether a properties configuration can be successfully cloned.
 void testCloneNullLayout()
          Tests the clone() method when no layout object exists yet.
 void testComment()
          Test if the lines starting with # or !
 void testCopyAndSave()
          Tests copying another configuration into the test configuration.
 void testDisableListDelimiter()
           
 void testEmpty()
          Tests that empty properties are treated as the empty string (rather than as null).
 void testEscapedKey()
           
 void testEscapedKeyValueSeparator()
          Check that key/value separators can be part of a key.
 void testFileWithSharpSymbol()
          Test the creation of a file containing a '#' in its name.
 void testGetIOFactoryDefault()
          Tests whether a default IOFactory is set.
 void testGetLayout()
          Tests accessing the layout object.
 void testGetStringWithEscapedChars()
           
 void testGetStringWithEscapedComma()
           
 void testIncludeInSubDir()
          Tests including properties when they are loaded from a nested directory structure.
 void testInitFromNonExistingFile()
          Tests initializing a properties configuration from a non existing file.
 void testInMemoryCreatedSave()
           
 void testIsCommentLine()
          Tests whether comment lines are correctly detected.
 void testKeepSeparators()
          Tests that the property separators are retained when saving the configuration.
 void testKeyValueSeparators()
          Test all acceptable key/value separators ('=', ':' or white spaces).
 void testLineSeparator()
          Tests whether the correct line separator is used.
 void testList()
          Tests List parsing.
 void testLoad()
           
 void testLoadFromFile()
           
 void testLoadInclude()
          test if includes properties get loaded too
 void testLoadIncludeFromClassPath()
          Tests if included files are loaded when the source lies in the class path.
 void testLoadIncludeInterpol()
          test if includes properties from interpolated file name get loaded
 void testLoadUnexistingFile()
           
 void testLoadViaProperty()
           
 void testLoadViaPropertyWithBasePath()
           
 void testLoadViaPropertyWithBasePath2()
           
 void testLoadWithAutoSave()
          Tests to load a file with enabled auto save mode.
 void testLoadWithAutoSaveAndAdd()
          Tests the auto save functionality when a new property is added using the addProperty() method.
 void testLoadWithAutoSaveAndClear()
          Tests the auto save functionality when a property is removed.
 void testLoadWithAutoSaveAndSetExisting()
          Tests the auto save functionality when an existing property is modified.
 void testLoadWithAutoSaveAndSetNew()
          Tests the auto save functionality when a new property is added using the setProperty() method.
 void testLoadWithDefaultEncoding()
          Tests whether the correct default encoding is used when loading a properties file.
 void testMixedArray()
           
 void testMultilines()
           
 void testNewLineEscaping()
          Tests escaping of an end of line with a backslash.
 void testPropertyLoaded()
          Tests the propertyLoaded() method for a simple property.
 void testPropertyLoadedInclude()
          Tests the propertyLoaded() method for an include property.
 void testPropertyLoadedIncludeNotAllowed()
          Tests propertyLoaded() for an include property, when includes are disabled.
 void testReentrantReload()
          Tests what happens if a reloading strategy's reloadingRequired() implementation accesses methods of the configuration that in turn cause a reload.
 void testReference()
          Tests that references to other properties work
 void testSave()
           
 void testSaveEscapedEscapingCharacter()
          Tests whether the escape character for list delimiters can be itself escaped and survives a save operation.
 void testSaveMissingFilename()
           
 void testSaveToCustomURL()
           
 void testSaveToHTTPServerFail()
          Tests saving a file-based configuration to a HTTP server when the server reports a failure.
 void testSaveToHTTPServerSuccess()
          Tests saving a file-based configuration to a HTTP server.
 void testSaveWithBasePath()
          Tests if the base path is taken into account by the save() method.
 void testSaveWithDataConfig()
          Tests adding properties through a DataConfiguration.
 void testSaveWithDelimiterParsingDisabled()
          Tests saving a configuration when delimiter parsing is disabled.
 void testSetInclude()
           
 void testSetIOFactoryNull()
          Tests setting the IOFactory to null.
 void testSetIOFactoryReader()
          Tests setting an IOFactory that uses a specialized reader.
 void testSetIOFactoryWriter()
          Tests setting an IOFactory that uses a specialized writer.
 void testSetPropertyListWithDelimiterParsingDisabled()
          Tests whether a list property is handled correctly if delimiter parsing is disabled.
 void testSlashEscaping()
          Tests whether properties with slashes in their values can be saved.
 void testUnescapeJava()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestPropertiesConfiguration

public TestPropertiesConfiguration()
Method Detail

setUp

public void setUp()
           throws Exception
Throws:
Exception

testLoad

public void testLoad()
              throws Exception
Throws:
Exception

testAppend

public void testAppend()
                throws Exception
Tests if properties can be appended by simply calling load() another time.

Throws:
Exception

testEmpty

public void testEmpty()
               throws Exception
Tests that empty properties are treated as the empty string (rather than as null).

Throws:
Exception

testReference

public void testReference()
                   throws Exception
Tests that references to other properties work

Throws:
Exception

testLoadInclude

public void testLoadInclude()
                     throws Exception
test if includes properties get loaded too

Throws:
Exception

testLoadIncludeInterpol

public void testLoadIncludeInterpol()
                             throws Exception
test if includes properties from interpolated file name get loaded

Throws:
Exception

testSetInclude

public void testSetInclude()
                    throws Exception
Throws:
Exception

testList

public void testList()
              throws Exception
Tests List parsing.

Throws:
Exception

testSave

public void testSave()
              throws Exception
Throws:
Exception

testSaveToCustomURL

public void testSaveToCustomURL()
                         throws Exception
Throws:
Exception

testInMemoryCreatedSave

public void testInMemoryCreatedSave()
                             throws Exception
Throws:
Exception

testSaveWithDelimiterParsingDisabled

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

Throws:
ConfigurationException

testSaveMissingFilename

public void testSaveMissingFilename()
                             throws ConfigurationException
Throws:
ConfigurationException

testSaveWithBasePath

public void testSaveWithBasePath()
                          throws Exception
Tests if the base path is taken into account by the save() method.

Throws:
Exception - if an error occurs

testSaveEscapedEscapingCharacter

public void testSaveEscapedEscapingCharacter()
                                      throws ConfigurationException
Tests whether the escape character for list delimiters can be itself escaped and survives a save operation.

Throws:
ConfigurationException

testLoadViaProperty

public void testLoadViaProperty()
                         throws Exception
Throws:
Exception

testLoadViaPropertyWithBasePath

public void testLoadViaPropertyWithBasePath()
                                     throws Exception
Throws:
Exception

testLoadViaPropertyWithBasePath2

public void testLoadViaPropertyWithBasePath2()
                                      throws Exception
Throws:
Exception

testLoadFromFile

public void testLoadFromFile()
                      throws Exception
Throws:
Exception

testLoadUnexistingFile

public void testLoadUnexistingFile()
                            throws ConfigurationException
Throws:
ConfigurationException

testLoadWithAutoSave

public void testLoadWithAutoSave()
                          throws Exception
Tests to load a file with enabled auto save mode.

Throws:
Exception

testLoadWithAutoSaveAndSetExisting

public void testLoadWithAutoSaveAndSetExisting()
                                        throws Exception
Tests the auto save functionality when an existing property is modified.

Throws:
Exception

testLoadWithAutoSaveAndSetNew

public void testLoadWithAutoSaveAndSetNew()
                                   throws Exception
Tests the auto save functionality when a new property is added using the setProperty() method.

Throws:
Exception

testLoadWithAutoSaveAndAdd

public void testLoadWithAutoSaveAndAdd()
                                throws Exception
Tests the auto save functionality when a new property is added using the addProperty() method.

Throws:
Exception

testLoadWithAutoSaveAndClear

public void testLoadWithAutoSaveAndClear()
                                  throws Exception
Tests the auto save functionality when a property is removed.

Throws:
Exception

testGetStringWithEscapedChars

public void testGetStringWithEscapedChars()

testGetStringWithEscapedComma

public void testGetStringWithEscapedComma()

testUnescapeJava

public void testUnescapeJava()

testEscapedKey

public void testEscapedKey()
                    throws Exception
Throws:
Exception

testMixedArray

public void testMixedArray()

testMultilines

public void testMultilines()

testChangingDefaultListDelimiter

public void testChangingDefaultListDelimiter()
                                      throws Exception
Throws:
Exception

testChangingListDelimiter

public void testChangingListDelimiter()
                               throws Exception
Throws:
Exception

testDisableListDelimiter

public void testDisableListDelimiter()
                              throws Exception
Throws:
Exception

testNewLineEscaping

public void testNewLineEscaping()
Tests escaping of an end of line with a backslash.


testLoadIncludeFromClassPath

public void testLoadIncludeFromClassPath()
                                  throws ConfigurationException
Tests if included files are loaded when the source lies in the class path.

Throws:
ConfigurationException

testComment

public void testComment()
Test if the lines starting with # or ! are properly ignored.


testEscapedKeyValueSeparator

public void testEscapedKeyValueSeparator()
Check that key/value separators can be part of a key.


testKeyValueSeparators

public void testKeyValueSeparators()
Test all acceptable key/value separators ('=', ':' or white spaces).


testIncludeInSubDir

public void testIncludeInSubDir()
                         throws ConfigurationException
Tests including properties when they are loaded from a nested directory structure.

Throws:
ConfigurationException

testLineSeparator

public void testLineSeparator()
                       throws ConfigurationException
Tests whether the correct line separator is used.

Throws:
ConfigurationException

testReentrantReload

public void testReentrantReload()
Tests what happens if a reloading strategy's reloadingRequired() implementation accesses methods of the configuration that in turn cause a reload.


testGetLayout

public void testGetLayout()
Tests accessing the layout object.


testPropertyLoaded

public void testPropertyLoaded()
                        throws ConfigurationException
Tests the propertyLoaded() method for a simple property.

Throws:
ConfigurationException

testPropertyLoadedInclude

public void testPropertyLoadedInclude()
                               throws ConfigurationException
Tests the propertyLoaded() method for an include property.

Throws:
ConfigurationException

testPropertyLoadedIncludeNotAllowed

public void testPropertyLoadedIncludeNotAllowed()
                                         throws ConfigurationException
Tests propertyLoaded() for an include property, when includes are disabled.

Throws:
ConfigurationException

testIsCommentLine

public void testIsCommentLine()
Tests whether comment lines are correctly detected.


testClone

public void testClone()
               throws ConfigurationException
Tests whether a properties configuration can be successfully cloned. It is especially checked whether the layout object is taken into account.

Throws:
ConfigurationException

testCloneNullLayout

public void testCloneNullLayout()
Tests the clone() method when no layout object exists yet.


testSaveToHTTPServerSuccess

public void testSaveToHTTPServerSuccess()
                                 throws Exception
Tests saving a file-based configuration to a HTTP server.

Throws:
Exception

testSaveToHTTPServerFail

public void testSaveToHTTPServerFail()
                              throws Exception
Tests saving a file-based configuration to a HTTP server when the server reports a failure. This should cause an exception.

Throws:
Exception

testFileWithSharpSymbol

public void testFileWithSharpSymbol()
                             throws Exception
Test the creation of a file containing a '#' in its name. This test is skipped on Java 1.3 as it always fails.

Throws:
Exception

testInitFromNonExistingFile

public void testInitFromNonExistingFile()
                                 throws ConfigurationException
Tests initializing a properties configuration from a non existing file. There was a bug, which caused properties getting lost when later save() is called.

Throws:
ConfigurationException

testCopyAndSave

public void testCopyAndSave()
                     throws ConfigurationException
Tests copying another configuration into the test configuration. This test ensures that the layout object is informed about the newly added properties.

Throws:
ConfigurationException

testAppendAndSave

public void testAppendAndSave()
                       throws ConfigurationException
Tests appending a configuration to the test configuration. Again it has to be ensured that the layout object is correctly updated.

Throws:
ConfigurationException

testSaveWithDataConfig

public void testSaveWithDataConfig()
                            throws ConfigurationException
Tests adding properties through a DataConfiguration. This is related to CONFIGURATION-332.

Throws:
ConfigurationException

testLoadWithDefaultEncoding

public void testLoadWithDefaultEncoding()
                                 throws ConfigurationException
Tests whether the correct default encoding is used when loading a properties file. This test is related to CONFIGURATION-345.

Throws:
ConfigurationException

testGetIOFactoryDefault

public void testGetIOFactoryDefault()
Tests whether a default IOFactory is set.


testSetIOFactoryNull

public void testSetIOFactoryNull()
Tests setting the IOFactory to null. This should cause an exception.


testSetIOFactoryReader

public void testSetIOFactoryReader()
                            throws ConfigurationException
Tests setting an IOFactory that uses a specialized reader.

Throws:
ConfigurationException

testSetIOFactoryWriter

public void testSetIOFactoryWriter()
                            throws ConfigurationException,
                                   IOException
Tests setting an IOFactory that uses a specialized writer.

Throws:
ConfigurationException
IOException

testKeepSeparators

public void testKeepSeparators()
                        throws ConfigurationException,
                               IOException
Tests that the property separators are retained when saving the configuration.

Throws:
ConfigurationException
IOException

testSlashEscaping

public void testSlashEscaping()
                       throws ConfigurationException
Tests whether properties with slashes in their values can be saved. This test is related to CONFIGURATION-408.

Throws:
ConfigurationException

testBackslashEscapingInLists

public void testBackslashEscapingInLists()
                                  throws Exception
Tests whether backslashes are correctly handled if lists are parsed. This test is related to CONFIGURATION-418.

Throws:
Exception

testSetPropertyListWithDelimiterParsingDisabled

public void testSetPropertyListWithDelimiterParsingDisabled()
                                                     throws ConfigurationException
Tests whether a list property is handled 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.