cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r932521 - /cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
Date Fri, 09 Apr 2010 17:24:38 GMT
Author: aadamchik
Date: Fri Apr  9 17:24:38 2010
New Revision: 932521

URL: http://svn.apache.org/viewvc?rev=932521&view=rev
Log:
CAY-1380 Support for Escaped LIKE Clauses in Expressions

* backporting unit test

Modified:
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java?rev=932521&r1=932520&r2=932521&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
Fri Apr  9 17:24:38 2010
@@ -37,8 +37,6 @@ import org.apache.cayenne.exp.Expression
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
-// TODO CAY-1380
-// import org.apache.cayenne.test.TableHelper;
 
 public class SelectQueryTest extends SelectQueryBase {
 
@@ -69,7 +67,7 @@ public class SelectQueryTest extends Sel
         assertEquals(totalRows - 5, results.size());
         assertEquals("artist6", results.get(0).getArtistName());
     }
-    
+
     public void testDbEntityRoot() {
         ObjectContext context = createDataContext();
 
@@ -212,24 +210,24 @@ public class SelectQueryTest extends Sel
         assertNotNull(objects);
         assertEquals(1, objects.size());
     }
-    
-    // TODO CAY-1380
-    /*
+
     public void testSelectLikeSingleWildcardMatchAndEscape() throws Exception {
 
-        TableHelper artistHelper = new TableHelper(getDbHelper(), "ARTIST");
-        artistHelper.deleteAll();
-        artistHelper.setColumns("ARTIST_ID", "ARTIST_NAME");
-        artistHelper.insert(1, "_X");
-        artistHelper.insert(2, "Y_");
+        deleteTestData();
+        createDataContext().performGenericQuery(
+                new SQLTemplate(
+                        Artist.class,
+                        "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME) VALUES (1, '_X')"));
+        createDataContext().performGenericQuery(
+                new SQLTemplate(
+                        Artist.class,
+                        "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME) VALUES (2, 'Y_')"));
 
         SelectQuery query = new SelectQuery(Artist.class);
         query.andQualifier(ExpressionFactory.likeExp("artistName", "=_%", '='));
- 
         List objects = createDataContext().performQuery(query);
         assertEquals(1, objects.size());
     }
-    */
 
     public void testSelectLikeMultipleWildcardMatch() throws Exception {
         query.setRoot(Artist.class);
@@ -255,7 +253,7 @@ public class SelectQueryTest extends Sel
         assertNotNull(objects);
         assertEquals(_artistCount, objects.size());
     }
-    
+
     /** Test how "like ignore case" works when using lowercase parameter. */
     public void testSelectLikeIgnoreCaseObjects2() throws Exception {
         query.setRoot(Artist.class);
@@ -268,11 +266,10 @@ public class SelectQueryTest extends Sel
         assertNotNull(objects);
         assertEquals(_artistCount, objects.size());
     }
-    
+
     /** Test how "like ignore case" works when using uppercase parameter. */
     public void testSelectLikeIgnoreCaseClob() throws Exception {
-        
-        
+
         query.setRoot(ClobTestEntity.class);
         Expression qual = ExpressionFactory.likeIgnoreCaseExp("clobCol", "clob%");
         query.setQualifier(qual);
@@ -284,7 +281,6 @@ public class SelectQueryTest extends Sel
         assertEquals(_clobCount, objects.size());
     }
 
-
     public void testSelectIn() throws Exception {
         query.setRoot(Artist.class);
         Expression qual = Expression.fromString("artistName in ('artist1', 'artist2')");
@@ -535,14 +531,13 @@ public class SelectQueryTest extends Sel
         finally {
             conn.close();
         }
-        
+
         String insertClob = "INSERT INTO CLOB_TEST (CLOB_TEST_ID, CLOB_COL) VALUES (?,?)";
         Connection connection = getConnection();
 
         try {
             connection.setAutoCommit(false);
 
-          
             PreparedStatement stmt = connection.prepareStatement(insertClob);
             long dateBase = System.currentTimeMillis();
 
@@ -559,17 +554,19 @@ public class SelectQueryTest extends Sel
             connection.close();
         }
     }
-    
+
     public void testLeftJoinAndPrefetchToMany() {
-        SelectQuery query = new SelectQuery(Artist.class, 
-            ExpressionFactory.matchExp("paintingArray+.toGallery", null));
+        SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.matchExp(
+                "paintingArray+.toGallery",
+                null));
         query.addPrefetch("artistExhibitArray");
         createDataContext().performQuery(query);
     }
-    
+
     public void testLeftJoinAndPrefetchToOne() {
-        SelectQuery query = new SelectQuery(Painting.class, 
-            ExpressionFactory.matchExp("toArtist+.artistName", null));
+        SelectQuery query = new SelectQuery(Painting.class, ExpressionFactory.matchExp(
+                "toArtist+.artistName",
+                null));
         query.addPrefetch("toGallery");
         createDataContext().performQuery(query);
     }



Mime
View raw message