epugh       2003/11/12 03:27:08

  Modified:    configuration/xdocs changes.xml
  Added:       configuration/impl/src/test configuration.xml
               configuration/impl maven.xml LICENSE.txt project.xml
               configuration/impl/src/java/org/apache/fulcrum/configuration
                        DefaultConfigurationService.java package.html
               configuration/impl/conf block.xml config.xml
               configuration/impl/src/test/org/apache/fulcrum/configuration
                        ConfigTest.java
               configuration/impl/src/test/org test.properties test.xml
  Log:
  New Merlin tweak configuration object.  API is provided by commons-configuration,
  the implementation is here.
  
  Revision  Changes    Path
  1.1                  
jakarta-turbine-fulcrum/configuration/impl/src/test/configuration.xml
  
  Index: configuration.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  
  <configuration>
    <properties 
       className="org.apache.commons.configuration.PropertiesConfiguration" 
       fileName="../../src/test/org/test.properties"/>
    <dom4j 
       className="org.apache.commons.configuration.DOM4JConfiguration" 
       fileName="../../src/test/org/test.xml"/>
  </configuration>
  
    
    
  
  
  
  
  
  
  1.1                  jakarta-turbine-fulcrum/configuration/impl/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project default="jar:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core" 
xmlns:util="jelly:util">
  
    <preGoal name="java:compile">
      <attainGoal name="avalon:meta"/>
    </preGoal>
  
  </project>
  
  
  1.1                  jakarta-turbine-fulcrum/configuration/impl/LICENSE.txt
  
  Index: LICENSE.txt
  ===================================================================
  /* ----------------------------------------------------------------------------
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Plexus", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ----------------------------------------------------------------------------
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ----------------------------------------------------------------------------
   */
  
  
  
  1.1                  jakarta-turbine-fulcrum/configuration/impl/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <project>
  
    <id>fulcrum-configuration-impl</id>
    <extend>${basedir}/../../project.xml</extend>
    <name>Fulcrum Configuration Impl</name>
    <currentVersion>1.0-alpha-2</currentVersion>
    <package>org.apache.fulcrum.configuration</package>
  
    <dependencies>
      <dependency>
        <groupId>avalon-framework</groupId>
        <artifactId>avalon-framework-api</artifactId>
        <version>4.1.5</version>
      </dependency>
      <dependency>
        <id>commons-configuration</id>
        <version>20030706.202021</version>
        <url>http://jakarta.apache.org/commons/sandbox/configuration/index.html</url>
      </dependency>
      <dependency>
        <id>commons-digester</id>      
        <version>1.5</version>
        <properties>        
          <war.bundle.jar>true</war.bundle.jar>
        </properties>            
      </dependency>
      <dependency>
        <id>commons-logging</id>
        <version>1.0.3</version>
        <url>http://jakarta.apache.org/commons/logging.html</url>
      </dependency>
      <dependency>
        <id>commons-collections</id>
        <version>2.1</version>
        <url>http://jakarta.apache.org/commons/collections.html</url>
      </dependency>
      <dependency>
        <id>commons-lang</id>
        <version>2.0</version>
      </dependency> 
      <dependency>
        <id>dom4j</id>
        <version>1.3</version>
        <properties>        
          <war.bundle.jar>true</war.bundle.jar>
        </properties>            
      </dependency>
      <dependency>
        <id>commons-beanutils</id>      
        <version>1.7-dev</version>
        <properties>        
          <war.bundle.jar>true</war.bundle.jar>
        </properties>            
      </dependency>       
  
      <!-- testing -->
  
      <dependency>
        <groupId>merlin</groupId>
        <artifactId>merlin-unit</artifactId>
        <version>3.2.2-dev</version>
      </dependency>
  
    </dependencies>
  
  </project>
  
  
  
  
  1.2       +5 -0      jakarta-turbine-fulcrum/configuration/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/configuration/xdocs/changes.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- changes.xml       27 Oct 2003 16:53:40 -0000      1.1
  +++ changes.xml       12 Nov 2003 11:27:07 -0000      1.2
  @@ -7,6 +7,11 @@
   
     <body>
       <release version="1.0-alpha-1" date="">
  +       <action dev="epugh" type="update">
  +        Integrated Stephen McConnell's refactoring.  Removed
  +        API project as the API is provided by the Commons-Configuration
  +        Configuration.java class.
  +      </action>      
         <action dev="epugh" type="add">
           Initial creation of project.
         </action>
  
  
  
  1.1                  
jakarta-turbine-fulcrum/configuration/impl/src/java/org/apache/fulcrum/configuration/DefaultConfigurationService.java
  
  Index: DefaultConfigurationService.java
  ===================================================================
  package org.apache.fulcrum.configuration;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  import java.io.File;
  import java.util.Iterator;
  import java.util.Properties;
  import java.util.Vector;
  
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.commons.configuration.ConfigurationFactory;
  
  /**
   * Starts up a commons configuration Configuration object via an
   * Avalon container.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Eric Pugh</a>
   * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
   * @version $Id: DefaultConfigurationService.java,v 1.1 2003/11/12 11:27:07 epugh 
Exp $
   * @avalon.component name="config" lifestyle="singleton"
   * @avalon.service type="org.apache.commons.configuration.Configuration"
   */
  public class DefaultConfigurationService
      extends AbstractLogEnabled
      implements org.apache.commons.configuration.Configuration, Configurable, 
Contextualizable
  {
      /**
         * The property specifying the location where to read in the configuration
         * path from.
         */
      String CONFIGURATION_PATH = "configurationPath";
  
      /** The Avalon Context */
      private Context context = null;
  
      private String applicationRoot;
  
      private org.apache.commons.configuration.Configuration configuration;
  
      /**
         * @see org.apache.commons.configuration.Configuration
         */
      public void addProperty(String arg0, Object arg1)
      {
          configuration.addProperty(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         */
      public void clearProperty(String arg0)
      {
          configuration.clearProperty(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public boolean containsKey(String arg0)
      {
          return configuration.containsKey(arg0);
      }
  
      /*
         * (non-Javadoc)
         * 
         * @see java.lang.Object#equals(java.lang.Object)
         */
      public boolean equals(Object obj)
      {
          return configuration.equals(obj);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public boolean getBoolean(String arg0)
      {
          return configuration.getBoolean(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public boolean getBoolean(String arg0, boolean arg1)
      {
          return configuration.getBoolean(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Boolean getBoolean(String arg0, Boolean arg1)
      {
          return configuration.getBoolean(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public byte getByte(String arg0)
      {
          return configuration.getByte(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public byte getByte(String arg0, byte arg1)
      {
          return configuration.getByte(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Byte getByte(String arg0, Byte arg1)
      {
          return configuration.getByte(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public double getDouble(String arg0)
      {
          return configuration.getDouble(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public double getDouble(String arg0, double arg1)
      {
          return configuration.getDouble(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Double getDouble(String arg0, Double arg1)
      {
          return configuration.getDouble(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public float getFloat(String arg0)
      {
          return configuration.getFloat(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public float getFloat(String arg0, float arg1)
      {
          return configuration.getFloat(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Float getFloat(String arg0, Float arg1)
      {
          return configuration.getFloat(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public int getInt(String arg0)
      {
          return configuration.getInt(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public int getInt(String arg0, int arg1)
      {
          return configuration.getInt(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Integer getInteger(String arg0, Integer arg1)
      {
          return configuration.getInteger(arg0, arg1);
      }
  
      /**
       * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Iterator getKeys()
      {
          return configuration.getKeys();
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Iterator getKeys(String arg0)
      {
          return configuration.getKeys(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public long getLong(String arg0)
      {
          return configuration.getLong(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Long getLong(String arg0, Long arg1)
      {
          return configuration.getLong(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public long getLong(String arg0, long arg1)
      {
          return configuration.getLong(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Properties getProperties(String arg0)
      {
          return configuration.getProperties(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Object getProperty(String arg0)
      {
          return configuration.getProperty(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public short getShort(String arg0)
      {
          return configuration.getShort(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Short getShort(String arg0, Short arg1)
      {
          return configuration.getShort(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public short getShort(String arg0, short arg1)
      {
          return configuration.getShort(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public String getString(String arg0)
      {
          return configuration.getString(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public String getString(String arg0, String arg1)
      {
          return configuration.getString(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public String[] getStringArray(String arg0)
      {
          return configuration.getStringArray(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Vector getVector(String arg0)
      {
          return configuration.getVector(arg0);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public Vector getVector(String arg0, Vector arg1)
      {
          return configuration.getVector(arg0, arg1);
      }
  
      /*
         * (non-Javadoc)
         * 
         * @see java.lang.Object#hashCode()
         */
      public int hashCode()
      {
          return configuration.hashCode();
      }
  
      /**
       * @see org.apache.commons.configuration.Configuration
         * @return
         */
      public boolean isEmpty()
      {
          return configuration.isEmpty();
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         */
      public void setProperty(String arg0, Object arg1)
      {
          configuration.setProperty(arg0, arg1);
      }
  
      /**
         * @see org.apache.commons.configuration.Configuration
         */
      public org.apache.commons.configuration.Configuration subset(String arg0)
      {
          return configuration.subset(arg0);
      }
  
      /*
         * (non-Javadoc)
         * 
         * @see java.lang.Object#toString()
         */
      public String toString()
      {
          return configuration.toString();
      }
  
      /**
       * Avalon component lifecycle method
       */
      public void configure(Configuration conf) throws ConfigurationException
      {
          String confPath = conf.getAttribute(CONFIGURATION_PATH);
          File confFile = new File(confPath);
          if(!confFile.exists()){
              confFile = new File(applicationRoot,confPath);
          }
          if(!confFile.exists()){            
              throw new ConfigurationException("XML file for ConfigurationFactory can 
not be found:" +confFile);
          }
  
          ConfigurationFactory configurationFactory =
              new ConfigurationFactory(confFile.getAbsolutePath());
          configurationFactory.setBasePath(applicationRoot);
          try
          {
              configuration = configurationFactory.getConfiguration();
          }
          catch (Exception e)
          {
              throw new ConfigurationException(
                  "Problem loading Configuration with Factory.",
                  e);
          }
  
      }
  
      /**
       * @see org.apache.avalon.framework.context.Contextualizable
       */
      public void contextualize(Context context) throws ContextException
      {
          this.context = context;
          this.applicationRoot = context.get( "urn:avalon:home" ).toString();
      }
  
  }
  
  
  
  1.1                  
jakarta-turbine-fulcrum/configuration/impl/src/java/org/apache/fulcrum/configuration/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  <!-- head part is ignored -->
  </head>
  
  <body>
  Generic confiugration implementation.
  <br>
  <font size="-2">$Id: package.html,v 1.1 2003/11/12 11:27:07 epugh Exp $</font>
  </body>
  </html>
  
  
  
  1.1                  jakarta-turbine-fulcrum/configuration/impl/conf/block.xml
  
  Index: block.xml
  ===================================================================
  
  <container name="config">
  
     <classloader>
       <classpath>
         <repository>
           <!--<resource id="fulcrum:fulcrum-configuration-api" 
version="1.0-alpha-2"/>-->
         </repository>
       </classpath>
     </classloader>
  
     <services>
       <service type="org.apache.commons.configuration.Configuration">
         <source>config</source>
       </service>
     </services>
  
     <component name="conf" 
       class="org.apache.fulcrum.configuration.DefaultConfigurationService"/>
  
  </container>
  
  
  
  1.1                  jakarta-turbine-fulcrum/configuration/impl/conf/config.xml
  
  Index: config.xml
  ===================================================================
  
  <targets>
  
    <target path="/config/conf">
      <categories priority="INFO"/>
      <configuration configurationPath="../../src/test/configuration.xml"/>
    </target>
  
  </targets>
  
  
  
  1.1                  
jakarta-turbine-fulcrum/configuration/impl/src/test/org/apache/fulcrum/configuration/ConfigTest.java
  
  Index: ConfigTest.java
  ===================================================================
  package org.apache.fulcrum.configuration;
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.merlin.unit.AbstractMerlinTestCase;
  import org.apache.commons.configuration.Configuration;
  
  import junit.framework.TestSuite;
  
  /**
   * Basic testing of the Container
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Eric Pugh</a>
   * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
   * @version $Id: ConfigTest.java,v 1.1 2003/11/12 11:27:08 epugh Exp $
   */
  public class ConfigTest extends AbstractMerlinTestCase
  {
      private Configuration config = null;
      
      /**
       * Constructor for test.
       *
       * @param testName name of the test being executed
       */
      public ConfigTest(String name)
      {
          super( 
            MAVEN_TARGET_CLASSES_DIR, 
            MERLIN_DEFAULT_CONFIG_FILE, 
            MERLIN_INFO_OFF, 
            MERLIN_DEBUG_OFF, 
            name );
      }
      /**
       * Factory method for creating a TestSuite for this class.
       *
       * @return the test suite
       */
      public static TestSuite suite()
      {
          TestSuite suite = new TestSuite(ConfigTest.class);
          return suite;
      }
      public void setUp() throws Exception
      {
          super.setUp();
          try
          {
              config = (Configuration) this.resolve( "conf" );
          }
          catch (ComponentException e)
          {
              e.printStackTrace();
              fail(e.getMessage());
          }
      }
      
      /**
       * Verifies that the ConfigurationFactory works properly.
       *
       */
      public void testLoad()
      {
          assertEquals(10.25,config.getDouble("test.double"),0);
          assertEquals(
            "I'm complex!",config.getString("element2.subelement.subsubelement"));
          getLogger().info( "OK" );
      }
     
  }
  
  
  
  1.1                  
jakarta-turbine-fulcrum/configuration/impl/src/test/org/test.properties
  
  Index: test.properties
  ===================================================================
  configuration.loaded = true
  
  packages = packagea
  
  
  #
  # Other test properties
  #
  
  test.equals = value=one
  
  test.empty=
  
  #
  # Test a property that uses a previous property
  #
  base=base
  base.reference=${base}extra
  
  #
  # Non String Properties
  #
  
  test.boolean       = true
  test.boolean.array = false
  test.boolean.array = true
  
  test.byte       = 10
  test.byte.array = 20
  test.byte.array = 30
  
  test.double       = 10.25
  test.double.array = 20.35
  test.double.array = 30.45
  
  test.float       = 20.25
  test.float.array = 30.35
  test.float.array = 40.45
  
  test.integer       = 10
  test.integer.array = 20
  test.integer.array = 30
  
  test.long       = 1000000
  test.long.array = 2000000
  test.long.array = 3000000
  
  test.short       = 1
  test.short.array = 2
  test.short.array = 3
  
  test.overwrite       = 1
  
  
  1.1                  jakarta-turbine-fulcrum/configuration/impl/src/test/org/test.xml
  
  Index: test.xml
  ===================================================================
  <baseElement>
    <element>value</element>
    <element2>
      <subelement>
        <subsubelement>I'm complex!</subsubelement>
      </subelement>
    </element2>
    <test>
        <short>8</short>
    </test>
  </baseElement>
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to