You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by cr...@apache.org on 2002/12/28 04:56:30 UTC

cvs commit: jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/tests ConfigurationReaderTest.java FileResourcesExposerFactory.java FileResourcesTest.java

craigmcc    2002/12/27 19:56:30

  Modified:    resources build.xml
               resources/src/java/org/apache/commons/resources/impl
                        ResourceBundleResources.java
                        ResourceBundleResourcesFactory.java
               resources/src/test/org/apache/commons/resources/junit
                        XMLConfigurationReaderTestCase.java
               resources/src/test/org/apache/commons/resources/tests
                        ConfigurationReaderTest.java
                        FileResourcesExposerFactory.java
                        FileResourcesTest.java
  Added:       resources/src/test/org/apache/commons/resources/impl
                        ResourceBundleResourcesFactoryTestCase.java
                        ResourceBundleResourcesTestCase.java
                        ResourcesBaseTestCase.java
                        ResourcesFactoryBaseTestCase.java
                        TestResources.java TestResources.properties
                        TestResourcesFactory.java
                        TestResources_en.properties
                        TestResources_en_US.properties
                        TestResources_fr.properties
  Log:
  Add unit tests for the new ResourceBundleResources{,Factory} combination,
  plus basic tests on ResourcesBase and ResourcesFactoryBase.
  
  Revision  Changes    Path
  1.16      +2 -2      jakarta-commons-sandbox/resources/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/build.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- build.xml	27 Dec 2002 21:15:18 -0000	1.15
  +++ build.xml	28 Dec 2002 03:56:29 -0000	1.16
  @@ -436,7 +436,7 @@
   
         <batchtest>
           <fileset dir="${build.home}/tests"
  -            includes="org/apache/commons/resources/junit/*TestCase.class"/>
  +            includes="org/apache/commons/resources/impl/*TestCase.class"/>
         </batchtest>
   
       </junit>
  
  
  
  1.2       +4 -20     jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources/impl/ResourceBundleResources.java
  
  Index: ResourceBundleResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources/impl/ResourceBundleResources.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResourceBundleResources.java	28 Dec 2002 00:56:24 -0000	1.1
  +++ ResourceBundleResources.java	28 Dec 2002 03:56:29 -0000	1.2
  @@ -104,7 +104,7 @@
        */
       public ResourceBundleResources(String name, String base) {
   
  -        this.name = name;
  +        super(name);
           this.base = base;
   
       }
  @@ -131,12 +131,6 @@
       protected Map bundles = new HashMap();
   
   
  -    /**
  -     * <p>The logical name of this {@link Resources} instance.</p>
  -     */
  -    protected String name = null;
  -
  -
       // ------------------------------------------------------ Lifecycle Methods
   
   
  @@ -172,16 +166,6 @@
       public String getBase() {
   
           return (this.base);
  -
  -    }
  -
  -
  -    /**
  -     * <p>Return the logical name of this {@link Resources} instance.</p>
  -     */
  -    public String getName() {
  -
  -        return (this.name);
   
       }
   
  
  
  
  1.2       +3 -13     jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources/impl/ResourceBundleResourcesFactory.java
  
  Index: ResourceBundleResourcesFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources/impl/ResourceBundleResourcesFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResourceBundleResourcesFactory.java	28 Dec 2002 00:56:24 -0000	1.1
  +++ ResourceBundleResourcesFactory.java	28 Dec 2002 03:56:29 -0000	1.2
  @@ -86,16 +86,6 @@
   public class ResourceBundleResourcesFactory extends ResourcesFactoryBase {
       
   
  -    // ----------------------------------------------------- Instance Variables
  -
  -
  -    /**
  -     * <p>The set of {@link Resources} instances previously created by
  -     * this {@link ResourcesFactory}, keyed by logical name.</p>
  -     */
  -    protected Map resources = new HashMap();
  -
  -
       // --------------------------------------------------------- Public Methods
   
   
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesFactoryTestCase.java
  
  Index: ResourceBundleResourcesFactoryTestCase.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesFactoryTestCase.java,v 1.1 2002/12/28 03:56:29 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/12/28 03:56:29 $
   *
   * ====================================================================
   *
   * 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/>.
   *
   */
  
  
  package org.apache.commons.resources.impl;
  
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.commons.resources.Resources;
  import org.apache.commons.resources.ResourcesException;
  import org.apache.commons.resources.ResourcesFactory;
  import org.apache.commons.resources.impl.ResourceBundleResourcesFactory;
  
  
  /**
   * <p>Unit tests for
   * <code>org.apache.commons.resources.impl.ResourceBundleResourcesFactory</code>.
   * </p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/12/28 03:56:29 $
   */
  
  public class ResourceBundleResourcesFactoryTestCase extends TestCase {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      // Configuration value for our resource bundles
      protected static final String CONFIG = "org.apache.commons.resources.impl.TestResources";
  
      // Logical name of the Resources instance to be created
      protected static final String NAME = "name";
  
  
      // The <code>ResourcesFactory</code> instance to be tested.
      protected ResourcesFactory factory = null;
  
  
      // ----------------------------------------------------------- Constructors
  
  
      public ResourceBundleResourcesFactoryTestCase(String name) {
          super(name);
      }
  
  
      // --------------------------------------------------- Overall Test Methods
  
  
      // Set up instance variables required by this test case
      public void setUp() throws Exception {
          factory = new ResourceBundleResourcesFactory();
      }
  
      // Return the tests included in this test suite
      public static Test suite() {
          return (new TestSuite(ResourceBundleResourcesFactoryTestCase.class));
      }
  
      // Tear down the instance variables required by this test case
      public void tearDown() {
          factory = null;
      }
  
  
      // ------------------------------------------------ Individual Test Methods
  
  
      // Test the characteristics of a newly created instance
      public void testPristine() {
          assertNotNull(factory);
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesTestCase.java
  
  Index: ResourceBundleResourcesTestCase.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesTestCase.java,v 1.1 2002/12/28 03:56:29 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/12/28 03:56:29 $
   *
   * ====================================================================
   *
   * 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/>.
   *
   */
  
  
  package org.apache.commons.resources.impl;
  
  
  import java.util.Locale;
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.commons.resources.Resources;
  import org.apache.commons.resources.ResourcesException;
  import org.apache.commons.resources.ResourcesFactory;
  import org.apache.commons.resources.impl.ResourceBundleResources;
  
  
  /**
   * <p>Unit tests for
   * <code>org.apache.commons.resources.impl.ResourceBundleResources</code>.
   * </p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/12/28 03:56:29 $
   */
  
  public class ResourceBundleResourcesTestCase
      extends ResourceBundleResourcesFactoryTestCase {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      // The Resources instance to be tested
      protected Resources resources = null;
  
  
      // ----------------------------------------------------------- Constructors
  
  
      public ResourceBundleResourcesTestCase(String name) {
          super(name);
      }
  
  
      // --------------------------------------------------- Overall Test Methods
  
  
      // Set up instance variables required by this test case
      public void setUp() throws Exception {
          super.setUp();
          resources = factory.getResources(NAME, CONFIG);
      }
  
      // Return the tests included in this test suite
      public static Test suite() {
          return (new TestSuite(ResourceBundleResourcesTestCase.class));
      }
  
      // Tear down the instance variables required by this test case
      public void tearDown() {
          resources = null;
          super.tearDown();
      }
  
  
      // ------------------------------------------------ Individual Test Methods
  
  
      // Test retrieving Strings that should be inherited from parent Locales
      public void testInherit() throws Exception {
  
          Locale locale = null;
  
          locale = new Locale("en", "US");
          assertEquals("en_US inherit value",
                       "[en] INHERIT",
                       resources.getString("test.inherit", locale, null));
  
          locale = new Locale("fr", "FR");
          assertEquals("fr_FR inherit value",
                       "[fr] INHERIT",
                       resources.getString("test.inherit", locale, null));
  
      }
  
  
      // Test retrieving missing resource keys
      public void testMissing() throws Exception {
  
          Locale locale = new Locale("en");
          try {
              String value = resources.getString("test.missing", locale, null);
              fail("Should have thrown ResourcesException");
          } catch (ResourcesException e) {
              ; // Expected result
          }
  
      }
  
  
      // Test the characteristics of a newly created instance
      public void testPristine() {
          assertNotNull(resources);
          assertEquals("Correct name", NAME, resources.getName());
          assertEquals("Correct base", CONFIG,
                       ((ResourceBundleResources) resources).getBase());
      }
  
  
      // Test retrieving Locale-specific Strings explicitly
      public void testSpecific() throws Exception {
  
          Locale locale = null;
  
          locale = new Locale("en");
          assertEquals("en specific value",
                       "[en] SPECIFIC",
                       resources.getString("test.specific", locale, null));
  
          locale = new Locale("en", "US");
          assertEquals("en_US specific value",
                       "[en_US] SPECIFIC",
                       resources.getString("test.specific", locale, null));
  
          locale = new Locale("fr");
          assertEquals("fr specific value",
                       "[fr] SPECIFIC",
                       resources.getString("test.specific", locale, null));
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourcesBaseTestCase.java
  
  Index: ResourcesBaseTestCase.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourcesBaseTestCase.java,v 1.1 2002/12/28 03:56:29 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/12/28 03:56:29 $
   *
   * ====================================================================
   *
   * 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/>.
   *
   */
  
  
  package org.apache.commons.resources.impl;
  
  
  import java.util.Locale;
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.commons.resources.Resources;
  import org.apache.commons.resources.ResourcesException;
  import org.apache.commons.resources.ResourcesFactory;
  import org.apache.commons.resources.impl.ResourcesBase;
  
  
  /**
   * <p>Unit tests for
   * <code>org.apache.commons.resources.impl.ResourcesBase</code>.
   * </p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/12/28 03:56:29 $
   */
  
  public class ResourcesBaseTestCase extends ResourcesFactoryBaseTestCase {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      // The Resources instance to be tested
      protected Resources resources = null;
  
  
      // ----------------------------------------------------------- Constructors
  
  
      public ResourcesBaseTestCase(String name) {
          super(name);
      }
  
  
      // --------------------------------------------------- Overall Test Methods
  
  
      // Set up instance variables required by this test case
      public void setUp() throws Exception {
          super.setUp();
          resources = factory.getResources(NAME);
      }
  
      // Return the tests included in this test suite
      public static Test suite() {
          return (new TestSuite(ResourcesBaseTestCase.class));
      }
  
      // Tear down the instance variables required by this test case
      public void tearDown() {
          resources = null;
          super.tearDown();
      }
  
  
      // ------------------------------------------------ Individual Test Methods
  
  
      // Test retrieving Strings that should be inherited from parent Locales
      public void testInherit() throws Exception {
  
          Locale locale = null;
  
          locale = new Locale("en", "US");
          assertEquals("en_US inherit value",
                       "[test] INHERIT",
                       resources.getString("test.inherit", locale, null));
  
          locale = new Locale("fr", "FR");
          assertEquals("fr_FR inherit value",
                       "[test] INHERIT",
                       resources.getString("test.inherit", locale, null));
  
      }
  
  
      // Test retrieving missing resource keys
      public void testMissing() throws Exception {
  
          Locale locale = new Locale("en");
          try {
              String value = resources.getString("test.missing", locale, null);
              fail("Should have thrown ResourcesException");
          } catch (ResourcesException e) {
              ; // Expected result
          }
  
      }
  
  
      // Test the characteristics of a newly created instance
      public void testPristine() {
          assertNotNull(resources);
          assertEquals("Correct name", NAME, resources.getName());
          assertTrue("Resources initialized",
                     ((TestResources) resources).isInitialized());
      }
  
  
      // Test that releasing should destroy instances
      public void testRelease() throws Exception {
          factory.release();
          assertTrue("Resources destroyed",
                     !((TestResources) resources).isInitialized());
      }
  
  
      // Test retrieving Locale-specific Strings explicitly
      public void testSpecific() throws Exception {
  
          Locale locale = null;
  
          locale = new Locale("en");
          assertEquals("en specific value",
                       "[test] SPECIFIC",
                       resources.getString("test.specific", locale, null));
  
          locale = new Locale("en", "US");
          assertEquals("en_US specific value",
                       "[test] SPECIFIC",
                       resources.getString("test.specific", locale, null));
  
          locale = new Locale("fr");
          assertEquals("fr specific value",
                       "[test] SPECIFIC",
                       resources.getString("test.specific", locale, null));
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourcesFactoryBaseTestCase.java
  
  Index: ResourcesFactoryBaseTestCase.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourcesFactoryBaseTestCase.java,v 1.1 2002/12/28 03:56:29 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/12/28 03:56:29 $
   *
   * ====================================================================
   *
   * 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/>.
   *
   */
  
  
  package org.apache.commons.resources.impl;
  
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.commons.resources.Resources;
  import org.apache.commons.resources.ResourcesException;
  import org.apache.commons.resources.ResourcesFactory;
  import org.apache.commons.resources.impl.TestResourcesFactory;
  
  
  /**
   * <p>Unit tests for
   * <code>org.apache.commons.resources.impl.ResourcesFactoryBase</code>.
   * </p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/12/28 03:56:29 $
   */
  
  public class ResourcesFactoryBaseTestCase extends TestCase {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      // Logical name of the Resources instance to be created
      protected static final String NAME = "name";
  
  
      // The <code>ResourcesFactory</code> instance to be tested.
      protected ResourcesFactory factory = null;
  
  
      // ----------------------------------------------------------- Constructors
  
  
      public ResourcesFactoryBaseTestCase(String name) {
          super(name);
      }
  
  
      // --------------------------------------------------- Overall Test Methods
  
  
      // Set up instance variables required by this test case
      public void setUp() throws Exception {
          factory = new TestResourcesFactory();
      }
  
      // Return the tests included in this test suite
      public static Test suite() {
          return (new TestSuite(ResourcesFactoryBaseTestCase.class));
      }
  
      // Tear down the instance variables required by this test case
      public void tearDown() {
          factory = null;
      }
  
  
      // ------------------------------------------------ Individual Test Methods
  
  
      // Test the characteristics of a newly created instance
      public void testPristine() {
          assertNotNull(factory);
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/TestResources.java
  
  Index: TestResources.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/TestResources.java,v 1.1 2002/12/28 03:56:29 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/12/28 03:56:29 $
   *
   * ====================================================================
   *
   * 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/>.
   *
   */
  
  
  package org.apache.commons.resources.impl;
  
  
  import java.io.ByteArrayInputStream;
  import java.io.InputStream;
  import java.io.Reader;
  import java.io.StringReader;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Locale;
  import java.util.Map;
  import java.util.MissingResourceException;
  import java.util.ResourceBundle;
  import java.util.TimeZone;
  import org.apache.commons.resources.Resources;
  import org.apache.commons.resources.ResourcesException;
  
  
  /**
   * <p>Concrete implementation of {@link Resources} for unit tests.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/12/28 03:56:29 $
   */
  
  public class TestResources extends ResourcesBase {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      // Construct a test instance with the specified name
      public TestResources(String name) {
          super(name);
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      // Has this instance been initialized?
      protected boolean initialized = false;
  
  
      // Map of resource String values
      protected Map map = new HashMap();
  
  
      // ------------------------------------------------------ Lifecycle Methods
  
  
      // Initialize this Resources instance
      public void init() throws ResourcesException {
  
          super.init();
          map.put("test.specific", "[test] SPECIFIC");
          map.put("test.inherit", "[test] INHERIT");
          initialized = true;
  
      }
  
  
      // Destroy this Resources instance
      public void destroy() throws ResourcesException {
  
          super.destroy();
          map.clear();
          initialized = false;
  
      }
  
  
      // ------------------------------------------------------------- Properties
  
  
      // Has this instance been initialized?
      public boolean isInitialized() {
          return (this.initialized);
      }
  
  
      // ---------------------------------------------- Content Retrieval Methods
  
  
      /**
       * <p>Return the content for the specified <code>key</code> as a
       * byte array, localized based on the specified <code>locale</code>
       * and/or <code>timeZone</code>.</p>
       *
       * @param key Identifier for the requested content
       * @param locale Locale with which to localize retrieval,
       *  or <code>null</code> for the default Locale
       * @param timeZone TimeZone with which to localize retrieval,
       *  or <code>null</code> for the default TimeZone
       *
       * @exception ResourcesException if an error occurs retrieving or
       *  returning the requested content
       */
      public byte[] getBytes(String key, Locale locale, TimeZone timeZone)
          throws ResourcesException {
  
          throw new UnsupportedOperationException(); // FIXME
  
      }
  
  
      /**
       * <p>Return the content for the specified <code>key</code> as an
       * InputStream, localized based on the specified <code>locale</code>
       * and/or <code>timeZone</code>.</p>
       *
       * @param key Identifier for the requested content
       * @param locale Locale with which to localize retrieval,
       *  or <code>null</code> for the default Locale
       * @param timeZone TimeZone with which to localize retrieval,
       *  or <code>null</code> for the default TimeZone
       *
       * @exception ResourcesException if an error occurs retrieving or
       *  returning the requested content
       */
      public InputStream getInputStream(String key, Locale locale,
                                        TimeZone timeZone)
          throws ResourcesException {
  
          throw new UnsupportedOperationException();  // FIXME
  
      }
  
  
      /**
       * <p>Return the content for the specified <code>key</code> as an
       * Object, localized based on the specified <code>locale</code>
       * and/or <code>timeZone</code>.</p>
       *
       * @param key Identifier for the requested content
       * @param locale Locale with which to localize retrieval,
       *  or <code>null</code> for the default Locale
       * @param timeZone TimeZone with which to localize retrieval,
       *  or <code>null</code> for the default TimeZone
       *
       * @exception ResourcesException if an error occurs retrieving or
       *  returning the requested content
       */
      public Object getObject(String key, Locale locale, TimeZone timeZone)
          throws ResourcesException {
  
          throw new UnsupportedOperationException(); // FIXME
  
      }
  
  
      /**
       * <p>Return the content for the specified <code>key</code> as a
       * Reader, localized based on the specified <code>locale</code>
       * and/or <code>timeZone</code>.</p>
       *
       * @param key Identifier for the requested content
       * @param locale Locale with which to localize retrieval,
       *  or <code>null</code> for the default Locale
       * @param timeZone TimeZone with which to localize retrieval,
       *  or <code>null</code> for the default TimeZone
       *
       * @exception ResourcesException if an error occurs retrieving or
       *  returning the requested content
       */
      public Reader getReader(String key, Locale locale, TimeZone timeZone)
          throws ResourcesException {
  
          throw new UnsupportedOperationException(); // FIXME
  
      }
  
  
      /**
       * <p>Return the content for the specified <code>key</code> as a
       * String, localized based on the specified <code>locale</code>
       * and/or <code>timeZone</code>.</p>
       *
       * @param key Identifier for the requested content
       * @param locale Locale with which to localize retrieval,
       *  or <code>null</code> for the default Locale
       * @param timeZone TimeZone with which to localize retrieval,
       *  or <code>null</code> for the default TimeZone
       *
       * @exception ResourcesException if an error occurs retrieving or
       *  returning the requested content
       */
      public String getString(String key, Locale locale, TimeZone timeZone)
          throws ResourcesException {
  
          String value = (String) map.get(key);
          if (value == null) {
              throw new ResourcesException("Missing key '" + key + "'");
          }
          return (value);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/TestResources.properties
  
  Index: TestResources.properties
  ===================================================================
  test.base=[Base] ONLY
  test.specific=[Base] SPECIFIC
  test.inherit=[Base] INHERIT
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/TestResourcesFactory.java
  
  Index: TestResourcesFactory.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/TestResourcesFactory.java,v 1.1 2002/12/28 03:56:29 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/12/28 03:56:29 $
   *
   * ====================================================================
   *
   * 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/>.
   *
   */
  
  
  package org.apache.commons.resources.impl;
  
  
  import java.util.HashMap;
  import java.util.Map;
  import org.apache.commons.resources.Resources;
  import org.apache.commons.resources.ResourcesException;
  import org.apache.commons.resources.ResourcesFactory;
  
  
  /**
   * <p>Concrete implementation of {@link ResourcesFactory} for unit tests.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/12/28 03:56:29 $
   */
  
  public class TestResourcesFactory extends ResourcesFactoryBase {
      
  
      // --------------------------------------------------------- Public Methods
  
  
      // ------------------------------------------------------ Protected Methods
  
  
      /**
       * <p>Create and return a new {@link Resources} instance with the
       * specified logical name, after calling its <code>init()</code>
       * method.</p>
       *
       * @param name Logical name of the {@link Resources} instance to create
       * @param config Configuration string for this resource (if any)
       *
       * @exception ResourcesException if a {@link Resources} instance
       *  of the specified logical name cannot be created.
       */
      protected Resources createResources(String name, String config)
          throws ResourcesException {
  
          Resources resources = new TestResources(name);
          resources.init();
          return (resources);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/TestResources_en.properties
  
  Index: TestResources_en.properties
  ===================================================================
  test.specific=[en] SPECIFIC
  test.inherit=[en] INHERIT
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/TestResources_en_US.properties
  
  Index: TestResources_en_US.properties
  ===================================================================
  test.specific=[en_US] SPECIFIC
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/TestResources_fr.properties
  
  Index: TestResources_fr.properties
  ===================================================================
  test.specific=[fr] SPECIFIC
  test.inherit=[fr] INHERIT
  
  
  
  1.2       +4 -10     jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/junit/XMLConfigurationReaderTestCase.java
  
  Index: XMLConfigurationReaderTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/junit/XMLConfigurationReaderTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLConfigurationReaderTestCase.java	27 Dec 2002 21:15:18 -0000	1.1
  +++ XMLConfigurationReaderTestCase.java	28 Dec 2002 03:56:29 -0000	1.2
  @@ -213,12 +213,6 @@
           // Attempt to read the test configuration file
           try {
               reader.read(is);
  -        } catch (ResourcesException re) {
  -            if (re.getRootCause() != null) {
  -                throw re.getRootCause();
  -            } else {
  -                throw re;
  -            }
           } finally {
               if (is != null) {
                   try {
  
  
  
  1.7       +18 -38    jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/tests/ConfigurationReaderTest.java
  
  Index: ConfigurationReaderTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/tests/ConfigurationReaderTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ConfigurationReaderTest.java	27 Dec 2002 21:15:18 -0000	1.6
  +++ ConfigurationReaderTest.java	28 Dec 2002 03:56:29 -0000	1.7
  @@ -44,17 +44,7 @@
        * Test the parsing of the config reader
        */
       public void testParse() throws ResourcesException, IOException, Exception {
  -        try {
  -            configReader.read(inputStream);
  -        }
  -        catch (ResourcesException re) {
  -            if (re.getRootCause() != null) {
  -                throw re.getRootCause();
  -            }
  -            else {
  -                throw re;
  -            }
  -        }
  +        configReader.read(inputStream);
       }
       
       /**
  @@ -64,33 +54,23 @@
        */
       public void testGetResourceMap() throws ResourcesException, IOException, Exception {
           
  -        try {
  -            configReader.read(inputStream);        
  -            Map resourceMap = configReader.getResourcesMap();
  -
  -            Resources fileResource = (Resources) resourceMap.get("file");
  -            assertNotNull(fileResource);
  -            assertEquals("org.apache.commons.resources.file.FileResources",
  -                            fileResource.getClass().getName());
  -            assertEquals("c:\\temp", ((FileResources) fileResource).getPath());
  -
  -            Resources messageResource = (Resources) resourceMap.get("message");
  -            assertNotNull(messageResource);
  -            assertEquals("org.apache.commons.resources.message.PropertyMessageResources",
  -                         messageResource.getClass().getName());
  -            String config = ((MessageResources) messageResource).getConfig();
  -            assertEquals("org.apache.commons.resources.tests.ExampleStrings", config);
  -            assertEquals(true, ((MessageResources) messageResource).getReturnNull());
  -        }
  -        catch (ResourcesException re) {
  -            if (re.getRootCause() != null) {
  -                throw re.getRootCause();
  -            }
  -            else {
  -                throw re;
  -            }
  -        }
  -    }   
  +        configReader.read(inputStream);        
  +        Map resourceMap = configReader.getResourcesMap();
  +        
  +        Resources fileResource = (Resources) resourceMap.get("file");
  +        assertNotNull(fileResource);
  +        assertEquals("org.apache.commons.resources.file.FileResources",
  +                     fileResource.getClass().getName());
  +        assertEquals("c:\\temp", ((FileResources) fileResource).getPath());
  +        
  +        Resources messageResource = (Resources) resourceMap.get("message");
  +        assertNotNull(messageResource);
  +        assertEquals("org.apache.commons.resources.message.PropertyMessageResources",
  +                     messageResource.getClass().getName());
  +        String config = ((MessageResources) messageResource).getConfig();
  +        assertEquals("org.apache.commons.resources.tests.ExampleStrings", config);
  +        assertEquals(true, ((MessageResources) messageResource).getReturnNull());
  +    }
       
       public static Test suite() {
           return new TestSuite(ConfigurationReaderTest.class);       
  
  
  
  1.3       +5 -1      jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/tests/FileResourcesExposerFactory.java
  
  Index: FileResourcesExposerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/tests/FileResourcesExposerFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileResourcesExposerFactory.java	27 Dec 2002 23:27:12 -0000	1.2
  +++ FileResourcesExposerFactory.java	28 Dec 2002 03:56:29 -0000	1.3
  @@ -10,7 +10,11 @@
   public class FileResourcesExposerFactory implements ResourcesFactory {
       
    
  -    public Resources getResources(String config) {
  +    public Resources getResources(String name) {
  +        return new FileResourcesExposer();
  +    }
  +
  +    public Resources getResources(String name, String config) {
           return new FileResourcesExposer();
       }
   
  
  
  
  1.5       +30 -57    jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/tests/FileResourcesTest.java
  
  Index: FileResourcesTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/tests/FileResourcesTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FileResourcesTest.java	27 Dec 2002 19:18:04 -0000	1.4
  +++ FileResourcesTest.java	28 Dec 2002 03:56:29 -0000	1.5
  @@ -62,30 +62,22 @@
       }
       
       protected void setUp() throws ResourcesException, Exception {
  -        try {
  -            inputStream = null;
  -            manager = null;
  -            fileResource = null;
  -            
  -            inputStream = this.getClass().getResourceAsStream(RESOURCE_TEST_FILE);
  -            assertNotNull(inputStream);
  -
  -            manager = new ResourcesManager(inputStream);
  -
  -            Resources resource = manager.getResources(RESOURCE_TEST_NAME);
  -            assertNotNull(resource);
  -            assertEquals(RESOURCE_TEST_CLASS, resource.getClass().getName());
  -            fileResource = (FileResourcesExposer) resource;
  -            assertEquals(RESOURCE_PATH, fileResource.getPath());            
  -        }
  -        catch (ResourcesException re) {
  -            if (re.getRootCause() != null) {
  -                throw re.getRootCause();
  -            }
  -            else {
  -                throw re;
  -            }
  -        }
  +
  +        inputStream = null;
  +        manager = null;
  +        fileResource = null;
  +        
  +        inputStream = this.getClass().getResourceAsStream(RESOURCE_TEST_FILE);
  +        assertNotNull(inputStream);
  +        
  +        manager = new ResourcesManager(inputStream);
  +        
  +        Resources resource = manager.getResources(RESOURCE_TEST_NAME);
  +        assertNotNull(resource);
  +        assertEquals(RESOURCE_TEST_CLASS, resource.getClass().getName());
  +        fileResource = (FileResourcesExposer) resource;
  +        assertEquals(RESOURCE_PATH, fileResource.getPath());            
  +
       }
       
       public void testFindValidPath() {
  @@ -98,20 +90,10 @@
       
       public void testGetBytes() throws Exception {
           
  -        try {
  -        
  -            byte[] data = fileResource.getBytes(FILE_TEST1_KEY, locale_en_US, timeZone_EST);
  -            String stringData = new String(data, 0, data.length);
  -            assertEquals(FILE_TEST1_DATA, stringData);
  -        }
  -        catch (ResourcesException re) {
  -            if (re.getRootCause() != null) {
  -                throw re.getRootCause();
  -            }
  -            else {
  -                throw re;
  -            }
  -        }
  +        byte[] data = fileResource.getBytes(FILE_TEST1_KEY, locale_en_US, timeZone_EST);
  +        String stringData = new String(data, 0, data.length);
  +        assertEquals(FILE_TEST1_DATA, stringData);
  +
       }
       
       public void testGetFileNames() {
  @@ -145,26 +127,17 @@
   
       public void testMaxCacheSize() throws Exception {
   
  -        try {
  -            long maxCacheSize = fileResource.getMaxCacheSize();
  -
  -            assertEquals(10240, fileResource.getMaxCacheSize());
  -
  -            //see if the one file is cached and the other one isn't.
  -            fileResource.getInputStream(TEST_FILE_13K, null, null);
  -            fileResource.getInputStream(TEST_FILE_5K, null, null);
  +        long maxCacheSize = fileResource.getMaxCacheSize();
  +        
  +        assertEquals(10240, fileResource.getMaxCacheSize());
  +        
  +        //see if the one file is cached and the other one isn't.
  +        fileResource.getInputStream(TEST_FILE_13K, null, null);
  +        fileResource.getInputStream(TEST_FILE_5K, null, null);
  +        
  +        assertTrue(!fileResource.cacheContainsFile(TEST_FILE_13K, null, null));
  +        assertTrue(fileResource.cacheContainsFile(TEST_FILE_5K, null, null));
   
  -            assertTrue(!fileResource.cacheContainsFile(TEST_FILE_13K, null, null));
  -            assertTrue(fileResource.cacheContainsFile(TEST_FILE_5K, null, null));
  -        }
  -        catch (ResourcesException re) {
  -            if (re.getRootCause() != null) {
  -                throw re.getRootCause();
  -            }
  -            else {
  -                throw re;
  -            }
  -        }
       }
   
       public static Test suite() {
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>