cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r526696 [3/3] - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src: main/java/org/apache/cayenne/access/jdbc/ main/java/org/apache/cayenne/ejbql/ main/java/org/apache/cayenne/ejbql/parser/ main/jjtree/org/apache/cayenne/ejbql/ ...
Date Mon, 09 Apr 2007 09:55:04 GMT
Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLTranslatorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLTranslatorTest.java?view=diff&rev=526696&r1=526695&r2=526696
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLTranslatorTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLTranslatorTest.java
Mon Apr  9 02:54:53 2007
@@ -41,8 +41,7 @@
         assertTrue(sql, sql.indexOf("t0.ARTIST_ID") > 0);
         assertTrue(sql, sql.indexOf("t0.ARTIST_NAME") > 0);
         assertTrue(sql, sql.indexOf("t0.DATE_OF_BIRTH") > 0);
-        assertTrue(sql, sql.endsWith(" $from0"));
-        assertEquals(" FROM ARTIST t0", query.getParameters().get("from0").toString());
+        assertTrue(sql, sql.endsWith(" FROM ARTIST AS t0"));
     }
 
     public void testSelectDistinct() {
@@ -56,8 +55,7 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT DISTINCT "));
-        assertTrue(sql, sql.endsWith(" $from0"));
-        assertEquals(" FROM ARTIST t0", query.getParameters().get("from0").toString());
+        assertTrue(sql, sql.endsWith(" FROM ARTIST AS t0"));
     }
 
     public void testSelectFromWhereEqual() {
@@ -71,9 +69,8 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 WHERE t0.ARTIST_NAME "
+        assertTrue(sql, sql.endsWith(" FROM ARTIST AS t0 WHERE t0.ARTIST_NAME "
                 + "#bindEqual('Dali' 'VARCHAR')"));
-        assertEquals(" FROM ARTIST t0", query.getParameters().get("from0").toString());
     }
 
     public void testSelectFromWhereOrEqual() {
@@ -98,13 +95,11 @@
         String sql1 = query1.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.indexOf(" $from0 WHERE ") > 0);
-        assertEquals(" FROM ARTIST t0", query.getParameters().get("from0").toString());
+        assertTrue(sql, sql.indexOf(" FROM ARTIST AS t0 WHERE ") > 0);
         assertEquals(1, countDelimiters(sql, " OR ", sql.indexOf("WHERE ")));
 
         assertTrue(sql1, sql1.startsWith("SELECT "));
-        assertTrue(sql1, sql.indexOf(" $from0 WHERE ") > 0);
-        assertEquals(" FROM ARTIST t0", query1.getParameters().get("from0").toString());
+        assertTrue(sql1, sql.indexOf(" FROM ARTIST AS t0 WHERE ") > 0);
         assertEquals(2, countDelimiters(sql1, " OR ", sql.indexOf("WHERE ")));
     }
 
@@ -130,11 +125,11 @@
         String sql1 = query1.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.indexOf(" $from0 WHERE ") > 0);
+        assertTrue(sql, sql.indexOf(" WHERE ") > 0);
         assertEquals(1, countDelimiters(sql, " AND ", sql.indexOf("WHERE ")));
 
         assertTrue(sql1, sql1.startsWith("SELECT "));
-        assertTrue(sql1, sql1.indexOf(" $from0 WHERE ") > 0);
+        assertTrue(sql1, sql1.indexOf(" WHERE ") > 0);
         assertEquals(2, countDelimiters(sql1, " AND ", sql1.indexOf("WHERE ")));
     }
 
@@ -149,7 +144,7 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 WHERE NOT "
+        assertTrue(sql, sql.endsWith(" WHERE NOT "
                 + "t0.ARTIST_NAME #bindEqual('Dali' 'VARCHAR')"));
     }
 
@@ -164,8 +159,7 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 "
-                + "WHERE t0.ESTIMATED_PRICE > #bind($id1 'DECIMAL')"));
+        assertTrue(sql, sql.endsWith(" WHERE t0.ESTIMATED_PRICE > #bind($id0 'DECIMAL')"));
     }
 
     public void testSelectFromWhereGreaterOrEqual() {
@@ -179,8 +173,8 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 "
-                + "WHERE t0.ESTIMATED_PRICE >= #bind($id1 'INTEGER')"));
+        assertTrue(sql, sql
+                .endsWith(" WHERE t0.ESTIMATED_PRICE >= #bind($id0 'INTEGER')"));
     }
 
     public void testSelectFromWhereLess() {
@@ -194,8 +188,7 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 "
-                + "WHERE t0.ESTIMATED_PRICE < #bind($id1 'DECIMAL')"));
+        assertTrue(sql, sql.endsWith(" WHERE t0.ESTIMATED_PRICE < #bind($id0 'DECIMAL')"));
     }
 
     public void testSelectFromWhereLessOrEqual() {
@@ -209,8 +202,8 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 "
-                + "WHERE t0.ESTIMATED_PRICE <= #bind($id1 'DECIMAL')"));
+        assertTrue(sql, sql
+                .endsWith(" WHERE t0.ESTIMATED_PRICE <= #bind($id0 'DECIMAL')"));
     }
 
     public void testSelectFromWhereNotEqual() {
@@ -224,8 +217,8 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 "
-                + "WHERE t0.ARTIST_NAME #bindNotEqual('Dali' 'VARCHAR')"));
+        assertTrue(sql, sql
+                .endsWith(" WHERE t0.ARTIST_NAME #bindNotEqual('Dali' 'VARCHAR')"));
     }
 
     public void testSelectFromWhereBetween() {
@@ -239,9 +232,8 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 "
-                + "WHERE t0.ESTIMATED_PRICE "
-                + "BETWEEN #bind($id1 'INTEGER') AND #bind($id2 'INTEGER')"));
+        assertTrue(sql, sql.endsWith(" WHERE t0.ESTIMATED_PRICE "
+                + "BETWEEN #bind($id0 'INTEGER') AND #bind($id1 'INTEGER')"));
     }
 
     public void testSelectFromWhereNotBetween() {
@@ -255,9 +247,8 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 "
-                + "WHERE t0.ESTIMATED_PRICE "
-                + "NOT BETWEEN #bind($id1 'INTEGER') AND #bind($id2 'INTEGER')"));
+        assertTrue(sql, sql.endsWith(" WHERE t0.ESTIMATED_PRICE "
+                + "NOT BETWEEN #bind($id0 'INTEGER') AND #bind($id1 'INTEGER')"));
     }
 
     public void testSelectFromWhereLike() {
@@ -272,8 +263,7 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 "
-                + "WHERE t0.PAINTING_TITLE "
+        assertTrue(sql, sql.endsWith(" WHERE t0.PAINTING_TITLE "
                 + "LIKE #bind('Stuff' 'VARCHAR')"));
     }
 
@@ -288,8 +278,7 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 "
-                + "WHERE t0.PAINTING_TITLE "
+        assertTrue(sql, sql.endsWith(" WHERE t0.PAINTING_TITLE "
                 + "NOT LIKE #bind('Stuff' 'VARCHAR')"));
     }
 
@@ -308,8 +297,7 @@
         System.out.println("SQL: " + sql);
 
         assertTrue(sql, sql.startsWith("SELECT "));
-        assertTrue(sql, sql.endsWith(" $from0 "
-                + "WHERE t1.ARTIST_NAME #bindEqual('AA2' 'VARCHAR')"));
+        assertTrue(sql, sql.endsWith(" WHERE t1.ARTIST_NAME #bindEqual('AA2' 'VARCHAR')"));
         // TODO: andrus, 3/25/2007 - implement joins support
         // assertEquals(" FROM PAINTING t0 JOIN ARTIST t1 ON (t0.ARTIST_ID =
         // t1.ARTIST_ID)", query.getParameters().get("from0"));

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/ejbql/parser/EJBQLPathTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/ejbql/parser/EJBQLPathTest.java?view=auto&rev=526696
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/ejbql/parser/EJBQLPathTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/ejbql/parser/EJBQLPathTest.java
Mon Apr  9 02:54:53 2007
@@ -0,0 +1,37 @@
+/*****************************************************************
+ *   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.
+ ****************************************************************/
+package org.apache.cayenne.ejbql.parser;
+
+import junit.framework.TestCase;
+
+public class EJBQLPathTest extends TestCase {
+
+    public void testGetAbsolutePath() {
+        EJBQLPath path = new EJBQLPath(-1);
+        EJBQLIdentifier id = new EJBQLIdentifier(-1);
+        id.setText("x");
+
+        EJBQLIdentificationVariable c1 = new EJBQLIdentificationVariable(-1);
+        c1.setText("y");
+        
+        path.jjtAddChild(id, 0);
+        path.jjtAddChild(c1, 1);
+        assertEquals("x.y", path.getAbsolutePath());
+    }
+}



Mime
View raw message