org.apache.commons.configuration
Class TestFileConfiguration

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

public class TestFileConfiguration
extends Object

Version:
$Id: TestFileConfiguration.java 1231721 2012-01-15 18:32:07Z oheger $
Author:
Emmanuel Bourg

Field Summary
 org.junit.rules.TemporaryFolder folder
          Helper object for managing temporary files.
 
Constructor Summary
TestFileConfiguration()
           
 
Method Summary
 void setUp()
          Initializes the test environment.
protected  void tearDown()
          Performs cleanup after a test case.
 void testClone()
          Tests cloning a file based configuration.
 void testCreateFile1()
           
 void testCreateFile2()
           
 void testCreateFile3()
           
 void testFileOverwrite()
          Tests if the URL used by the load() method is also used by save().
 void testGetFile()
          Tests the getFile() method.
 void testGetFileAfterLoad()
          Tests whether getFile() returns a valid file after a configuration has been loaded.
 void testInitFromClassPath()
          Tests whether the constructor behaves the same as setFileName() when the configuration source is in the classpath.
 void testIterationWithReloadFlat()
          Tests iterating over the keys of a non hierarchical file-based configuration while a reload happens.
 void testIterationWithReloadHierarchical()
          Tests iterating over the keys of a hierarchical file-based configuration while a reload happens.
 void testLoadDirectoryConstrFile()
          Tests that it is not possible to load a directory using the File constructor.
 void testLoadDirectoryConstrString()
          Tests that it is not possible to load a directory using the String constructor.
 void testLoadDirectoryFile()
          Tests that it is not possible to load a directory using the load() method which expects a File.
 void testLoadDirectoryString()
          Checks that loading a directory instead of a file throws an exception.
 void testLoadFromClassPath()
          Tests the loading of configuration file in a Combined configuration when the configuration source is in the classpath.
 void testLoadMultiple()
          Tests whether calling load() multiple times changes the source.
 void testLocations()
           
 void testLogErrorListener()
          Tests whether an error log listener was registered at the configuration.
 void testPathWithPlus()
          Tests whether file names containing a "+" character are handled correctly.
 void testPathWithSpaces()
          Tests loading and saving a configuration file with a complicated path name including spaces.
 void testRefresh()
          Tests whether a configuration can be refreshed.
 void testRefreshNoFile()
          Tests refresh if the configuration is not associated with a file.
 void testReloadError()
          Tests handling of errors in the reload() method.
 void testReloadingWithAutoSave()
          Tests setting a file changed reloading strategy together with the auto save feature.
 void testSaveInvalidURL()
          Tests if invalid URLs cause an exception.
 void testSaveInvalidURLString()
          Tests if an invalid URL string causes an exception.
 void testSaveWithoutFileNameFile()
           
 void testSaveWithoutFileNameURL()
           
 void testSetURL()
           
 void testSetURLWithParams()
           
 void testWithConfigurationFactory()
          Tests collaboration with ConfigurationFactory: Is the base path set on loading is valid in file based configurations?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

folder

public org.junit.rules.TemporaryFolder folder
Helper object for managing temporary files.

Constructor Detail

TestFileConfiguration

public TestFileConfiguration()
Method Detail

setUp

public void setUp()
           throws Exception
Initializes the test environment. This implementation ensures that the test output file does not exist.

Throws:
Exception

tearDown

protected void tearDown()
                 throws Exception
Performs cleanup after a test case. This implementation removes temporary files that have been created.

Throws:
Exception

testSetURL

public void testSetURL()
                throws Exception
Throws:
Exception

testSetURLWithParams

public void testSetURLWithParams()
                          throws Exception
Throws:
Exception

testLocations

public void testLocations()
                   throws Exception
Throws:
Exception

testCreateFile1

public void testCreateFile1()
                     throws Exception
Throws:
Exception

testCreateFile2

public void testCreateFile2()
                     throws Exception
Throws:
Exception

testCreateFile3

public void testCreateFile3()
                     throws Exception
Throws:
Exception

testWithConfigurationFactory

public void testWithConfigurationFactory()
                                  throws Exception
Tests collaboration with ConfigurationFactory: Is the base path set on loading is valid in file based configurations?

Throws:
Exception - if an error occurs

testSaveInvalidURL

public void testSaveInvalidURL()
                        throws Exception
Tests if invalid URLs cause an exception.

Throws:
Exception

testSaveInvalidURLString

public void testSaveInvalidURLString()
                              throws ConfigurationException
Tests if an invalid URL string causes an exception.

Throws:
ConfigurationException

testFileOverwrite

public void testFileOverwrite()
                       throws Exception
Tests if the URL used by the load() method is also used by save().

Throws:
Exception

testReloadingWithAutoSave

public void testReloadingWithAutoSave()
                               throws Exception
Tests setting a file changed reloading strategy together with the auto save feature.

Throws:
Exception

testPathWithSpaces

public void testPathWithSpaces()
                        throws Exception
Tests loading and saving a configuration file with a complicated path name including spaces. (related to issue 35210)

Throws:
Exception

testPathWithPlus

public void testPathWithPlus()
                      throws ConfigurationException,
                             IOException
Tests whether file names containing a "+" character are handled correctly. This test is related to CONFIGURATION-415.

Throws:
ConfigurationException
IOException

testGetFile

public void testGetFile()
                 throws ConfigurationException
Tests the getFile() method.

Throws:
ConfigurationException

testGetFileAfterLoad

public void testGetFileAfterLoad()
                          throws ConfigurationException,
                                 IOException
Tests whether getFile() returns a valid file after a configuration has been loaded.

Throws:
ConfigurationException
IOException

testLoadMultiple

public void testLoadMultiple()
                      throws ConfigurationException
Tests whether calling load() multiple times changes the source. This should not be the case.

Throws:
ConfigurationException

testSaveWithoutFileNameFile

public void testSaveWithoutFileNameFile()
                                 throws Exception
Throws:
Exception

testSaveWithoutFileNameURL

public void testSaveWithoutFileNameURL()
                                throws Exception
Throws:
Exception

testLoadDirectoryString

public void testLoadDirectoryString()
                             throws ConfigurationException
Checks that loading a directory instead of a file throws an exception.

Throws:
ConfigurationException

testLoadDirectoryFile

public void testLoadDirectoryFile()
                           throws ConfigurationException
Tests that it is not possible to load a directory using the load() method which expects a File.

Throws:
ConfigurationException

testLoadDirectoryConstrString

public void testLoadDirectoryConstrString()
                                   throws ConfigurationException
Tests that it is not possible to load a directory using the String constructor.

Throws:
ConfigurationException

testLoadDirectoryConstrFile

public void testLoadDirectoryConstrFile()
                                 throws ConfigurationException
Tests that it is not possible to load a directory using the File constructor.

Throws:
ConfigurationException

testInitFromClassPath

public void testInitFromClassPath()
                           throws ConfigurationException
Tests whether the constructor behaves the same as setFileName() when the configuration source is in the classpath.

Throws:
ConfigurationException

testLoadFromClassPath

public void testLoadFromClassPath()
                           throws ConfigurationException
Tests the loading of configuration file in a Combined configuration when the configuration source is in the classpath.

Throws:
ConfigurationException

testClone

public void testClone()
               throws ConfigurationException
Tests cloning a file based configuration.

Throws:
ConfigurationException

testLogErrorListener

public void testLogErrorListener()
Tests whether an error log listener was registered at the configuration.


testReloadError

public void testReloadError()
                     throws ConfigurationException
Tests handling of errors in the reload() method.

Throws:
ConfigurationException

testIterationWithReloadFlat

public void testIterationWithReloadFlat()
                                 throws ConfigurationException
Tests iterating over the keys of a non hierarchical file-based configuration while a reload happens. This test is related to CONFIGURATION-347.

Throws:
ConfigurationException

testIterationWithReloadHierarchical

public void testIterationWithReloadHierarchical()
                                         throws ConfigurationException
Tests iterating over the keys of a hierarchical file-based configuration while a reload happens. This test is related to CONFIGURATION-347.

Throws:
ConfigurationException

testRefresh

public void testRefresh()
                 throws ConfigurationException
Tests whether a configuration can be refreshed.

Throws:
ConfigurationException

testRefreshNoFile

public void testRefreshNoFile()
                       throws ConfigurationException
Tests refresh if the configuration is not associated with a file.

Throws:
ConfigurationException


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