commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration TestBasePropertiesConfiguration.java TestClassPropertiesConfiguration.java TestPropertiesConfiguration.java
Date Sat, 11 Jan 2003 00:55:03 GMT
dlr         2003/01/10 16:55:03

  Modified:    configuration project.xml build.xml
               configuration/src/test/org/apache/commons/configuration
                        TestClassPropertiesConfiguration.java
                        TestPropertiesConfiguration.java
  Added:       configuration/src/test/org/apache/commons/configuration
                        TestBasePropertiesConfiguration.java
  Log:
  * project.xml
  * build.xml
    Ignore the new TestBasePropertiesConfiguration.java unit test (it's
    an abstract base class)
  
  * src/test/org/apache/commons/configuration/TestClassPropertiesConfiguration.java
    Made TEST_PROPERTIES static final, rather than an instance field.
    Pushed test code up into the new TestBasePropertiesConfiguration class.
  
  * src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
    Pushed test code up into the new TestBasePropertiesConfiguration class.
    Renamed the local variable "conf" in the testSave() method to
    "toSave" to avoid confusion with super-class variable of the same
    name.
  
  * src/test/org/apache/commons/configuration/TestBasePropertiesConfiguration.java
    New abstract base class containing common unit tests.
  
  Revision  Changes    Path
  1.17      +2 -1      jakarta-commons-sandbox/configuration/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/project.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -u -r1.16 -r1.17
  --- project.xml	1 Jan 2003 02:51:25 -0000	1.16
  +++ project.xml	11 Jan 2003 00:55:02 -0000	1.17
  @@ -138,6 +138,7 @@
       <unitTest>
         <includes>
           <include>**/*Test*.java</include>
  +        <exclude>**/TestBasePropertiesConfiguration.java</exclude>
         </includes>
         <resources>
           <resource>
  
  
  
  1.7       +3 -4      jakarta-commons-sandbox/configuration/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/build.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- build.xml	14 Dec 2002 11:45:17 -0000	1.6
  +++ build.xml	11 Jan 2003 00:55:02 -0000	1.7
  @@ -69,9 +69,8 @@
           <pathelement path="${testclassesdir}"></pathelement>
         </classpath>
         <batchtest todir="${testreportdir}">
  -        <fileset dir="src/test">
  -              
  -              
  +        <fileset dir="src/test"
  +                 excludes="**/TestBasePropertiesConfiguration.java">
           </fileset>
         </batchtest>
       </junit>
  
  
  
  1.4       +9 -37     jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestClassPropertiesConfiguration.java
  
  Index: TestClassPropertiesConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestClassPropertiesConfiguration.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- TestClassPropertiesConfiguration.java	7 Jan 2003 22:53:52 -0000	1.3
  +++ TestClassPropertiesConfiguration.java	11 Jan 2003 00:55:02 -0000	1.4
  @@ -59,56 +59,28 @@
   import junit.framework.TestCase;
   
   /**
  - * test for loading and saving properties files
  + * Tests {@link
  + * org.apache.commons.configuration.ClassPropertiesConfiguration}.
    *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  + * @author <a href="mailto:dlr@apache.org">Daniel Rall</a>
    * @version $Id$
    */
   public class TestClassPropertiesConfiguration
  -    extends TestCase
  +    extends TestBasePropertiesConfiguration
   {
       /** The File that we test with */
  -    private String TEST_PROPERTIES = "test.properties";
  +    private static final String TEST_PROPERTIES = "test.properties";
   
       public TestClassPropertiesConfiguration(String s)
       {
           super(s);
       }
   
  -    public void testLoad()
  -      throws Exception
  +    protected void setUp()
  +        throws Exception
       {
  -        ClassPropertiesConfiguration conf =
  -          new ClassPropertiesConfiguration(this.getClass(), TEST_PROPERTIES);
  -
  -        String loaded = conf.getString("configuration.loaded");
  -        assertEquals("true", loaded);
  -    }
  -
  -    /**
  -     * test if includes properties get loaded too
  -     */
  -    public void testLoadInclude()
  -      throws Exception
  -    {
  -        ClassPropertiesConfiguration conf =
  -          new ClassPropertiesConfiguration(this.getClass(), TEST_PROPERTIES);
  -        String loaded = conf.getString("include.loaded");
  -        assertEquals("true", loaded);
  -    }
  -
  -    /**
  -     * test if includes properties get loaded too
  -     */
  -    public void testVector()
  -      throws Exception
  -    {
  -        ClassPropertiesConfiguration conf =
  -          new ClassPropertiesConfiguration(this.getClass(), TEST_PROPERTIES);
  -
  -        Vector loaded = conf.getVector("packages");
  -        // we should get 3 packages here
  -        assertEquals(3, loaded.size());
  +        conf = new ClassPropertiesConfiguration(getClass(), TEST_PROPERTIES);
       }
   }
  
  
  
  1.5       +9 -39     jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
  
  Index: TestPropertiesConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -u -r1.4 -r1.5
  --- TestPropertiesConfiguration.java	7 Jan 2003 22:53:52 -0000	1.4
  +++ TestPropertiesConfiguration.java	11 Jan 2003 00:55:02 -0000	1.5
  @@ -65,10 +65,11 @@
    *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  + * @author <a href="mailto:dlr@apache.org">Daniel Rall</a>
    * @version $Id$
    */
   public class TestPropertiesConfiguration
  -    extends TestCase
  +    extends TestBasePropertiesConfiguration
   {
       /** The File that we test with */
       private String testProperties = 
  @@ -79,56 +80,25 @@
           super(s);
       }
   
  -    public void testLoad()
  +    protected void setUp()
           throws Exception
       {
  -        PropertiesConfiguration conf =
  -            new PropertiesConfiguration(testProperties);
  -
  -        String loaded = conf.getString("configuration.loaded");
  -        assertEquals("true", loaded);
  -    }
  -
  -    /**
  -     * test if includes properties get loaded too
  -     */
  -    public void testLoadInclude()
  -        throws Exception
  -    {
  -        PropertiesConfiguration conf =
  -            new PropertiesConfiguration(testProperties);
  -
  -        String loaded = conf.getString("include.loaded");
  -        assertEquals("true", loaded);
  -    }
  -
  -    /**
  -     * test if includes properties get loaded too
  -     */
  -    public void testVector()
  -        throws Exception
  -    {
  -        PropertiesConfiguration conf =
  -            new PropertiesConfiguration(testProperties);
  -
  -        Vector loaded = conf.getVector("packages");
  -        // we should get 3 packages here
  -        assertEquals(3, loaded.size());
  +        conf = new PropertiesConfiguration(testProperties);
       }
   
       public void testSave()
           throws Exception
       {
  -        PropertiesConfiguration conf = new PropertiesConfiguration();
  -        conf.addProperty("string", "value1");
  +        PropertiesConfiguration toSave = new PropertiesConfiguration();
  +        toSave.addProperty("string", "value1");
           Vector vec = new Vector();
           for (int i = 1; i < 5; i++)
           {
               vec.add("value" + i);
           }
  -        conf.addProperty("array", vec);
  +        toSave.addProperty("array", vec);
           String filename = "STRING0";
   
  -        conf.save(filename);
  +        toSave.save(filename);
       }
   }
  
  
  
  1.1                  jakarta-commons-sandbox/configuration/src/test/org/apache/commons/configuration/TestBasePropertiesConfiguration.java
  
  Index: TestBasePropertiesConfiguration.java
  ===================================================================
  package org.apache.commons.configuration;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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", "Commons", 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 apache@apache.org.
   *
   * 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/>.
   */
  
  import java.util.Vector;
  
  import junit.framework.TestCase;
  
  /**
   * A base class for testing {@link
   * org.apache.commons.configuration.BasePropertiesConfiguration}
   * extensions.
   *
   * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
   * @author <a href="mailto:dlr@apache.org">Daniel Rall</a>
   * @version $Id: TestBasePropertiesConfiguration.java,v 1.1 2003/01/11 00:55:02 dlr Exp
$
   */
  public abstract class TestBasePropertiesConfiguration
      extends TestCase
  {
      protected BasePropertiesConfiguration conf;
  
      public TestBasePropertiesConfiguration(String s)
      {
          super(s);
      }
  
      /**
       * Assigns the {@link #conf} field to a {@link
       * org.apache.commons.configuration.BasePropertiesConfiguration}
       * sub-class.
       */
      protected abstract void setUp()
          throws Exception;
  
      public void testLoad()
        throws Exception
      {
          String loaded = conf.getString("configuration.loaded");
          assertEquals("true", loaded);
      }
  
      /**
       * test if includes properties get loaded too
       */
      public void testLoadInclude()
        throws Exception
      {
          String loaded = conf.getString("include.loaded");
          assertEquals("true", loaded);
      }
  
      /**
       * Tests <code>Vector</code> parsing.
       */
      public void testVector()
        throws Exception
      {
          Vector packages = conf.getVector("packages");
          // we should get 3 packages here
          assertEquals(3, packages.size());
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message