db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mka...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb repository_junit.xml
Date Fri, 11 Mar 2005 16:59:25 GMT
mkalen      2005/03/11 08:59:25

  Modified:    src/schema ojbtest-schema.xml
               src/test/org/apache/ojb/broker AllTests.java
               src/test/org/apache/ojb/junit PBTestCase.java
               src/test/org/apache/ojb repository_junit.xml
  Added:       src/test/org/apache/ojb/broker CharacterTest.java
  Log:
  Merge with OJB_1_0_RELEASE branch: New PB-API testcase broker.CharacterTest to prove ClassCastExceptions
in Oracle JDBC-driver when using default platform impl rs.setObject() and java.lang.Character.
Passes with hsqldb, fails with Oracle9i.
  
  Revision  Changes    Path
  1.92      +9 -1      db-ojb/src/schema/ojbtest-schema.xml
  
  Index: ojbtest-schema.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/schema/ojbtest-schema.xml,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- ojbtest-schema.xml	6 Jan 2005 21:00:00 -0000	1.91
  +++ ojbtest-schema.xml	11 Mar 2005 16:59:24 -0000	1.92
  @@ -230,6 +230,14 @@
       <column name="CLOB_VALUE_" type="LONGVARCHAR"/>
     </table>
   
  +  <table name="CHARACTER_TEST">
  +    <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
  +    <column name="CHAR_1" type="CHAR" size="1" />
  +    <column name="CHAR_10" type="CHAR" size="10" />
  +    <column name="VARCHAR_1" type="VARCHAR" size="1" />
  +    <column name="VARCHAR_10" type="VARCHAR" size="10" />
  +  </table>
  +
     <table name="MDTEST_MASTER">
       <column name="MASTERID" required="true" primaryKey="true" type="INTEGER"/>
       <column name="MASTER_TEXT" type="VARCHAR" size="255"/>
  
  
  
  1.61      +17 -7     db-ojb/src/test/org/apache/ojb/broker/AllTests.java
  
  Index: AllTests.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AllTests.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- AllTests.java	2 Feb 2005 20:10:26 -0000	1.60
  +++ AllTests.java	11 Mar 2005 16:59:24 -0000	1.61
  @@ -1,11 +1,21 @@
   package org.apache.ojb.broker;
   
  -import java.sql.Connection;
  -import java.sql.SQLException;
  -import java.sql.Statement;
  +/* Copyright 2002-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.
  + */
   
   import junit.framework.Test;
  -import junit.framework.TestResult;
   import junit.framework.TestSuite;
   
   import org.apache.ojb.broker.accesslayer.sql.TableAliasHandlerTest;
  @@ -25,8 +35,6 @@
   import org.apache.ojb.broker.metadata.ReferenceMapTest;
   import org.apache.ojb.broker.metadata.RepositoryElementsTest;
   import org.apache.ojb.broker.metadata.RepositoryPersistorTest;
  -import org.apache.ojb.broker.platforms.Platform;
  -import org.apache.ojb.broker.platforms.PlatformHsqldbImpl;
   import org.apache.ojb.broker.sequence.AutoIncrementTest;
   import org.apache.ojb.broker.sequence.NativeIdentifierTest;
   import org.apache.ojb.broker.sequence.SMMultiThreadedTest;
  @@ -36,8 +44,9 @@
    * the facade to all TestCases in this package.
    *
    * @author Thomas Mahler
  + * @version $Id$
    */
  -public class AllTests extends junit.framework.TestSuite
  +public class AllTests extends TestSuite
   {
       /**
        * runs the suite in a junit.textui.TestRunner.
  @@ -83,6 +92,7 @@
           suite.addTestSuite(KeyConstraintViolationTest.class);
           suite.addTestSuite(RsIteratorTest.class);
           suite.addTestSuite(BlobTest.class);
  +        suite.addTestSuite(CharacterTest.class);
           suite.addTestSuite(LogServiceTest.class);
           suite.addTestSuite(MetaDataSerializationTest.class);
           suite.addTestSuite(MetadataTest.class);
  
  
  
  1.2       +223 -0    db-ojb/src/test/org/apache/ojb/broker/CharacterTest.java
  
  
  
  
  1.10      +77 -3     db-ojb/src/test/org/apache/ojb/junit/PBTestCase.java
  
  Index: PBTestCase.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/junit/PBTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PBTestCase.java	18 Dec 2004 14:01:18 -0000	1.9
  +++ PBTestCase.java	11 Mar 2005 16:59:24 -0000	1.10
  @@ -1,8 +1,25 @@
   package org.apache.ojb.junit;
   
  +/* Copyright 2002-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.
  + */
  +
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerInternal;
   import org.apache.ojb.broker.PersistenceConfiguration;
  +import org.apache.ojb.broker.PersistenceBrokerException;
  +import org.apache.ojb.broker.platforms.Platform;
   
   /**
    * A base class for PB-api based test cases.
  @@ -15,6 +32,7 @@
   {
       protected PersistenceConfiguration persistenceConf;
       protected PersistenceBrokerInternal broker;
  +    protected String platformClass;
   
       public PBTestCase()
       {
  @@ -28,9 +46,13 @@
   
       public void setUp() throws Exception
       {
  +        Platform platform;
  +
           super.setUp();
  -        persistenceConf = ojb.getDefaultConfiguration();
  -        broker = (PersistenceBrokerInternal) persistenceConf.createPersistenceBroker();
  +        assertNotNull(persistenceConf = ojb.getDefaultConfiguration());
  +        assertNotNull(broker = (PersistenceBrokerInternal) persistenceConf.createPersistenceBroker());
  +        assertNotNull(platform = broker.serviceConnectionManager().getSupportedPlatform());
  +        assertNotNull(platformClass = platform.getClass().getName());
   
           // allows to run all tests in batch mode, if the 'batch-mode'
           // was enabled
  @@ -57,4 +79,56 @@
               broker.close();
           }
       }
  +
  +    /**
  +     * Returns the platform implementation class name of the currently
  +     * used broker.
  +     * @return platform implementation class name
  +     */
  +    public String getPlatformClass()
  +    {
  +        return platformClass;
  +    }
  +
  +    /**
  +     * Persists an object with PB-API in a method-local transaction.
  +     * @param obj the object to persist
  +     * @throws org.apache.ojb.broker.TransactionInProgressException
  +     *  if external transaction in progress
  +     * @throws org.apache.ojb.broker.PersistenceBrokerException
  +     *  on persistence error
  +     */
  +    public void pbPersist(Object obj)
  +    {
  +        try
  +        {
  +            broker.beginTransaction();
  +            broker.store(obj);
  +            broker.commitTransaction();
  +        }
  +        catch (PersistenceBrokerException pbe)
  +        {
  +            throw pbe;
  +        }
  +        catch (ClassCastException cce)
  +        {
  +            System.err.println("Error in JDBC-driver while storing: " + obj);
  +            throw cce;
  +        }
  +        finally
  +        {
  +            if (broker.isInTransaction())
  +            {
  +                try
  +                {
  +                    broker.abortTransaction();
  +                }
  +                catch (Throwable ignore)
  +                {
  +                    //ignore
  +                }
  +            }
  +        }
  +    }
  +
   }
  
  
  
  1.131     +16 -1     db-ojb/src/test/org/apache/ojb/repository_junit.xml
  
  Index: repository_junit.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_junit.xml,v
  retrieving revision 1.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- repository_junit.xml	2 Feb 2005 20:03:15 -0000	1.130
  +++ repository_junit.xml	11 Mar 2005 16:59:25 -0000	1.131
  @@ -1358,6 +1358,21 @@
         />
      </class-descriptor>
   
  +<!-- Definitions for broker.CharacterTest$ObjectWithCharField -->
  +  <class-descriptor
  +    class="org.apache.ojb.broker.CharacterTest$ObjectWithCharField"
  +    table="CHARACTER_TEST">
  +    <field-descriptor name="id" column="ID"
  +      jdbc-type="INTEGER" primarykey="true" autoincrement="true"/>
  +    <field-descriptor name="characterCharField" column="CHAR_1"
  +      jdbc-type="CHAR" length="1"/>
  +    <field-descriptor name="characterVarcharField" column="VARCHAR_1"
  +      jdbc-type="VARCHAR" length="1"/>
  +    <field-descriptor name="stringCharField" column="CHAR_10"
  +      jdbc-type="CHAR" length="10"/>
  +    <field-descriptor name="stringVarcharField" column="VARCHAR_10"
  +      jdbc-type="VARCHAR" length="10"/>
  +  </class-descriptor>
   
   <!-- Definitions for org.apache.ojb.broker.PBAwareEntity -->
      <class-descriptor
  
  
  

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


Mime
View raw message