You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jm...@apache.org on 2004/09/08 01:49:48 UTC

cvs commit: jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl MessageResources.xml IBatisResourcesTestCase.java ResourceBundleResourcesTestCase.java TestResources.java ResourcesBaseTestCase.java JDBCResourcesTestCase.java CollectionResourcesBaseTestCase.java

jmitchell    2004/09/07 16:49:48

  Modified:    resources/src/test/org/apache/commons/resources/impl
                        ResourceBundleResourcesTestCase.java
                        TestResources.java ResourcesBaseTestCase.java
                        JDBCResourcesTestCase.java
                        CollectionResourcesBaseTestCase.java
  Added:       resources/src/test/org/apache/commons/resources/impl
                        MessageResources.xml IBatisResourcesTestCase.java
  Log:
  adding iBatis Impl and a few other changes
  
  Revision  Changes    Path
  1.10      +4 -4      jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesTestCase.java
  
  Index: ResourceBundleResourcesTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ResourceBundleResourcesTestCase.java	27 Mar 2004 21:34:09 -0000	1.9
  +++ ResourceBundleResourcesTestCase.java	7 Sep 2004 23:49:47 -0000	1.10
  @@ -107,7 +107,7 @@
               resources.getString("test.missing", locale, null);
               fail("Should have thrown ResourcesException");
           } catch (ResourcesKeyException e) {
  -            ; // Expected result
  +            // Expected result
           }
           try {
               resources.setReturnNull(true);
  
  
  
  1.11      +8 -3      jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/TestResources.java
  
  Index: TestResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/TestResources.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestResources.java	27 Mar 2004 21:34:09 -0000	1.10
  +++ TestResources.java	7 Sep 2004 23:49:47 -0000	1.11
  @@ -123,7 +123,12 @@
        *
        * @exception ResourcesException if an error occurs retrieving or
        *  returning the requested content
  +     * 
  +     * @TODO - FIXME - why is locale and timeZone ignored here?
        */
  +    public Object getObject(String key){
  +        return getObject(key, null, null);
  +    }
       public Object getObject(String key, Locale locale, TimeZone timeZone)
           throws ResourcesException {
   
  
  
  
  1.12      +4 -4      jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourcesBaseTestCase.java
  
  Index: ResourcesBaseTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/ResourcesBaseTestCase.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ResourcesBaseTestCase.java	27 Mar 2004 21:34:09 -0000	1.11
  +++ ResourcesBaseTestCase.java	7 Sep 2004 23:49:47 -0000	1.12
  @@ -136,7 +136,7 @@
               resources.getString("test.missing", locale, null);
               fail("Should have thrown ResourcesException");
           } catch (ResourcesKeyException e) {
  -            ; // Expected result
  +            // Expected result
           }
           try {
               resources.setReturnNull(true);
  
  
  
  1.2       +6 -5      jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java
  
  Index: JDBCResourcesTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JDBCResourcesTestCase.java	11 Jun 2004 02:51:45 -0000	1.1
  +++ JDBCResourcesTestCase.java	7 Sep 2004 23:49:47 -0000	1.2
  @@ -45,7 +45,7 @@
   
   
       // ----------------------------------------------------- Instance Variables
  -	Connection con = null;
  +	private Connection con;
   
   
       protected String getBase() throws Exception
  @@ -78,6 +78,7 @@
           factory = new JDBCResourcesFactory();
           resources = factory.getResources(NAME, getBase());
           
  +        // change this to load from init.sql
           String[] sql = {""
           + "create table resources (" 
           + "  locale            varchar(10)      not null,"
  
  
  
  1.11      +4 -4      jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/CollectionResourcesBaseTestCase.java
  
  Index: CollectionResourcesBaseTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/CollectionResourcesBaseTestCase.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- CollectionResourcesBaseTestCase.java	27 Mar 2004 21:34:09 -0000	1.10
  +++ CollectionResourcesBaseTestCase.java	7 Sep 2004 23:49:47 -0000	1.11
  @@ -163,7 +163,7 @@
   			resources.getString("test.missing", locale, null);
   			fail("Should have thrown ResourcesException");
   		} catch (ResourcesKeyException e) {
  -			; // Expected result
  +			// Expected result
   		}
   
       }
  
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/MessageResources.xml
  
  Index: MessageResources.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!DOCTYPE sql-map
      PUBLIC "-//iBATIS.com//DTD SQL Map 1.0//EN"
      "http://www.ibatis.com/dtd/sql-map.dtd">
  
  <sql-map name="MessageResources">
  
    <result-map name="bundle-result" 
  		class="org.apache.commons.resources.impl.DatabaseBasicMessage">
      <property name="locale"  type="VARCHAR" column="locale"/>
      <property name="key"     type="VARCHAR" column="msgKey"/>
      <property name="value"   type="VARCHAR" column="val"/>
    </result-map>
  
    <mapped-statement name="getBundleByLocale"
                      result-map="bundle-result">
      select locale, msgKey, val
      from RESOURCES
      where LOCALE = #value#
    </mapped-statement>
  
  </sql-map>
  
  
  1.1                  jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/IBatisResourcesTestCase.java
  
  Index: IBatisResourcesTestCase.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/resources/src/test/org/apache/commons/resources/impl/IBatisResourcesTestCase.java,v 1.1 2004/09/07 23:49:47 jmitchell Exp $
   * $Revision: 1.1 $
   * $Date: 2004/09/07 23:49:47 $
   *
   * ====================================================================
   *
   *  Copyright 2003-2004 The Apache Software Foundation
   * 
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   */
  package org.apache.commons.resources.impl;
  import java.io.Reader;
  import java.sql.Connection;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import com.ibatis.common.resources.Resources;
  import com.ibatis.db.jdbc.SimpleDataSource;
  import com.ibatis.db.sqlmap.SqlMap;
  import com.ibatis.db.sqlmap.XmlSqlMapBuilder;
  import com.ibatis.db.util.ScriptRunner;
  
  /**
   * <p>Unit tests for
   * <code>org.apache.commons.resources.impl.iBatisResources</code>.
   * </p>
   *
   * @author James Mitchell
   * @version $Revision: 1.1 $ $Date: 2004/09/07 23:49:47 $
   */
  
  public class IBatisResourcesTestCase
      extends CollectionResourcesBaseTestCase {
  
  
      // ----------------------------------------------------- Instance Variables
  	 protected static SqlMap sqlMap;
  //	 private Connection con;
  
      // ----------------------------------------------------------- Constructors
  
  
      public IBatisResourcesTestCase(String name) {
          super(name);
      }
  
  
      // --------------------------------------------------- Overall Test Methods
  
  
      // Set up instance variables required by this test case
      public void setUp() throws Exception {
      	
          initSqlMap("SqlMapConfig.xml");
          initScript("init.sql");
          factory = new IBatisResourcesFactory();
          resources = factory.getResources(NAME, getBase());
      }
  
  	// Return the tests included in this test suite
      public static Test suite() {
          return (new TestSuite(IBatisResourcesTestCase.class));
      }
  
      // Tear down the instance variables required by this test case
      public void tearDown() {
          SimpleDataSource ds = (SimpleDataSource) sqlMap.getCurrentDataSource();
          ds.forceCloseAll();
          resources = null;
          factory = null;
      }
  
  
      // ------------------------------------------------ Individual Test Methods
  
  
      // ------------------------------------------------------ Protected Methods
      protected String getBase() throws Exception
      {
          return "SqlMapConfig.xml";
      }
  
      // ------------------------------------------------------ Private Methods
      protected void initSqlMap(String configFile) throws Exception {
          Reader reader = Resources.getResourceAsReader(configFile);
          sqlMap = XmlSqlMapBuilder.buildSqlMap(reader);
          reader.close();
      }
      
      protected void initScript(String script) throws Exception {
          Reader reader = Resources.getResourceAsReader(script);
          Connection conn = sqlMap.getCurrentDataSource().getConnection();
          ScriptRunner runner = new ScriptRunner();
          runner.setStopOnError(false);
          runner.setLogWriter(null);
          runner.setErrorLogWriter(null);
          runner.runScript(conn, reader);
          conn.commit();
  
          conn.close();
          reader.close();
        }
  }
  
  
  

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