db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1237966 - in /db/torque/torque4/trunk/torque-test/src: main/schema/ test/java/org/apache/torque/ test/java/org/apache/torque/adapter/ test/java/org/apache/torque/datatypes/ test/java/org/apache/torque/generated/peer/ test/java/org/apache/t...
Date Mon, 30 Jan 2012 20:19:54 GMT
Author: tfischer
Date: Mon Jan 30 20:19:54 2012
New Revision: 1237966

URL: http://svn.apache.org/viewvc?rev=1237966&view=rev
Log:
- added test schema for index and unique
- moved tables which are designated to test a ceratain type to a new types schema
- moved "bit" test and "in" test from DataTest to own test classes
- added a test which checks that lock/unlock tables runs without error
- added a test case for getting related objects
- added a test case for idbroker start/stop behaviour

Added:
    db/torque/torque4/trunk/torque-test/src/main/schema/index.xml
    db/torque/torque4/trunk/torque-test/src/main/schema/types.xml
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/adapter/
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/adapter/AdapterTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BitTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/GetRelatedObjectsTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectInTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java
Modified:
    db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java

Added: db/torque/torque4/trunk/torque-test/src/main/schema/index.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/main/schema/index.xml?rev=1237966&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/main/schema/index.xml (added)
+++ db/torque/torque4/trunk/torque-test/src/main/schema/index.xml Mon Jan 30 20:19:54 2012
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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.
+-->
+<!-- This schema contains tables to test index creation. -->
+
+<database name="@DATABASE_DEFAULT@" 
+    defaultIdMethod="@DATABASE_ID_METHOD@"
+    package="org.apache.torque.test"
+    xmlns="http://db.apache.org/torque/4.0/templates/database"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://db.apache.org/torque/4.0/templates/database 
+        http://db.apache.org/torque/4.0/templates/database.xsd">
+
+  <table name="single_named_index" idMethod="none">
+    <column name="id" required="true" primaryKey="true" type="INTEGER" />
+    <column name="value" required="true" type="INTEGER" />
+    <index name="single_idx">
+      <index-column name="value"/>
+    </index>
+  </table>
+
+  <table name="single_unnamed_index" idMethod="none">
+    <column name="id" required="true" primaryKey="true" type="INTEGER" />
+    <column name="value" required="true" type="INTEGER" />
+    <index>
+      <index-column name="value"/>
+    </index>
+  </table>
+
+  <table name="multiple_index" idMethod="none">
+    <column name="id" required="true" primaryKey="true" type="INTEGER" />
+    <column name="value1" required="true" type="INTEGER" />
+    <column name="value2" required="true" type="INTEGER" />
+    <index name="multiple_idx">
+      <index-column name="value1"/>
+      <index-column name="value2"/>
+    </index>
+  </table>
+
+  <table name="single_named_unique" idMethod="none">
+    <column name="id" required="true" primaryKey="true" type="INTEGER" />
+    <column name="value" required="true" type="INTEGER" />
+    <unique name="single_unq">
+      <unique-column name="value"/>
+    </unique>
+  </table>
+
+  <table name="single_unnamed_unique">
+    <column name="id" required="true" primaryKey="true" type="INTEGER" />
+    <column name="value" required="true" type="INTEGER" />
+    <unique>
+      <unique-column name="value"/>
+    </unique>
+  </table>
+
+  <table name="multiple_unique">
+    <column name="id" required="true" primaryKey="true" type="INTEGER" />
+    <column name="value1" required="true" type="INTEGER" />
+    <column name="value2" required="true" type="INTEGER" />
+    <unique name="multiple_unq">
+      <unique-column name="value1"/>
+      <unique-column name="value2"/>
+    </unique>
+  </table>
+</database>
+
+  
\ No newline at end of file

Modified: db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml?rev=1237966&r1=1237965&r2=1237966&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml (original)
+++ db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml Mon Jan 30 20:19:54 2012
@@ -143,13 +143,6 @@
   </table>
 -->
 
-  <!-- BOOLEANCHAR not working? -->
-  <table name="boolean_check" idMethod="none">
-    <column name="test_key" required="true" primaryKey="true" type="CHAR" size="2" />
-    <column name="bint_value" required="true" type="BOOLEANINT" />
-    <column name="bchar_value" required="true" type="BOOLEANCHAR" />
-  </table>
-
   <!-- TRQS97 -->
   <table name="LEAGUES_OBJECT" description="Contains all leagues">
     <column name="LEAGUEID" primaryKey="true" required="true" type="TINYINT" javaType="object"/>
@@ -186,21 +179,6 @@
     <column name="name" size="100" type="VARCHAR"/>
   </table>
 
-  <table name="bit_test" idMethod="none">
-    <column name="id" required="true" primaryKey="true" type="CHAR" size="10" />
-    <column name="bit_value" required="true" type="BIT" />
-  </table>
-
-  <table name="blob_test">
-    <column name="id" required="true" primaryKey="true" type="BIGINT" />
-    <column name="blob_value" type="BLOB" required="false"/>
-  </table>
-
-  <table name="clob_test">
-    <column name="id" required="true" primaryKey="true" type="INTEGER" />
-    <column name="clob_value" type="CLOB" required="false"/>
-  </table>
-
   <!-- TRQS263 -->
   <table name="DATE_TIME_TIMESTAMP" description="Table to test Date formats">
     <column

Added: db/torque/torque4/trunk/torque-test/src/main/schema/types.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/main/schema/types.xml?rev=1237966&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/main/schema/types.xml (added)
+++ db/torque/torque4/trunk/torque-test/src/main/schema/types.xml Mon Jan 30 20:19:54 2012
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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.
+-->
+<!-- This schema contains tables with data types to test. -->
+
+<database name="@DATABASE_DEFAULT@" 
+    defaultIdMethod="@DATABASE_ID_METHOD@"
+    package="org.apache.torque.test"
+    xmlns="http://db.apache.org/torque/4.0/templates/database"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://db.apache.org/torque/4.0/templates/database 
+        http://db.apache.org/torque/4.0/templates/database.xsd">
+  <table name="bit_value" idMethod="none">
+    <column name="id" required="true" primaryKey="true" type="VARCHAR" size="10" />
+    <column name="bit_value" required="true" type="BIT" />
+  </table>
+
+  <table name="blob_test">
+    <column name="id" required="true" primaryKey="true" type="BIGINT" />
+    <column name="blob_value" type="BLOB" required="false"/>
+  </table>
+
+  <table name="clob_test">
+    <column name="id" required="true" primaryKey="true" type="INTEGER" />
+    <column name="clob_value" type="CLOB" required="false"/>
+  </table>
+  
+  <table name="bint_bchar_value" idMethod="none">
+    <column name="id" required="true" primaryKey="true" type="VARCHAR" size="2" />
+    <column name="bint_value" required="true" type="BOOLEANINT" />
+    <column name="bchar_value" required="true" type="BOOLEANCHAR" />
+  </table>
+
+</database>

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java?rev=1237966&r1=1237965&r2=1237966&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java Mon Jan 30 20:19:54 2012
@@ -19,6 +19,7 @@ package org.apache.torque;
  * under the License.
  */
 
+import java.util.ArrayList;
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -137,26 +138,38 @@ public abstract class BaseDatabaseTestCa
     /**
      * Inserts test data into the bookstore tables.
      *
+     * @return the list of added authors, which in turn contain the added books.
+     *
      * @throws TorqueException if filling data fails.
      */
-    protected void insertBookstoreData() throws TorqueException
+    protected List<Author> insertBookstoreData() throws TorqueException
     {
+        List<Author> result = new ArrayList<Author>();
         for (int i = 1; i <= 10; i++)
         {
             Author author = new Author();
             author.setName("Author " + i);
             author.save();
+            result.add(author);
             assertTrue("authorId should not be 0 after insert",
                     author.getAuthorId() != 0);
 
             for (int j = 1; j <= 10; j++)
             {
                 Book book = new Book();
-                book.setAuthor(author);
+                author.addBook(book);
                 book.setTitle("Book " + j + " - Author " + i);
-                book.setIsbn("ISBN" + j + "-" + i);
+                if (j < 10)
+                {
+                    book.setIsbn("ISBN " + j + " - " + i);
+                }
+                else
+                {
+                   book.setIsbn(null);
+                }
                 book.save();
             }
         }
+        return result;
     }
 }

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java?rev=1237966&r1=1237965&r2=1237966&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java Mon Jan 30 20:19:54 2012
@@ -32,14 +32,11 @@ import java.util.Set;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.torque.adapter.DB;
-import org.apache.torque.adapter.DBDerby;
 import org.apache.torque.adapter.DBHsqldb;
 import org.apache.torque.adapter.DBMM;
 import org.apache.torque.adapter.DBMSSQL;
-import org.apache.torque.adapter.DBOracle;
 import org.apache.torque.criteria.Criteria;
 import org.apache.torque.criteria.Criterion;
-import org.apache.torque.om.StringKey;
 import org.apache.torque.om.mapper.CompositeMapper;
 import org.apache.torque.om.mapper.IntegerMapper;
 import org.apache.torque.om.mapper.RecordMapper;
@@ -50,17 +47,11 @@ import org.apache.torque.test.AuthorPeer
 import org.apache.torque.test.AuthorRecordMapper;
 import org.apache.torque.test.B;
 import org.apache.torque.test.BPeer;
-import org.apache.torque.test.BitCompositePk;
-import org.apache.torque.test.BitCompositePkPeer;
-import org.apache.torque.test.BitTest;
-import org.apache.torque.test.BitTestPeer;
 import org.apache.torque.test.BlobTest;
 import org.apache.torque.test.BlobTestPeer;
 import org.apache.torque.test.Book;
 import org.apache.torque.test.BookPeer;
 import org.apache.torque.test.BookRecordMapper;
-import org.apache.torque.test.BooleanCheck;
-import org.apache.torque.test.BooleanCheckPeer;
 import org.apache.torque.test.C;
 import org.apache.torque.test.CPeer;
 import org.apache.torque.test.ClobTest;
@@ -162,20 +153,6 @@ public class DataTest extends BaseDataba
                 book.save();
             }
         }
-        // clean booleancheck table (because insert uses fixed keys)
-        Criteria criteria = new Criteria();
-        BooleanCheckPeer.doDelete(criteria);
-
-        BooleanCheck bc = new BooleanCheck();
-        bc.setTestKey("t1");
-        bc.setBintValue(true);
-        bc.setBcharValue(true);
-        bc.save();
-        bc = new BooleanCheck();
-        bc.setTestKey("f1");
-        bc.setBintValue(false);
-        bc.setBcharValue(false);
-        bc.save();
 
         // check a primitive id can be set manually
         Author author = new Author();
@@ -183,7 +160,7 @@ public class DataTest extends BaseDataba
         author.setName("Author 2000");
         author.save();
         assertEquals(2000, author.getAuthorId());
-        criteria = new Criteria();
+        Criteria criteria = new Criteria();
         criteria.add(AuthorPeer.AUTHOR_ID, 2000);
         List<Author> authorList = AuthorPeer.doSelect(criteria);
         assertEquals(1, authorList.size());
@@ -411,296 +388,6 @@ public class DataTest extends BaseDataba
     }
 
     /**
-     * test boolean values
-     * @throws Exception if the test fails
-     */
-    public void testBooleanValues() throws Exception
-    {
-        BooleanCheck bc = BooleanCheckPeer.retrieveByPK(new StringKey("t1"));
-        assertTrue("BOOLEANINT should be true but is: "
-                + bc.getBintValue(), bc.getBintValue());
-        assertTrue("BOOLEANCHAR should be true but is: "
-                + bc.getBcharValue(), bc.getBcharValue());
-        bc = BooleanCheckPeer.retrieveByPK(new StringKey("f1"));
-        assertFalse("BOOLEANINT should be false but is: "
-                + bc.getBintValue(), bc.getBintValue());
-        assertFalse("BOOLEANCHAR should be false but is: "
-                + bc.getBcharValue(), bc.getBcharValue());
-    }
-
-    /**
-     * Test whether a boolean PK works.
-     *
-     * @throws Exception if anything in the test goes wrong.
-     */
-    public void testBitPk() throws Exception
-    {
-        if (Torque.getDB(Torque.getDefaultDB()) instanceof DBOracle
-                || Torque.getDB(Torque.getDefaultDB()) instanceof DBDerby)
-        {
-            log.error("testBitPk(): "
-                    + "BIT is known not to work with "
-                    + "Oracle and Derby");
-            // failing is "expected", so exit without error
-            return;
-        }
-
-        Criteria criteria = new Criteria();
-        BitCompositePkPeer.doDelete(criteria);
-
-        BitCompositePk bitCompositePk = new BitCompositePk();
-        bitCompositePk.setPk1("false value");
-        bitCompositePk.setPk2(Boolean.FALSE);
-        bitCompositePk.setPayload("false payload");
-        bitCompositePk.save();
-
-        bitCompositePk = new BitCompositePk();
-        bitCompositePk.setPk1("true value");
-        bitCompositePk.setPk2(Boolean.TRUE);
-        bitCompositePk.setPayload("true payload");
-        bitCompositePk.save();
-
-        bitCompositePk = new BitCompositePk();
-        bitCompositePk.setPk1("value");
-        bitCompositePk.setPk2(Boolean.TRUE);
-        bitCompositePk.setPayload("payload");
-        bitCompositePk.save();
-
-        // check we get correct result when pks match
-        criteria = new Criteria();
-        criteria.and(BitCompositePkPeer.PK1, "false value");
-        criteria.and(BitCompositePkPeer.PK2, Boolean.FALSE);
-        List<BitCompositePk> result
-            = BitCompositePkPeer.doSelect(criteria);
-        assertEquals(1, result.size());
-        assertEquals("false payload", result.get(0).getPayload());
-
-        criteria = new Criteria();
-        criteria.and(BitCompositePkPeer.PK1, "true value");
-        criteria.and(BitCompositePkPeer.PK2, Boolean.TRUE);
-        result = BitCompositePkPeer.doSelect(criteria);
-        assertEquals(1, result.size());
-        assertEquals("true payload", result.get(0).getPayload());
-
-        // check updating works
-        result.get(0).setPayload("true updated payload");
-        result.get(0).save();
-
-        criteria = new Criteria();
-        criteria.and(BitCompositePkPeer.PK1, "true value");
-        criteria.and(BitCompositePkPeer.PK2, Boolean.TRUE);
-        result = BitCompositePkPeer.doSelect(criteria);
-        assertEquals(1, result.size());
-        assertEquals("true updated payload", result.get(0).getPayload());
-    }
-
-    /**
-     * Tests whether column type BIT can be written and read correctly
-     * and works in criteria as expected
-     * @throws Exception if the test fails
-     */
-    public void testBitType() throws Exception
-    {
-        if (Torque.getDB(Torque.getDefaultDB()) instanceof DBOracle
-                || Torque.getDB(Torque.getDefaultDB()) instanceof DBDerby)
-        {
-            log.error("testBitType(): "
-                    + "BIT is known not to work with "
-                    + "Oracle and Derby");
-            // failing is "expected", so exit without error
-            return;
-        }
-
-        // clean table
-        Criteria criteria = new Criteria();
-        criteria.add(BitTestPeer.ID, (Object) null, Criteria.NOT_EQUAL);
-        BitTestPeer.doDelete(criteria);
-
-        // insert Data
-        BitTest bitTest = new BitTest();
-        bitTest.setId("t1");
-        bitTest.setBitValue(true);
-        bitTest.save();
-        bitTest = new BitTest();
-        bitTest.setId("f1");
-        bitTest.setBitValue(false);
-        bitTest.save();
-
-        // read data
-        bitTest = BitTestPeer.retrieveByPK(new StringKey("t1"));
-        assertTrue("BIT should be true but is: "
-                + bitTest.getBitValue(), bitTest.getBitValue());
-
-        bitTest = BitTestPeer.retrieveByPK(new StringKey("f1"));
-        assertFalse("BIT should be false but is: "
-                + bitTest.getBitValue(), bitTest.getBitValue());
-
-        // query data
-        criteria = new Criteria();
-        criteria.add(BitTestPeer.BIT_VALUE, new Boolean(true));
-        List bitTestList = BitTestPeer.doSelect(criteria);
-        assertTrue("Should have read 1 dataset "
-                + "but read " + bitTestList.size(),
-                bitTestList.size() == 1);
-        bitTest = (BitTest) bitTestList.get(0);
-        // use trim() for testkey because some databases will return the
-        // testkey filled up with blanks, as it is defined as char(10)
-        assertTrue("Primary key of data set should be t1 but is "
-                + bitTest.getId().trim(),
-                "t1".equals(bitTest.getId().trim()));
-
-        criteria = new Criteria();
-        criteria.add(BitTestPeer.BIT_VALUE, new Boolean(false));
-        bitTestList = BitTestPeer.doSelect(criteria);
-        assertTrue("Should have read 1 dataset "
-                + "but read " + bitTestList.size(),
-                bitTestList.size() == 1);
-        bitTest = (BitTest) bitTestList.get(0);
-        assertTrue("Primary key of data set should be f1 but is "
-                + bitTest.getId().trim(),
-                "f1".equals(bitTest.getId().trim()));
-
-    }
-
-    /**
-     * check whether we can select from boolean columns
-     * @throws Exception if the test fails
-     */
-    public void testBooleanSelects() throws Exception
-    {
-        Criteria criteria = new Criteria();
-        criteria.add(BooleanCheckPeer.BCHAR_VALUE, new Boolean(true));
-        criteria.add(BooleanCheckPeer.BINT_VALUE, new Boolean(true));
-        List<BooleanCheck> booleanCheckList
-            = BooleanCheckPeer.doSelect(criteria);
-        assertTrue("Should have read 1 dataset with both values true "
-                + "but read " + booleanCheckList.size(),
-                booleanCheckList.size() == 1);
-        BooleanCheck booleanCheck = booleanCheckList.get(0);
-        // use trim() for testkey because some databases will return the
-        // testkey filled up with blanks, as it is defined as char(10)
-        assertTrue("Primary key of data set should be t1 but is "
-                + booleanCheck.getTestKey().trim(),
-                "t1".equals(booleanCheck.getTestKey().trim()));
-
-        criteria = new Criteria();
-        criteria.add(BooleanCheckPeer.BCHAR_VALUE, new Boolean(false));
-        criteria.add(BooleanCheckPeer.BINT_VALUE, new Boolean(false));
-        booleanCheckList = BooleanCheckPeer.doSelect(criteria);
-        assertTrue("Should have read 1 dataset with both values false "
-                + "but read " + booleanCheckList.size(),
-                booleanCheckList.size() == 1);
-        booleanCheck = booleanCheckList.get(0);
-        assertTrue("Primary key of data set should be f1 but is "
-                + booleanCheck.getTestKey().trim(),
-                "f1".equals(booleanCheck.getTestKey().trim()));
-
-        // checks whether booleanint and booleanchar values are also
-        // replaced in joined tables
-        criteria = new Criteria();
-        criteria.addAlias("bc", BooleanCheckPeer.TABLE_NAME);
-        criteria.addJoin(
-                BooleanCheckPeer.TEST_KEY,
-                new ColumnImpl("bc.test_key"));
-        criteria.add("bc.bint_value", new Boolean(false));
-        criteria.add("bc.bchar_value", new Boolean(false));
-        booleanCheckList = BooleanCheckPeer.doSelect(criteria);
-        assertTrue("Should have read 1 dataset with both values false "
-                + "but read " + booleanCheckList.size(),
-                booleanCheckList.size() == 1);
-        booleanCheck = booleanCheckList.get(0);
-        assertTrue("Primary key of data set should be f1 but is "
-                + booleanCheck.getTestKey().trim(),
-                "f1".equals(booleanCheck.getTestKey().trim()));
-
-        // check whether complex criteria are overwritten by
-        // replaceBooleans
-        criteria = new Criteria();
-        Criterion criterion1 = criteria.getNewCriterion(
-                BooleanCheckPeer.BCHAR_VALUE,
-                Boolean.FALSE,
-                Criteria.EQUAL);
-        Criterion criterion2 = criteria.getNewCriterion(
-                BooleanCheckPeer.BCHAR_VALUE,
-                null,
-                Criteria.ISNULL);
-        criteria.add(criterion1.and(criterion2));
-        booleanCheckList = BooleanCheckPeer.doSelect(criteria);
-        // List should be empty, because and creates unfulfillable condition
-        // If BasePeer.correctBooleans() replaces Criterion wrongly,
-        // then we get entries in the list.
-        assertTrue("List should be empty but contains "
-                + booleanCheckList.size() + " datasets",
-                booleanCheckList.isEmpty());
-
-        // check whether complex criteria are overwritten by
-        // replaceBooleans
-        criteria = new Criteria();
-        criterion1 = criteria.getNewCriterion(
-                BooleanCheckPeer.BCHAR_VALUE,
-                null,
-                Criteria.ISNULL);
-        criterion2 = criteria.getNewCriterion(
-                BooleanCheckPeer.BCHAR_VALUE,
-                Boolean.FALSE,
-                Criteria.EQUAL);
-        criteria.add(criterion1.or(criterion2));
-        booleanCheckList = BooleanCheckPeer.doSelect(criteria);
-        assertTrue("Should have read 1 dataset complex Criteria "
-                + "but read " + booleanCheckList.size(),
-                booleanCheckList.size() == 1);
-        booleanCheck = booleanCheckList.get(0);
-        // use trim() for testkey because some databases will return the
-        // testkey filled up with blanks, as it is defined as char(10)
-        assertTrue("Primary key of data set should be f1 but is "
-                + booleanCheck.getTestKey().trim(),
-                "f1".equals(booleanCheck.getTestKey().trim()));
-
-        // check whether booleans are replaced with unqualified columns
-        criteria = new Criteria()
-            .where("BooleanCheck.bint_value", true)
-            .and("BooleanCheck.bchar_value", true);
-
-        BooleanCheckPeer.correctBooleans(criteria);
-
-        Criterion criterionInt
-                = criteria.getTopLevelCriterion().getParts().get(0);
-        Object intValue = criterionInt.getValue();
-
-        assertTrue("The boolean value should be an instance of Integer",
-                intValue instanceof Integer);
-
-        Criterion criterionChar
-                = criteria.getTopLevelCriterion().getParts().get(1);
-        Object charValue = criterionChar.getValue();
-
-        assertTrue("The boolean value should be an instance of String",
-                charValue instanceof String);
-
-        // check whether booleans are left alone with unqualified columns and
-        // no table map
-        criteria = new Criteria()
-            .where("BooleanCheck.bint_value", true)
-            .and("BooleanCheck.bchar_value", true);
-
-        BasePeer.correctBooleans(criteria, null);
-
-        Criterion criterionBool1
-                = criteria.getTopLevelCriterion().getParts().get(0);
-        Object boolValue1 = criterionBool1.getValue();
-
-        assertTrue("The boolean value should be an instance of Boolean",
-               boolValue1 instanceof Boolean);
-
-        Criterion criterionBool2
-                = criteria.getTopLevelCriterion().getParts().get(1);
-        Object boolValue2 = criterionBool2.getValue();
-
-        assertTrue("The boolean value should be an instance of Boolean",
-               boolValue2 instanceof Boolean);
-    }
-
-    /**
      * Test whether an update works and whether it only affects the
      * specified record.
      * @throws Exception if anything in the test goes wrong.
@@ -1961,214 +1648,6 @@ public class DataTest extends BaseDataba
         }
     }
 
-    /**
-     * Tests whether we can in statements.
-     * @throws Exception if the test fails
-     */
-    public void testIn() throws Exception
-    {
-        cleanBookstore();
-        Author author1 = new Author();
-        author1.setName("author1");
-        author1.save();
-        Author author2 = new Author();
-        author2.setName("author2");
-        author2.save();
-        Author author3 = new Author();
-        author3.setName("author3");
-        author3.save();
-        Book book1 = new Book();
-        book1.setTitle("book1");
-        book1.setIsbn("isbn1");
-        book1.setAuthor(author1);
-        book1.save();
-        Book book2 = new Book();
-        book2.setTitle("book2");
-        book2.setIsbn("isbn2");
-        book2.setAuthor(author1);
-        book2.save();
-        Book book3 = new Book();
-        book3.setTitle("title3");
-        book3.setIsbn(null);
-        book3.setAuthor(author1);
-        book3.save();
-
-        // "in" query with String list and ignoreCase = false
-        {
-            Criteria criteria = new Criteria();
-            List<String> nameList = new ArrayList<String>();
-            nameList.add("author1");
-            nameList.add("author2");
-            criteria.add(AuthorPeer.NAME, nameList, Criteria.IN);
-            criteria.addDescendingOrderByColumn(AuthorPeer.AUTHOR_ID);
-
-            List<Author> result = AuthorPeer.doSelect(criteria);
-            assertEquals("Expected result of size 2 but got " + result.size(),
-                    2,
-                    result.size());
-            Author author = result.get(0);
-            assertEquals("Expected author with Id "
-                    + author2.getAuthorId()
-                    + " at first position but got "
-                    + author.getAuthorId(),
-                    author2.getAuthorId(),
-                    author.getAuthorId());
-            author = result.get(1);
-            assertEquals("Expected author with Id "
-                    + author1.getAuthorId()
-                    + " at second position but got "
-                    + author.getAuthorId(),
-                    author1.getAuthorId(),
-                    author.getAuthorId());
-        }
-
-        // "in" query with Integer list and ignoreCase = true
-        {
-            Criteria criteria = new Criteria();
-            List<Integer> idList = new ArrayList<Integer>();
-            idList.add(author1.getAuthorId());
-            idList.add(author2.getAuthorId());
-            criteria.add(AuthorPeer.AUTHOR_ID, idList, Criteria.IN);
-            criteria.addDescendingOrderByColumn(AuthorPeer.AUTHOR_ID);
-
-            List<Author> result = AuthorPeer.doSelect(criteria);
-            assertEquals("Expected result of size 2 but got " + result.size(),
-                    2,
-                    result.size());
-            Author author = result.get(0);
-            assertEquals("Expected author with Id "
-                    + author2.getAuthorId()
-                    + " at first position but got "
-                    + author.getAuthorId(),
-                    author2.getAuthorId(),
-                    author.getAuthorId());
-            author = result.get(1);
-            assertEquals("Expected author with Id "
-                    + author1.getAuthorId()
-                    + " at second position but got "
-                    + author.getAuthorId(),
-                    author1.getAuthorId(),
-                    author.getAuthorId());
-        }
-
-        // "in" query with String list and null value
-        // TODO fails
-//        {
-//            Criteria criteria = new Criteria();
-//            List<String> isbnList = new ArrayList<String>();
-//
-//            isbnList.add("isbn1");
-//            isbnList.add(null);
-//            criteria.add(BookPeer.ISBN, isbnList, Criteria.IN);
-//            criteria.addAscendingOrderByColumn(BookPeer.BOOK_ID);
-//
-//            List<Book> result = BookPeer.doSelect(criteria);
-//            assertEquals("Expected result of size 2 but got " + result.size(),
-//                    2,
-//                    result.size());
-//            Book book = result.get(0);
-//            assertEquals("Expected book with Id "
-//                    + book1.getBookId()
-//                    + " at first position but got "
-//                    + book.getBookId(),
-//                    book1.getBookId(),
-//                    book.getBookId());
-//            book = result.get(1);
-//            assertEquals("Expected book with Id "
-//                    + book3.getBookId()
-//                    + " at second position but got "
-//                    + book.getBookId(),
-//                    book3.getBookId(),
-//                    book.getBookId());
-//        }
-
-        // "in" query  with array and ignoreCase = false
-        {
-            Criteria criteria = new Criteria();
-            String[] nameArray = new String[] {"author1", "author3"};
-            criteria.add(AuthorPeer.NAME, nameArray, Criteria.IN);
-            criteria.addDescendingOrderByColumn(AuthorPeer.AUTHOR_ID);
-
-            List<Author> result = AuthorPeer.doSelect(criteria);
-            assertEquals("Expected result of size 2 but got " + result.size(),
-                    result.size(),
-                    2);
-            Author author = result.get(0);
-            assertEquals("Expected author with Id "
-                    + author3.getAuthorId()
-                    + " at first position but got "
-                    + author.getAuthorId(),
-                    author3.getAuthorId(),
-                    author.getAuthorId());
-            author = result.get(1);
-            assertEquals("Expected author with Id "
-                    + author1.getAuthorId()
-                    + " at second position but got "
-                    + author.getAuthorId(),
-                    author1.getAuthorId(),
-                    author.getAuthorId());
-        }
-
-        // "in" query with String list and ignoreCase = true
-        {
-            Criteria criteria = new Criteria();
-            List<String> nameList = new ArrayList<String>();
-            nameList.add("AuTHor1");
-            nameList.add("AuTHor2");
-            criteria.add(AuthorPeer.NAME, nameList, Criteria.IN);
-            criteria.setIgnoreCase(true);
-            criteria.addDescendingOrderByColumn(AuthorPeer.AUTHOR_ID);
-
-            List<Author> result = AuthorPeer.doSelect(criteria);
-            assertEquals("Expected result of size 2 but got " + result.size(),
-                    2,
-                    result.size());
-            Author author = result.get(0);
-            assertEquals("Expected author with Id "
-                    + author2.getAuthorId()
-                    + " at first position but got "
-                    + author.getAuthorId(),
-                    author2.getAuthorId(),
-                    author.getAuthorId());
-            author = result.get(1);
-            assertEquals("Expected author with Id "
-                    + author1.getAuthorId()
-                    + " at second position but got "
-                    + author.getAuthorId(),
-                    author1.getAuthorId(),
-                    author.getAuthorId());
-        }
-
-        // "in" query with Integer list and ignoreCase = true
-        {
-            Criteria criteria = new Criteria();
-            List<Integer> idList = new ArrayList<Integer>();
-            idList.add(author1.getAuthorId());
-            idList.add(author2.getAuthorId());
-            criteria.add(AuthorPeer.AUTHOR_ID, idList, Criteria.IN);
-            criteria.setIgnoreCase(true);
-            criteria.addDescendingOrderByColumn(AuthorPeer.AUTHOR_ID);
-
-            List<Author> result = AuthorPeer.doSelect(criteria);
-            assertEquals("Expected result of size 2 but got " + result.size(),
-                    2,
-                    result.size());
-            Author author = result.get(0);
-            assertEquals("Expected author with Id "
-                    + author2.getAuthorId()
-                    + " at first position but got "
-                    + author.getAuthorId(),
-                    author2.getAuthorId(),
-                    author.getAuthorId());
-            author = result.get(1);
-            assertEquals("Expected author with Id "
-                    + author1.getAuthorId()
-                    + " at second position but got "
-                    + author.getAuthorId(),
-                    author1.getAuthorId(),
-                    author.getAuthorId());
-        }
-    }
 
     /**
      * Tests whether a table implementing an interface actually
@@ -2344,8 +1823,8 @@ public class DataTest extends BaseDataba
         author.save();
 
         Criteria criteria = new Criteria();
-        criteria.add(AuthorPeer.AUTHOR_ID, (Object) null, Criteria.NOT_EQUAL);
-        criteria.add("name", "Joshua Bloch", Criteria.EQUAL);
+        criteria.where(AuthorPeer.AUTHOR_ID, (Object) null, Criteria.NOT_EQUAL);
+        criteria.and("name", "Joshua Bloch", Criteria.EQUAL);
         List<Author> authors = AuthorPeer.doSelect(criteria);
         assertEquals(1, authors.size());
     }

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/adapter/AdapterTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/adapter/AdapterTest.java?rev=1237966&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/adapter/AdapterTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/adapter/AdapterTest.java Mon Jan 30 20:19:54 2012
@@ -0,0 +1,76 @@
+package org.apache.torque.adapter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.sql.Connection;
+import java.util.List;
+
+import org.apache.torque.BaseDatabaseTestCase;
+import org.apache.torque.Torque;
+import org.apache.torque.test.Author;
+import org.apache.torque.test.AuthorPeer;
+
+/**
+ * Tests methods in the adapters
+ *
+ * @version $Id: DataTest.java 1213056 2011-12-11 20:31:06Z tfischer $
+ */
+public class AdapterTest extends BaseDatabaseTestCase
+{
+    private List<Author> authorList;
+
+    @Override
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        cleanBookstore();
+        authorList = insertBookstoreData();
+    }
+
+    /**
+     * Tests that locking tables throws no error.
+     * Other behavior is difficult to test as the database may wait
+     * for the connection holding the lock being closed.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testLockTableThrowsNoError() throws Exception
+    {
+        Connection connection = null;
+        try
+        {
+            connection = Torque.getConnection();
+            // lock table
+            Torque.getDB(Torque.getDefaultDB()).lockTable(
+                    connection,
+                    AuthorPeer.TABLE_NAME);
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Torque.getDB(Torque.getDefaultDB()).unlockTable(
+                        connection,
+                        AuthorPeer.TABLE_NAME);
+                connection.close();
+            }
+        }
+    }
+}

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BitTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BitTest.java?rev=1237966&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BitTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BitTest.java Mon Jan 30 20:19:54 2012
@@ -0,0 +1,262 @@
+package org.apache.torque.datatypes;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.torque.BaseDatabaseTestCase;
+import org.apache.torque.TorqueException;
+import org.apache.torque.adapter.DBDerby;
+import org.apache.torque.adapter.DBOracle;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.om.StringKey;
+import org.apache.torque.test.BitCompositePk;
+import org.apache.torque.test.BitCompositePkPeer;
+import org.apache.torque.test.BitValue;
+import org.apache.torque.test.BitValuePeer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * Tests the data types BIT.
+ * @version $Id: $
+ */
+public class BitTest extends BaseDatabaseTestCase
+{
+    private static Log log = LogFactory.getLog(BitTest.class);
+
+    /**
+     * Test whether we can insert into Tables with BIT PKs and BIT values.
+     *
+     * @throws Exception if anything in the test goes wrong.
+     */
+    public void testInsertBitPk() throws Exception
+    {
+        if (!isBitSupported())
+        {
+            // failing is "expected", so exit without error
+            return;
+        }
+        fillTables();
+
+        List<BitCompositePk> bitCompositePks
+                = BitCompositePkPeer.doSelect(new Criteria());
+        assertEquals(3, bitCompositePks.size());
+        List<BitValue> bitValues
+                = BitValuePeer.doSelect(new Criteria());
+        assertEquals(2, bitValues.size());
+    }
+
+    /**
+     * Test whether we can select values using PK values
+     *
+     * @throws Exception if anything in the test goes wrong.
+     */
+    public void testSelectUsingBitPk() throws Exception
+    {
+        if (!isBitSupported())
+        {
+            // failing is "expected", so exit without error
+            return;
+        }
+        fillTables();
+
+        // check we get correct result when pks match
+        Criteria criteria = new Criteria();
+        criteria.and(BitCompositePkPeer.PK1, "false value");
+        criteria.and(BitCompositePkPeer.PK2, Boolean.FALSE);
+        List<BitCompositePk> result
+            = BitCompositePkPeer.doSelect(criteria);
+        assertEquals(1, result.size());
+        assertEquals("false payload", result.get(0).getPayload());
+
+        criteria = new Criteria();
+        criteria.and(BitCompositePkPeer.PK1, "true value");
+        criteria.and(BitCompositePkPeer.PK2, Boolean.TRUE);
+        result = BitCompositePkPeer.doSelect(criteria);
+        assertEquals(1, result.size());
+        assertEquals("true payload", result.get(0).getPayload());
+    }
+
+    /**
+     * Test we can update values in a table where a BIT pk is used.
+     *
+     * @throws Exception if anything in the test goes wrong.
+     */
+    public void testUpdateWithBitPk() throws Exception
+    {
+        if (!isBitSupported())
+        {
+            // failing is "expected", so exit without error
+            return;
+        }
+        fillTables();
+
+        // check we get correct result when pks match
+
+        // check updating works
+        Criteria criteria = new Criteria().and(
+                BitCompositePkPeer.PK1, "true value");
+        criteria.and(BitCompositePkPeer.PK2, Boolean.TRUE);
+        List<BitCompositePk> selectResult
+                = BitCompositePkPeer.doSelect(criteria);
+        selectResult.get(0).setPayload("true updated payload");
+        selectResult.get(0).save();
+
+        criteria = new Criteria();
+        criteria.and(BitCompositePkPeer.PK1, "true value");
+        criteria.and(BitCompositePkPeer.PK2, Boolean.TRUE);
+        selectResult = BitCompositePkPeer.doSelect(criteria);
+        assertEquals(1, selectResult.size());
+        assertEquals("true updated payload", selectResult.get(0).getPayload());
+    }
+
+    /**
+     * Tests whether column type BIT can be written and read correctly
+     * and works in criteria as expected
+     * @throws Exception if the test fails
+     */
+    public void testReadBitValue() throws Exception
+    {
+        if (!isBitSupported())
+        {
+            // failing is "expected", so exit without error
+            return;
+        }
+        fillTables();
+
+        // read data
+        BitValue bitValue = BitValuePeer.retrieveByPK(new StringKey("t1"));
+        assertTrue("BIT should be true but is: "
+                + bitValue.getBitValue(), bitValue.getBitValue());
+
+        bitValue = BitValuePeer.retrieveByPK(new StringKey("f1"));
+        assertFalse("BIT should be false but is: "
+                + bitValue.getBitValue(), bitValue.getBitValue());
+    }
+
+    /**
+     * Tests whether column type BIT works if set to true in Criteria.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testSelectBitTypeByTrueValue() throws Exception
+    {
+        if (!isBitSupported())
+        {
+            // failing is "expected", so exit without error
+            return;
+        }
+        // query data
+        Criteria criteria = new Criteria()
+                .where(BitValuePeer.BIT_VALUE, new Boolean(true));
+        List<BitValue> bitValueList = BitValuePeer.doSelect(criteria);
+        assertTrue("Should have read 1 dataset "
+                + "but read " + bitValueList.size(),
+                bitValueList.size() == 1);
+        BitValue bitValue = bitValueList.get(0);
+        // use trim() for testkey because some databases will return the
+        // testkey filled up with blanks, as it is defined as char(10)
+        assertTrue("Primary key of data set should be t1 but is "
+                + bitValue.getId(),
+                "t1".equals(bitValue.getId()));
+    }
+
+    /**
+     * Tests whether column type BIT works if set to false in Criteria.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testSelectBitTypeByFalseValue() throws Exception
+    {
+        if (!isBitSupported())
+        {
+            // failing is "expected", so exit without error
+            return;
+        }
+        Criteria criteria = new Criteria().where(
+                BitValuePeer.BIT_VALUE, new Boolean(false));
+        List<BitValue> bitValueList = BitValuePeer.doSelect(criteria);
+        assertTrue("Should have read 1 dataset "
+                + "but read " + bitValueList.size(),
+                bitValueList.size() == 1);
+        BitValue bitValue = bitValueList.get(0);
+        assertTrue("Primary key of data set should be f1 but is "
+                + bitValue.getId(),
+                "f1".equals(bitValue.getId()));
+    }
+
+    /**
+     * Checks whether the BIT type is supported in the database.
+     * If not, a message is logged in the log file.
+     *
+     * @return true if the type is supported, false otherwise.
+     */
+    private boolean isBitSupported()
+    {
+        if (defaultAdapter instanceof DBOracle
+                || defaultAdapter instanceof DBDerby)
+        {
+            log.warn("isBitSupported(): "
+                    + "BIT is known not to work with "
+                    + "Oracle and Derby");
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Delete all previous data from the tested tables
+     * and re-inserts test data.
+     */
+    private void fillTables() throws TorqueException
+    {
+        BitCompositePkPeer.doDelete(new Criteria());
+        BitValuePeer.doDelete(new Criteria());
+
+        BitCompositePk bitCompositePk = new BitCompositePk();
+        bitCompositePk.setPk1("false value");
+        bitCompositePk.setPk2(Boolean.FALSE);
+        bitCompositePk.setPayload("false payload");
+        bitCompositePk.save();
+
+        bitCompositePk = new BitCompositePk();
+        bitCompositePk.setPk1("true value");
+        bitCompositePk.setPk2(Boolean.TRUE);
+        bitCompositePk.setPayload("true payload");
+        bitCompositePk.save();
+
+        bitCompositePk = new BitCompositePk();
+        bitCompositePk.setPk1("value");
+        bitCompositePk.setPk2(Boolean.TRUE);
+        bitCompositePk.setPayload("payload");
+        bitCompositePk.save();
+
+        BitValue bitValue = new BitValue();
+        bitValue.setId("t1");
+        bitValue.setBitValue(true);
+        bitValue.save();
+
+        bitValue = new BitValue();
+        bitValue.setId("f1");
+        bitValue.setBitValue(false);
+        bitValue.save();
+    }
+}

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java?rev=1237966&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java Mon Jan 30 20:19:54 2012
@@ -0,0 +1,270 @@
+package org.apache.torque.datatypes;
+
+import java.util.List;
+
+import org.apache.torque.BaseDatabaseTestCase;
+import org.apache.torque.ColumnImpl;
+import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.criteria.Criterion;
+import org.apache.torque.om.StringKey;
+import org.apache.torque.test.BintBcharValue;
+import org.apache.torque.test.BintBcharValuePeer;
+import org.apache.torque.util.BasePeer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * Tests the data types BOOLEANINT and BOOLEANCHAR.
+ * @version $Id: $
+ */
+public class BooleanIntCharTest extends BaseDatabaseTestCase
+{
+    /**
+     * Test inserting and reading boolean values.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testReadBooleanIntCharValues() throws Exception
+    {
+        fillTables();
+
+        BintBcharValue bc
+                = BintBcharValuePeer.retrieveByPK(new StringKey("t1"));
+        assertTrue("BOOLEANINT should be true but is: "
+                + bc.getBintValue(), bc.getBintValue());
+        assertTrue("BOOLEANCHAR should be true but is: "
+                + bc.getBcharValue(), bc.getBcharValue());
+        bc = BintBcharValuePeer.retrieveByPK(new StringKey("f1"));
+        assertFalse("BOOLEANINT should be false but is: "
+                + bc.getBintValue(), bc.getBintValue());
+        assertFalse("BOOLEANCHAR should be false but is: "
+                + bc.getBcharValue(), bc.getBcharValue());
+    }
+
+
+    /**
+     * Check whether we can impose the condition Boolean True to
+     * booleanint/booleanchar columns.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testBooleanTrueSelect() throws Exception
+    {
+        Criteria criteria = new Criteria()
+                .where(BintBcharValuePeer.BCHAR_VALUE, new Boolean(true))
+                .and(BintBcharValuePeer.BINT_VALUE, new Boolean(true));
+        List<BintBcharValue> selectedList
+            = BintBcharValuePeer.doSelect(criteria);
+        assertTrue("Should have read 1 dataset with both values true "
+                + "but read " + selectedList.size(),
+                selectedList.size() == 1);
+        BintBcharValue bintBcharValue = selectedList.get(0);
+        assertTrue("Primary key of data set should be t1 but is "
+                + bintBcharValue.getId(),
+                "t1".equals(bintBcharValue.getId()));
+    }
+
+    /**
+     * Check whether we can impose the condition Boolean False to
+     * booleanint/booleanchar columns.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testBooleanFalseSelect() throws Exception
+    {
+        Criteria criteria = new Criteria()
+                .where(BintBcharValuePeer.BCHAR_VALUE, new Boolean(false))
+                .and(BintBcharValuePeer.BINT_VALUE, new Boolean(false));
+        List<BintBcharValue> selectedList = BintBcharValuePeer.doSelect(criteria);
+        assertTrue("Should have read 1 dataset with both values false "
+                + "but read " + selectedList.size(),
+                selectedList.size() == 1);
+        BintBcharValue bintBcharValue = selectedList.get(0);
+        assertTrue("Primary key of data set should be f1 but is "
+                + bintBcharValue.getId(),
+                "f1".equals(bintBcharValue.getId()));
+    }
+
+    /**
+     * Check whether we can impose a Boolean condition to booleanint/booleanchar
+     * columns via joins.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testBooleanSelectViaJoins() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        criteria.addAlias("bc", BintBcharValuePeer.TABLE_NAME);
+        criteria.addJoin(
+                BintBcharValuePeer.ID,
+                new ColumnImpl("bc.id"));
+        criteria.where("bc.bint_value", new Boolean(false));
+        criteria.and("bc.bchar_value", new Boolean(false));
+        List<BintBcharValue> selectedList
+                = BintBcharValuePeer.doSelect(criteria);
+        assertTrue("Should have read 1 dataset with both values false "
+                + "but read " + selectedList.size(),
+                selectedList.size() == 1);
+        BintBcharValue bintBcharValue = selectedList.get(0);
+        assertTrue("Primary key of data set should be f1 but is "
+                + bintBcharValue.getId(),
+                "f1".equals(bintBcharValue.getId()));
+    }
+
+    /**
+     * Check whether we can impose a Boolean condition in
+     * chained criterions and get no hits using a unfullfillable condition.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testBooleanSelectInChainedCriterionsNoHits() throws Exception
+    {
+        // check whether complex criteria are overwritten by
+        // replaceBooleans
+        Criteria criteria = new Criteria();
+        Criterion criterion1 = new Criterion(
+                BintBcharValuePeer.BCHAR_VALUE,
+                Boolean.FALSE,
+                Criteria.EQUAL);
+        Criterion criterion2 = new Criterion(
+                BintBcharValuePeer.BCHAR_VALUE,
+                null,
+                Criteria.ISNULL);
+        criteria.where(criterion1.and(criterion2));
+        List<BintBcharValue> selectedList
+                = BintBcharValuePeer.doSelect(criteria);
+        // List should be empty, because and creates unfulfillable condition
+        // If BasePeer.correctBooleans() replaces Criterion wrongly,
+        // then we get entries in the list.
+        assertTrue("List should be empty but contains "
+                + selectedList.size() + " datasets",
+                selectedList.isEmpty());
+    }
+
+    /**
+     * Check whether we can impose a Boolean condition in
+     * chained criterions and get a hits using OR.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testBooleanSelectInChainedCriterionsUsingOr() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        Criterion criterion1 = new Criterion(
+                BintBcharValuePeer.BCHAR_VALUE,
+                null,
+                Criteria.ISNULL);
+        Criterion criterion2 = new Criterion(
+                BintBcharValuePeer.BCHAR_VALUE,
+                Boolean.FALSE,
+                Criteria.EQUAL);
+        criteria.where(criterion1.or(criterion2));
+        List<BintBcharValue> selectedList
+                = BintBcharValuePeer.doSelect(criteria);
+        assertTrue("Should have read 1 dataset complex Criteria "
+                + "but read " + selectedList.size(),
+                selectedList.size() == 1);
+        BintBcharValue selected = selectedList.get(0);
+        // use trim() for testkey because some databases will return the
+        // testkey filled up with blanks, as it is defined as char(10)
+        assertTrue("Primary key of data set should be f1 but is "
+                + selected.getId(),
+                "f1".equals(selected.getId()));
+    }
+
+    /**
+     * Check whether CorrectBooleans works also on unqualified columns.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testCorrectBooleansInUnqualifiedColumns() throws Exception
+    {
+        // check whether booleans are replaced with unqualified columns
+        Criteria criteria = new Criteria()
+            .where("BooleanCheck.bint_value", true)
+            .and("BooleanCheck.bchar_value", true);
+
+        BintBcharValuePeer.correctBooleans(criteria);
+
+        Criterion criterionInt
+                = criteria.getTopLevelCriterion().getParts().get(0);
+        Object intValue = criterionInt.getValue();
+
+        assertTrue("The boolean value should be an instance of Integer",
+                intValue instanceof Integer);
+
+        Criterion criterionChar
+                = criteria.getTopLevelCriterion().getParts().get(1);
+        Object charValue = criterionChar.getValue();
+
+        assertTrue("The boolean value should be an instance of String",
+                charValue instanceof String);
+    }
+
+    /**
+     * Check whether CorrectBooleans leaves unknown columns alone.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testCorrectBooleansUnknownColumns() throws Exception
+    {
+        Criteria criteria = new Criteria()
+            .where("BooleanCheck.bint_value", true)
+            .and("BooleanCheck.bchar_value", true);
+
+        BasePeer.correctBooleans(criteria, null);
+
+        Criterion criterionBool1
+                = criteria.getTopLevelCriterion().getParts().get(0);
+        Object boolValue1 = criterionBool1.getValue();
+
+        assertTrue("The boolean value should be an instance of Boolean",
+               boolValue1 instanceof Boolean);
+
+        Criterion criterionBool2
+                = criteria.getTopLevelCriterion().getParts().get(1);
+        Object boolValue2 = criterionBool2.getValue();
+
+        assertTrue("The boolean value should be an instance of Boolean",
+               boolValue2 instanceof Boolean);
+    }
+
+    /**
+     * Delete all previous data from the tested tables
+     * and re-inserts test data.
+     */
+    private void fillTables() throws TorqueException
+    {
+        Criteria criteria = new Criteria();
+        BintBcharValuePeer.doDelete(criteria);
+
+        BintBcharValue bc = new BintBcharValue();
+        bc.setId("t1");
+        bc.setBintValue(true);
+        bc.setBcharValue(true);
+        bc.save();
+        bc = new BintBcharValue();
+        bc.setId("f1");
+        bc.setBintValue(false);
+        bc.setBcharValue(false);
+        bc.save();
+    }
+}

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/GetRelatedObjectsTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/GetRelatedObjectsTest.java?rev=1237966&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/GetRelatedObjectsTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/GetRelatedObjectsTest.java Mon Jan 30 20:19:54 2012
@@ -0,0 +1,158 @@
+package org.apache.torque.generated.peer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.util.List;
+
+import org.apache.torque.BaseDatabaseTestCase;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.test.Author;
+import org.apache.torque.test.AuthorPeer;
+import org.apache.torque.test.Book;
+import org.apache.torque.test.BookPeer;
+
+/**
+ * Tests whether the getRelatedObjects methodd works
+ *
+ * @version $Id: DataTest.java 1213056 2011-12-11 20:31:06Z tfischer $
+ */
+public class GetRelatedObjectsTest extends BaseDatabaseTestCase
+{
+    private List<Author> authorList;
+
+    @Override
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        cleanBookstore();
+        authorList = insertBookstoreData();
+    }
+
+    /**
+     * Tests getters of related objects.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testGetRelatedObjects() throws Exception
+    {
+        Criteria criteria = new Criteria().where(
+                AuthorPeer.AUTHOR_ID,
+                authorList.get(0).getAuthorId());
+        Author author = AuthorPeer.doSelect(criteria).get(0);
+
+        // execute loading books
+        List<Book> books = author.getBooks();
+
+        // verify
+        assertEquals(10, books.size());
+        assertTrue(books.get(0).getTitle().endsWith("- Author 1"));
+    }
+
+    /**
+     * Tests getters of related objects, after the collection was initialized.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testGetRelatedObjectsAfterInit() throws Exception
+    {
+        Criteria criteria = new Criteria().where(
+                AuthorPeer.AUTHOR_ID,
+                authorList.get(0).getAuthorId());
+        Author author = AuthorPeer.doSelect(criteria).get(0);
+
+        // execute : init, then load books
+        author.initBooks();
+        List<Book> books = author.getBooks();
+
+        // verify
+        // Books should not be loaded from db but cache should be used
+        assertEquals(0, books.size());
+    }
+
+    /**
+     * Tests getters of related objects with a Criteria object
+     *
+     * @throws Exception if the test fails
+     */
+    public void testGetRelatedObjectsWithCriteria() throws Exception
+    {
+        Criteria criteria = new Criteria().where(
+                AuthorPeer.AUTHOR_ID,
+                authorList.get(0).getAuthorId());
+        Author author = AuthorPeer.doSelect(criteria).get(0);
+        Book book = authorList.get(0).getBooks().get(2);
+
+        // execute : load books
+        criteria = new Criteria().where(BookPeer.BOOK_ID, book.getBookId());
+        List<Book> books = author.getBooks(criteria);
+
+        // verify
+        assertEquals(1, books.size());
+        assertEquals(book.getBookId(), books.get(0).getBookId());
+    }
+
+    /**
+     * Tests getters of related objects with a Criteria object
+     * after the related objects were loaded with another criteria.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testGetRelatedObjectsWithOtherCriteria() throws Exception
+    {
+        Criteria criteria = new Criteria().where(
+                AuthorPeer.AUTHOR_ID,
+                authorList.get(0).getAuthorId());
+        Author author = AuthorPeer.doSelect(criteria).get(0);
+        author.getBooks();
+        Book book = authorList.get(0).getBooks().get(2);
+
+        // execute : load books
+        criteria = new Criteria().where(BookPeer.BOOK_ID, book.getBookId());
+        List<Book> books = author.getBooks(criteria);
+
+        // verify
+        assertEquals(1, books.size());
+        assertEquals(book.getBookId(), books.get(0).getBookId());
+    }
+
+    /**
+     * Tests getters of related objects with a Criteria object
+     * after the init method was called on the collection.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testGetRelatedObjectsWithCriteriaAfterInit() throws Exception
+    {
+        Criteria criteria = new Criteria().where(
+                AuthorPeer.AUTHOR_ID,
+                authorList.get(0).getAuthorId());
+        Author author = AuthorPeer.doSelect(criteria).get(0);
+        author.initBooks();
+        Book book = authorList.get(0).getBooks().get(2);
+
+        // execute : load books
+        criteria = new Criteria().where(BookPeer.BOOK_ID, book.getBookId());
+        List<Book> books = author.getBooks(criteria);
+
+        // verify
+        assertEquals(1, books.size());
+        assertEquals(book.getBookId(), books.get(0).getBookId());
+    }
+}

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectInTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectInTest.java?rev=1237966&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectInTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectInTest.java Mon Jan 30 20:19:54 2012
@@ -0,0 +1,252 @@
+package org.apache.torque.generated.peer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.util.ArrayList;
+import java.util.List;
+
+import org.apache.torque.BaseDatabaseTestCase;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.test.Author;
+import org.apache.torque.test.AuthorPeer;
+import org.apache.torque.test.Book;
+import org.apache.torque.test.BookPeer;
+
+/**
+ * Tests selects using the IN operator.
+ *
+ * @version $Id: DataTest.java 1213056 2011-12-11 20:31:06Z tfischer $
+ */
+public class SelectInTest extends BaseDatabaseTestCase
+{
+    private List<Author> authorList;
+
+    @Override
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        cleanBookstore();
+        authorList = insertBookstoreData();
+    }
+
+    /**
+     * Tests "in" query with String list and ignoreCase = false.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testInWithStringListNoIgnoreCase() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        List<String> nameList = new ArrayList<String>();
+        nameList.add("Author 1");
+        nameList.add("Author 2");
+        criteria.where(AuthorPeer.NAME, nameList, Criteria.IN);
+        criteria.addDescendingOrderByColumn(AuthorPeer.AUTHOR_ID);
+
+        List<Author> result = AuthorPeer.doSelect(criteria);
+        assertEquals("Expected result of size 2 but got " + result.size(),
+                2,
+                result.size());
+        Author author = result.get(0);
+        assertEquals("Expected author with Id "
+                + authorList.get(1).getAuthorId()
+                + " at first position but got "
+                + author.getAuthorId(),
+                authorList.get(1).getAuthorId(),
+                author.getAuthorId());
+        author = result.get(1);
+        assertEquals("Expected author with Id "
+                + authorList.get(0).getAuthorId()
+                + " at second position but got "
+                + author.getAuthorId(),
+                authorList.get(0).getAuthorId(),
+                author.getAuthorId());
+    }
+
+    /**
+     * Tests "in" query with String list and ignoreCase = true.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testInWithIntegerListNoIgnoreCase() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        List<Integer> idList = new ArrayList<Integer>();
+        idList.add(authorList.get(0).getAuthorId());
+        idList.add(authorList.get(1).getAuthorId());
+        criteria.where(AuthorPeer.AUTHOR_ID, idList, Criteria.IN);
+        criteria.addDescendingOrderByColumn(AuthorPeer.AUTHOR_ID);
+
+        List<Author> result = AuthorPeer.doSelect(criteria);
+        assertEquals("Expected result of size 2 but got " + result.size(),
+                2,
+                result.size());
+        Author author = result.get(0);
+        assertEquals("Expected author with Id "
+                + authorList.get(1).getAuthorId()
+                + " at first position but got "
+                + author.getAuthorId(),
+                authorList.get(1).getAuthorId(),
+                author.getAuthorId());
+        author = result.get(1);
+        assertEquals("Expected author with Id "
+                + authorList.get(0).getAuthorId()
+                + " at second position but got "
+                + author.getAuthorId(),
+                authorList.get(0).getAuthorId(),
+                author.getAuthorId());
+    }
+
+    /**
+     * Tests "in" query with String list containing null value.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testInWithStringListAndNullValue() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        List<String> isbnList = new ArrayList<String>();
+
+        isbnList.add("ISBN 1 - 1");
+        isbnList.add(null);
+        criteria.where(BookPeer.ISBN, isbnList, Criteria.IN);
+        criteria.addAscendingOrderByColumn(BookPeer.BOOK_ID);
+
+        List<Book> result = BookPeer.doSelect(criteria);
+        assertEquals("Expected result of size 11 but got " + result.size(),
+                11,
+                result.size());
+        Book book = result.get(0);
+        assertEquals("Expected book with Id "
+                + authorList.get(0).getBooks().get(0).getBookId()
+                + " at first position but got "
+                + book.getBookId(),
+                authorList.get(0).getBooks().get(0).getBookId(),
+                book.getBookId());
+        book = result.get(1);
+        assertEquals("Expected book with ISBN null "
+                + " at second position but got "
+                + book.getIsbn(),
+                null,
+                book.getIsbn());
+    }
+
+    /**
+     * Tests "in" query with String array and ignoreCase = false.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testInWithStringArrayIgnoreCaseFalse() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        String[] nameArray = new String[] {"Author 1", "Author 3"};
+        criteria.where(AuthorPeer.NAME, nameArray, Criteria.IN);
+        criteria.addDescendingOrderByColumn(AuthorPeer.AUTHOR_ID);
+
+        List<Author> result = AuthorPeer.doSelect(criteria);
+        assertEquals("Expected result of size 2 but got " + result.size(),
+                result.size(),
+                2);
+        Author author = result.get(0);
+        assertEquals("Expected author with Id "
+                + authorList.get(2).getAuthorId()
+                + " at first position but got "
+                + author.getAuthorId(),
+                authorList.get(2).getAuthorId(),
+                author.getAuthorId());
+        author = result.get(1);
+        assertEquals("Expected author with Id "
+                + authorList.get(0).getAuthorId()
+                + " at second position but got "
+                + author.getAuthorId(),
+                authorList.get(0).getAuthorId(),
+                author.getAuthorId());
+    }
+
+    /**
+     * Tests "in" query with String list and ignoreCase = true.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testInWithStringListIgnoreCaseTrue() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        List<String> nameList = new ArrayList<String>();
+        nameList.add("AuTHor 1");
+        nameList.add("AuTHor 2");
+        criteria.where(AuthorPeer.NAME, nameList, Criteria.IN);
+        criteria.setIgnoreCase(true);
+        criteria.addDescendingOrderByColumn(AuthorPeer.AUTHOR_ID);
+
+        List<Author> result = AuthorPeer.doSelect(criteria);
+        assertEquals("Expected result of size 2 but got " + result.size(),
+                2,
+                result.size());
+        Author author = result.get(0);
+        assertEquals("Expected author with Id "
+                + authorList.get(1).getAuthorId()
+                + " at first position but got "
+                + author.getAuthorId(),
+                authorList.get(1).getAuthorId(),
+                author.getAuthorId());
+        author = result.get(1);
+        assertEquals("Expected author with Id "
+                + authorList.get(0).getAuthorId()
+                + " at second position but got "
+                + author.getAuthorId(),
+                authorList.get(0).getAuthorId(),
+                author.getAuthorId());
+    }
+
+    /**
+     * Tests "in" query with Integer list and ignoreCase = true.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testInWithIntegerListIgnoreCaseTrue() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        List<Integer> idList = new ArrayList<Integer>();
+        idList.add(authorList.get(0).getAuthorId());
+        idList.add(authorList.get(1).getAuthorId());
+        criteria.where(AuthorPeer.AUTHOR_ID, idList, Criteria.IN);
+        criteria.setIgnoreCase(true);
+        criteria.addDescendingOrderByColumn(AuthorPeer.AUTHOR_ID);
+
+        List<Author> result = AuthorPeer.doSelect(criteria);
+        assertEquals("Expected result of size 2 but got " + result.size(),
+                2,
+                result.size());
+        Author author = result.get(0);
+        assertEquals("Expected author with Id "
+                + authorList.get(1).getAuthorId()
+                + " at first position but got "
+                + author.getAuthorId(),
+                authorList.get(1).getAuthorId(),
+                author.getAuthorId());
+        author = result.get(1);
+        assertEquals("Expected author with Id "
+                + authorList.get(0).getAuthorId()
+                + " at second position but got "
+                + author.getAuthorId(),
+                authorList.get(0).getAuthorId(),
+                author.getAuthorId());
+    }
+}

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java?rev=1237966&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java Mon Jan 30 20:19:54 2012
@@ -0,0 +1,63 @@
+package org.apache.torque.oid;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.sql.Connection;
+
+import org.apache.torque.BaseDatabaseTestCase;
+import org.apache.torque.Torque;
+import org.apache.torque.test.AuthorPeer;
+
+/**
+ * Tests methods in the adapters
+ *
+ * @version $Id: DataTest.java 1213056 2011-12-11 20:31:06Z tfischer $
+ */
+public class IDBrokerTest extends BaseDatabaseTestCase
+{
+    private IDBroker idBroker;
+
+    @Override
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        idBroker = new IDBroker(Torque.getDatabase(Torque.getDefaultDB()));
+    }
+
+    /**
+     * Tests that restarting the idBroker clears its cache.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testRestartIdBroker() throws Exception
+    {
+        idBroker.start();
+        Connection connection = Torque.getConnection();
+        int id = idBroker.getIdAsInt(connection, AuthorPeer.TABLE_NAME);
+        idBroker.stop();
+        while (idBroker.isThreadRunning()) {
+            Thread.sleep(1000);
+        }
+        idBroker.start();
+        int nextId = idBroker.getIdAsInt(connection, AuthorPeer.TABLE_NAME);
+        // assuming quantity > 1
+        assertTrue(nextId > id + 1);
+    }
+}



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


Mime
View raw message