org.apache.commons.configuration
Class TestDefaultConfigurationBuilder

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.configuration.TestDefaultConfigurationBuilder
All Implemented Interfaces:
junit.framework.Test

public class TestDefaultConfigurationBuilder
extends junit.framework.TestCase

Test class for DefaultConfigurationBuilder.

Version:
$Id: TestDefaultConfigurationBuilder.java 578455 2007-09-22 15:12:16Z oheger $
Author:
Oliver Heger

Constructor Summary
TestDefaultConfigurationBuilder()
           
 
Method Summary
protected  void setUp()
           
 void testAddConfigurationProvider()
          Tests adding a new configuration provider.
 void testAddConfigurationProviderNull()
          Tries to register a null configuration provider.
 void testAddConfigurationProviderNullTag()
          Tries to register a configuration provider for a null tag.
 void testCombinedConfiguration()
          Tests if the returned combined configuration has the expected structure.
 void testCombinedConfigurationListNodes()
          Tests whether the list node definition was correctly processed.
 void testCombinedConfigurationNoAdditional()
          Tests the structure of the returned combined configuration if there is no additional section.
 void testComplexInitialization()
          Tests reading a configuration definition file that contains complex initialization of properties of the declared configuration sources.
 void testConfigurationBeanFactoryCreateBean()
          Tests creating a configuration object from a configuration declaration.
 void testConfigurationBeanFactoryCreateUnknownTag()
          Tests creating a configuration object from an unknown tag.
 void testConfigurationBuilderProvider()
          Tests whether a configuration builder can itself be declared in a configuration definition file.
 void testConfigurationDeclarationGetAttributes()
          Tests access to certain reserved attributes of a ConfigurationDeclaration.
 void testConfigurationDeclarationIsReserved()
          Tests the isReservedNode() method of ConfigurationDeclaration.
 void testConfigurationDeclarationIsReservedAt()
          Tests if the at attribute is correctly detected as reserved attribute.
 void testConfigurationDeclarationIsReservedOptional()
          Tests if the optional attribute is correctly detected as reserved attribute.
 void testLoadAdditional()
          Tests loading a configuration definition file with an additional section.
 void testLoadConfiguration()
          Tests loading a simple configuration definition file.
 void testLoadConfigurationFromFile()
          Tests the file constructor.
 void testLoadConfigurationFromFileName()
          Tests the file name constructor.
 void testLoadConfigurationFromURL()
          Tests the URL constructor.
 void testLoadDifferentSources()
          Tests loading a definition file with multiple different sources.
 void testLoadOptional()
          Tests loading a definition file that contains optional configurations.
 void testLoadOptionalBuilderForceCreate()
          Tests loading an embedded optional configuration builder with the force create attribute.
 void testLoadOptionalErrorEvent()
          Tests whether loading a failing optional configuration causes an error event.
 void testLoadOptionalForceCreate()
          Tests an optional, non existing configuration with the forceCreate attribute.
 void testLoadOptionalForceCreateWithException()
          Tests loading an optional configuration with the force create attribute set.
 void testLoadOptionalNonFileBased()
          Tries to load a configuration file with an optional, non file-based configuration.
 void testLoadOptionalWithException()
          Tests loading a definition file with optional and non optional configuration sources.
 void testLoadXMLWithSettings()
          Tests whether XML settings can be inherited.
 void testLogErrorListener()
          Tests whether a default log error listener is registered at the builder instance.
 void testRemoveConfigurationProvider()
          Tests removing configuration providers.
 void testSetConfigurationBasePath()
          Tests if the base path is correctly evaluated.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestDefaultConfigurationBuilder

public TestDefaultConfigurationBuilder()
Method Detail

setUp

protected void setUp()
              throws java.lang.Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

testConfigurationDeclarationIsReserved

public void testConfigurationDeclarationIsReserved()
Tests the isReservedNode() method of ConfigurationDeclaration.


testConfigurationDeclarationIsReservedAt

public void testConfigurationDeclarationIsReservedAt()
Tests if the at attribute is correctly detected as reserved attribute.


testConfigurationDeclarationIsReservedOptional

public void testConfigurationDeclarationIsReservedOptional()
Tests if the optional attribute is correctly detected as reserved attribute.


testConfigurationDeclarationGetAttributes

public void testConfigurationDeclarationGetAttributes()
Tests access to certain reserved attributes of a ConfigurationDeclaration.


testAddConfigurationProvider

public void testAddConfigurationProvider()
Tests adding a new configuration provider.


testAddConfigurationProviderNull

public void testAddConfigurationProviderNull()
Tries to register a null configuration provider. This should cause an exception.


testAddConfigurationProviderNullTag

public void testAddConfigurationProviderNullTag()
Tries to register a configuration provider for a null tag. This should cause an exception to be thrown.


testRemoveConfigurationProvider

public void testRemoveConfigurationProvider()
Tests removing configuration providers.


testConfigurationBeanFactoryCreateBean

public void testConfigurationBeanFactoryCreateBean()
Tests creating a configuration object from a configuration declaration.


testConfigurationBeanFactoryCreateUnknownTag

public void testConfigurationBeanFactoryCreateUnknownTag()
Tests creating a configuration object from an unknown tag. This should cause an exception.


testLoadConfiguration

public void testLoadConfiguration()
                           throws org.apache.commons.configuration.ConfigurationException
Tests loading a simple configuration definition file.

Throws:
org.apache.commons.configuration.ConfigurationException

testLoadConfigurationFromFile

public void testLoadConfigurationFromFile()
                                   throws org.apache.commons.configuration.ConfigurationException
Tests the file constructor.

Throws:
org.apache.commons.configuration.ConfigurationException

testLoadConfigurationFromFileName

public void testLoadConfigurationFromFileName()
                                       throws org.apache.commons.configuration.ConfigurationException
Tests the file name constructor.

Throws:
org.apache.commons.configuration.ConfigurationException

testLoadConfigurationFromURL

public void testLoadConfigurationFromURL()
                                  throws java.lang.Exception
Tests the URL constructor.

Throws:
java.lang.Exception

testLoadAdditional

public void testLoadAdditional()
                        throws org.apache.commons.configuration.ConfigurationException
Tests loading a configuration definition file with an additional section.

Throws:
org.apache.commons.configuration.ConfigurationException

testLogErrorListener

public void testLogErrorListener()
Tests whether a default log error listener is registered at the builder instance.


testLoadOptional

public void testLoadOptional()
                      throws java.lang.Exception
Tests loading a definition file that contains optional configurations.

Throws:
java.lang.Exception

testLoadOptionalErrorEvent

public void testLoadOptionalErrorEvent()
                                throws java.lang.Exception
Tests whether loading a failing optional configuration causes an error event.

Throws:
java.lang.Exception

testLoadOptionalWithException

public void testLoadOptionalWithException()
Tests loading a definition file with optional and non optional configuration sources. One non optional does not exist, so this should cause an exception.


testLoadOptionalNonFileBased

public void testLoadOptionalNonFileBased()
                                  throws org.apache.commons.configuration.ConfigurationException
Tries to load a configuration file with an optional, non file-based configuration. The optional attribute should work for other configuration classes, too.

Throws:
org.apache.commons.configuration.ConfigurationException

testLoadOptionalForceCreate

public void testLoadOptionalForceCreate()
                                 throws org.apache.commons.configuration.ConfigurationException
Tests an optional, non existing configuration with the forceCreate attribute. This configuration should be added to the resulting configuration.

Throws:
org.apache.commons.configuration.ConfigurationException

testLoadOptionalBuilderForceCreate

public void testLoadOptionalBuilderForceCreate()
                                        throws org.apache.commons.configuration.ConfigurationException
Tests loading an embedded optional configuration builder with the force create attribute.

Throws:
org.apache.commons.configuration.ConfigurationException

testLoadOptionalForceCreateWithException

public void testLoadOptionalForceCreateWithException()
                                              throws org.apache.commons.configuration.ConfigurationException
Tests loading an optional configuration with the force create attribute set. The provider will always throw an exception. In this case the configuration will not be added to the resulting combined configuration.

Throws:
org.apache.commons.configuration.ConfigurationException

testLoadDifferentSources

public void testLoadDifferentSources()
                              throws org.apache.commons.configuration.ConfigurationException
Tests loading a definition file with multiple different sources.

Throws:
org.apache.commons.configuration.ConfigurationException

testSetConfigurationBasePath

public void testSetConfigurationBasePath()
                                  throws org.apache.commons.configuration.ConfigurationException
Tests if the base path is correctly evaluated.

Throws:
org.apache.commons.configuration.ConfigurationException

testComplexInitialization

public void testComplexInitialization()
                               throws org.apache.commons.configuration.ConfigurationException
Tests reading a configuration definition file that contains complex initialization of properties of the declared configuration sources.

Throws:
org.apache.commons.configuration.ConfigurationException

testCombinedConfiguration

public void testCombinedConfiguration()
                               throws org.apache.commons.configuration.ConfigurationException
Tests if the returned combined configuration has the expected structure.

Throws:
org.apache.commons.configuration.ConfigurationException

testCombinedConfigurationNoAdditional

public void testCombinedConfigurationNoAdditional()
                                           throws org.apache.commons.configuration.ConfigurationException
Tests the structure of the returned combined configuration if there is no additional section.

Throws:
org.apache.commons.configuration.ConfigurationException

testCombinedConfigurationListNodes

public void testCombinedConfigurationListNodes()
                                        throws org.apache.commons.configuration.ConfigurationException
Tests whether the list node definition was correctly processed.

Throws:
org.apache.commons.configuration.ConfigurationException

testConfigurationBuilderProvider

public void testConfigurationBuilderProvider()
                                      throws org.apache.commons.configuration.ConfigurationException
Tests whether a configuration builder can itself be declared in a configuration definition file.

Throws:
org.apache.commons.configuration.ConfigurationException

testLoadXMLWithSettings

public void testLoadXMLWithSettings()
                             throws org.apache.commons.configuration.ConfigurationException,
                                    java.io.IOException
Tests whether XML settings can be inherited.

Throws:
org.apache.commons.configuration.ConfigurationException
java.io.IOException


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