db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1369256 - in /db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque: DataTest.java util/LargeSelectTest.java
Date Sat, 04 Aug 2012 03:44:48 GMT
Author: tfischer
Date: Sat Aug  4 03:44:48 2012
New Revision: 1369256

URL: http://svn.apache.org/viewvc?rev=1369256&view=rev
Log:
Do not use deprecated criteria methods any more

Modified:
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java

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=1369256&r1=1369255&r2=1369256&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 Sat
Aug  4 03:44:48 2012
@@ -122,7 +122,7 @@ public class DataTest extends BaseDataba
     {
         // clean table
         Criteria criteria = new Criteria();
-        criteria.add(MultiPkPeer.PK1, (Object) null, Criteria.NOT_EQUAL);
+        criteria.where(MultiPkPeer.PK1, (Object) null, Criteria.NOT_EQUAL);
         MultiPkPeer.doDelete(criteria);
 
         // do test
@@ -155,11 +155,11 @@ public class DataTest extends BaseDataba
         }
 
         Criteria crit = new Criteria();
-        Criterion c = crit.getNewCriterion(BookPeer.TITLE,
+        Criterion c = new Criterion(BookPeer.TITLE,
                 "Book 6 - Author 1", Criteria.GREATER_EQUAL);
-        c.and(crit.getNewCriterion(BookPeer.TITLE,
+        c.and(new Criterion(BookPeer.TITLE,
                 "Book 8 - Author 3", Criteria.LESS_EQUAL));
-        crit.add(c);
+        crit.where(c);
         crit.addDescendingOrderByColumn(BookPeer.BOOK_ID);
         crit.setLimit(10);
         crit.setOffset(5);
@@ -248,7 +248,7 @@ public class DataTest extends BaseDataba
     {
         // clean table
         Criteria criteria = new Criteria();
-        criteria.add(
+        criteria.where(
                 NullValueTablePeer.NULL_VALUE_TABLE_ID,
                 -1,
                 Criteria.NOT_EQUAL);
@@ -265,11 +265,11 @@ public class DataTest extends BaseDataba
 
         // do check for comparison NOT_EQUAL and value null
         criteria = new Criteria();
-        criteria.add(
+        criteria.where(
                 NullValueTablePeer.TEXT1,
                 (Integer)null,
                 Criteria.NOT_EQUAL);
-        criteria.add(NullValueTablePeer.NUMBER_OBJ1,
+        criteria.and(NullValueTablePeer.NUMBER_OBJ1,
                 (Integer)null,
                 Criteria.NOT_EQUAL);
         List<NullValueTable> result = NullValueTablePeer.doSelect(criteria);
@@ -287,11 +287,11 @@ public class DataTest extends BaseDataba
 
         // do check for comparison EQUAL and value null
         criteria = new Criteria();
-        criteria.add(
+        criteria.where(
                 NullValueTablePeer.TEXT1,
                 (Integer)null,
                 Criteria.EQUAL);
-        criteria.add(NullValueTablePeer.NUMBER_OBJ1,
+        criteria.and(NullValueTablePeer.NUMBER_OBJ1,
                 (Integer)null,
                 Criteria.EQUAL);
         result = NullValueTablePeer.doSelect(criteria);
@@ -461,7 +461,7 @@ public class DataTest extends BaseDataba
         try
         {
             Criteria criteria = new Criteria();
-            criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL);
+            criteria.where(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL);
             BookPeer.doDelete(criteria, (Connection) null);
             fail("NullPointerException expected");
         }
@@ -669,7 +669,7 @@ public class DataTest extends BaseDataba
         author.save();
 
         Criteria criteria = new Criteria();
-        criteria.add(AuthorPeer.NAME, author.getName().toLowerCase());
+        criteria.where(AuthorPeer.NAME, author.getName().toLowerCase());
         criteria.setIgnoreCase(true);
         List<Author> result = AuthorPeer.doSelect(criteria);
         assertTrue("Size of result is not 1, but " + result.size(),
@@ -677,7 +677,7 @@ public class DataTest extends BaseDataba
 
         // LIKE treatment might be different (e.g. postgres), so check extra
         criteria = new Criteria();
-        criteria.add(
+        criteria.where(
                 AuthorPeer.NAME,
                 author.getName().toLowerCase().replace('r', '%'),
                 Criteria.LIKE);
@@ -688,12 +688,12 @@ public class DataTest extends BaseDataba
 
         // Test ignore case in criterion
         criteria = new Criteria();
-        Criterion criterion1 = criteria.getNewCriterion(
+        Criterion criterion1 = new Criterion(
                 AuthorPeer.NAME,
                 author.getName().toLowerCase(),
                 Criteria.EQUAL);
         criterion1.setIgnoreCase(true);
-        Criterion criterion2 = criteria.getNewCriterion(
+        Criterion criterion2 = new Criterion(
                 AuthorPeer.AUTHOR_ID, null, Criteria.NOT_EQUAL);
         criterion1.and(criterion2);
 
@@ -709,9 +709,9 @@ public class DataTest extends BaseDataba
 
         // Test ignore case in attached criterion
         criteria = new Criteria();
-        criterion1 = criteria.getNewCriterion(
+        criterion1 = new Criterion(
                 AuthorPeer.AUTHOR_ID, null, Criteria.NOT_EQUAL);
-        criterion2 = criteria.getNewCriterion(
+        criterion2 = new Criterion(
                 AuthorPeer.NAME,
                 author.getName().toLowerCase(),
                 Criteria.EQUAL);
@@ -733,7 +733,7 @@ public class DataTest extends BaseDataba
             criteria = new Criteria();
             Set<String> names = new HashSet<String>();
             names.add(author.getName().toLowerCase());
-            criteria.add(AuthorPeer.NAME, names, Criteria.IN);
+            criteria.where(AuthorPeer.NAME, names, Criteria.IN);
             criteria.setIgnoreCase(true);
 
             result = AuthorPeer.doSelect(criteria);
@@ -760,14 +760,14 @@ public class DataTest extends BaseDataba
         else
         {
             criteria = new Criteria();
-            criteria.add(AuthorPeer.NAME, author.getName());
+            criteria.where(AuthorPeer.NAME, author.getName());
             result = AuthorPeer.doSelect(criteria);
             assertTrue("Size of result is not 1, but " + result.size(),
                     result.size() == 1);
 
             // again check LIKE treatment
             criteria = new Criteria();
-            criteria.add(
+            criteria.where(
                     AuthorPeer.NAME,
                     author.getName().replace('r', '%'),
                     Criteria.LIKE);
@@ -777,17 +777,17 @@ public class DataTest extends BaseDataba
 
             // Test different ignore cases in criterions
             criteria = new Criteria();
-            criterion1 = criteria.getNewCriterion(
+            criterion1 = new Criterion(
                     AuthorPeer.NAME,
                     author.getName().toLowerCase(),
                     Criteria.NOT_EQUAL);
-            criterion2 = criteria.getNewCriterion(
+            criterion2 = new Criterion(
                     AuthorPeer.NAME,
                     author.getName().toLowerCase(),
                     Criteria.EQUAL);
             criterion2.setIgnoreCase(true);
             criterion1.and(criterion2);
-            criteria.add(criterion1);
+            criteria.where(criterion1);
 
             result = AuthorPeer.doSelect(criteria);
             assertTrue("Size of result is not 1, but " + result.size(),
@@ -798,7 +798,7 @@ public class DataTest extends BaseDataba
                 criteria = new Criteria();
                 Set<String> names = new HashSet<String>();
                 names.add(author.getName());
-                criteria.add(AuthorPeer.NAME, names, Criteria.IN);
+                criteria.where(AuthorPeer.NAME, names, Criteria.IN);
 
                 result = AuthorPeer.doSelect(criteria);
                 assertEquals("Expected result of size 1 but got " + result.size(),
@@ -913,7 +913,7 @@ public class DataTest extends BaseDataba
     {
         // clean LargePk table
         Criteria criteria = new Criteria();
-        criteria.add(
+        criteria.where(
                 LargePkPeer.ID,
                 (Long) null,
                 Criteria.NOT_EQUAL);
@@ -974,7 +974,7 @@ public class DataTest extends BaseDataba
         }
 
         criteria = new Criteria();
-        criteria.add(AuthorPeer.NAME, "Name2");
+        criteria.where(AuthorPeer.NAME, "Name2");
         count = new CountHelper().count(criteria);
 
         if (count != 1) {
@@ -993,10 +993,10 @@ public class DataTest extends BaseDataba
     {
         // clean IntegerPk and MultiPkForeignKey table
         Criteria criteria = new Criteria();
-        criteria.add(MultiPkForeignKeyPeer.ID, (Integer) null, Criteria.NOT_EQUAL);
+        criteria.where(MultiPkForeignKeyPeer.ID, (Integer) null, Criteria.NOT_EQUAL);
         MultiPkForeignKeyPeer.doDelete(criteria);
         criteria = new Criteria();
-        criteria.add(IntegerPkPeer.ID, (Integer) null, Criteria.NOT_EQUAL);
+        criteria.where(IntegerPkPeer.ID, (Integer) null, Criteria.NOT_EQUAL);
         IntegerPkPeer.doDelete(criteria);
 
         IntegerPk integerPk = new IntegerPk();
@@ -1034,7 +1034,7 @@ public class DataTest extends BaseDataba
         // clean BlobTest table
         {
             Criteria criteria = new Criteria();
-            criteria.add(
+            criteria.where(
                     BlobTestPeer.ID,
                     (Long) null,
                     Criteria.NOT_EQUAL);
@@ -1119,7 +1119,7 @@ public class DataTest extends BaseDataba
         // clean ClobTest table
         {
             Criteria criteria = new Criteria();
-            criteria.add(
+            criteria.where(
                     ClobTestPeer.ID,
                     (Long) null,
                     Criteria.NOT_EQUAL);
@@ -1216,7 +1216,7 @@ public class DataTest extends BaseDataba
     public void testInterface() throws Exception
     {
         Criteria criteria = new Criteria();
-        criteria.add(IfcTablePeer.ID, -1, Criteria.NOT_EQUAL);
+        criteria.where(IfcTablePeer.ID, -1, Criteria.NOT_EQUAL);
         IfcTablePeer.doDelete(criteria);
 
         IfcTable ifc = new IfcTable();
@@ -1255,13 +1255,13 @@ public class DataTest extends BaseDataba
     {
         // make sure that the InheritanceTest table is empty before the test
         Criteria criteria = new Criteria();
-        criteria.add(
+        criteria.where(
                 InheritanceTestPeer.INHERITANCE_TEST,
                 (Object) null,
                 Criteria.ISNOTNULL);
         InheritanceTestPeer.doDelete(criteria);
         criteria = new Criteria();
-        criteria.add(
+        criteria.where(
                 InheritanceTestPeer.INHERITANCE_TEST,
                 (Object) null,
                 Criteria.ISNOTNULL);
@@ -1284,9 +1284,9 @@ public class DataTest extends BaseDataba
 
         // Check that all objects are saved into the InheritanceTest table
         criteria = new Criteria();
-        criteria.add(
+        criteria.where(
                 InheritanceTestPeer.INHERITANCE_TEST,
-                (Object) null,
+                null,
                 Criteria.ISNOTNULL);
         assertEquals("InheritanceTestTable should contain 4 rows",
                 4,
@@ -1318,9 +1318,9 @@ public class DataTest extends BaseDataba
         Criteria criteria = new Criteria();
         InheritanceClassnameTestPeer.doDelete(criteria);
         criteria = new Criteria();
-        criteria.add(
+        criteria.where(
                 InheritanceClassnameTestPeer.INHERITANCE_TEST,
-                (Object) null,
+                null,
                 Criteria.ISNOTNULL);
         assertEquals(0,
                 new CountHelper().count(criteria));
@@ -1341,9 +1341,9 @@ public class DataTest extends BaseDataba
 
         // Check that all objects are saved into the InheritanceTest table
         criteria = new Criteria();
-        criteria.add(
+        criteria.where(
                 InheritanceClassnameTestPeer.INHERITANCE_TEST,
-                (Object) null,
+                null,
                 Criteria.ISNOTNULL);
         assertEquals("InheritanceClassnameTest table should contain 3 rows",
                 3,
@@ -1437,7 +1437,7 @@ public class DataTest extends BaseDataba
         for (int i = 0; i < authorNames.length; ++i)
         {
             Criteria criteria = new Criteria();
-            criteria.add(AuthorPeer.NAME, authorNames[i]);
+            criteria.where(AuthorPeer.NAME, authorNames[i]);
             List<Author> authorList = AuthorPeer.doSelect(criteria);
             assertEquals(
                     "AuthorList should contain one author"
@@ -1453,7 +1453,7 @@ public class DataTest extends BaseDataba
         for (Map.Entry<String, String> likeResult : likeResults.entrySet())
         {
             Criteria criteria = new Criteria();
-            criteria.add(
+            criteria.where(
                     AuthorPeer.NAME,
                     likeResult.getKey(),
                     Criteria.LIKE);
@@ -1487,7 +1487,7 @@ public class DataTest extends BaseDataba
         // a like is replaced with an equals (no wildcard present)
         // This might be a problem for databases which use ILIKE
         Criteria criteria = new Criteria();
-        criteria.add(AuthorPeer.NAME, "AbC", Criteria.LIKE);
+        criteria.where(AuthorPeer.NAME, "AbC", Criteria.LIKE);
         criteria.setIgnoreCase(true);
         List<Author> authorList = AuthorPeer.doSelect(criteria);
         assertEquals(
@@ -1502,19 +1502,19 @@ public class DataTest extends BaseDataba
         // check that the escape clause (where needed) also works
         // with limit, offset and order by
         criteria = new Criteria();
-        Criterion criterion1 = criteria.getNewCriterion(
+        Criterion criterion1 = new Criterion(
                 AuthorPeer.NAME,
                 "b%",
                 Criteria.LIKE);
-        Criterion criterion2 = criteria.getNewCriterion(
+        Criterion criterion2 = new Criterion(
                 AuthorPeer.NAME,
                 "a\\%%",
                 Criteria.LIKE);
-        Criterion criterion3 = criteria.getNewCriterion(
+        Criterion criterion3 = new Criterion(
                 AuthorPeer.NAME,
                 "cbc",
                 Criteria.LIKE);
-        criteria.add(criterion1.or(criterion2).or(criterion3));
+        criteria.where(criterion1.or(criterion2).or(criterion3));
         criteria.addAscendingOrderByColumn(AuthorPeer.NAME);
         criteria.setOffset(1);
         criteria.setLimit(1);

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java?rev=1369256&r1=1369255&r2=1369256&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java
(original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java
Sat Aug  4 03:44:48 2012
@@ -21,6 +21,7 @@ package org.apache.torque.util;
 
 import java.util.List;
 
+import org.apache.commons.lang.SerializationUtils;
 import org.apache.torque.BaseDatabaseTestCase;
 import org.apache.torque.TorqueException;
 import org.apache.torque.criteria.Criteria;
@@ -45,6 +46,7 @@ public class LargeSelectTest extends Bas
 
     private Criteria criteria;
 
+    @Override
     public void setUp() throws Exception
     {
         super.setUp();
@@ -65,9 +67,10 @@ public class LargeSelectTest extends Bas
         }
         // Set up the standard criteria for the test.
         criteria = new Criteria();
-        criteria.add(AuthorPeer.NAME, LARGE_SELECT_AUTHOR);
+        criteria.where(AuthorPeer.NAME, LARGE_SELECT_AUTHOR);
     }
 
+    @Override
     public void tearDown() throws Exception
     {
         // Delete the test data
@@ -310,7 +313,7 @@ public class LargeSelectTest extends Bas
     public void testLargeSelectOneRow() throws Exception
     {
         // Alter criteria to retrieve only one row
-        criteria.add(AuthorPeer.AUTHOR_ID, firstAuthorId);
+        criteria.where(AuthorPeer.AUTHOR_ID, firstAuthorId);
         AuthorPeer.addSelectColumns(criteria);
 
         LargeSelect<Author> ls = new LargeSelect<Author>(



---------------------------------------------------------------------
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