cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1099061 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java
Date Tue, 03 May 2011 14:06:19 GMT
Author: aadamchik
Date: Tue May  3 14:06:18 2011
New Revision: 1099061

URL: http://svn.apache.org/viewvc?rev=1099061&view=rev
Log:
CAY-1563 CayenneCase unit tests conversion(3)

patches by Dzmitry Kazimirchyk:
EJBQLSelectTranslatorTest

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java?rev=1099061&r1=1099060&r2=1099061&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java
Tue May  3 14:06:18 2011
@@ -22,41 +22,48 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
 import org.apache.cayenne.ejbql.EJBQLParser;
 import org.apache.cayenne.ejbql.EJBQLParserFactory;
 import org.apache.cayenne.query.EJBQLQuery;
 import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class EJBQLSelectTranslatorTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class EJBQLSelectTranslatorTest extends ServerCase {
+
+    @Inject
+    private ServerRuntime runtime;
 
     private SQLTemplate translateSelect(String ejbql) {
         return translateSelect(ejbql, Collections.EMPTY_MAP);
     }
 
-   
     private SQLTemplate translateSelect(
             String ejbql,
             final Map<Integer, Object> queryParameters) {
         EJBQLParser parser = EJBQLParserFactory.getParser();
-        EJBQLCompiledExpression select = parser.compile(ejbql, getDomain()
+        EJBQLCompiledExpression select = parser.compile(ejbql, runtime
+                .getDataDomain()
                 .getEntityResolver());
         EJBQLQuery query = new EJBQLQuery(ejbql) {
 
             @Override
-            public Map<Integer, Object>  getPositionalParameters(){
+            public Map<Integer, Object> getPositionalParameters() {
                 return queryParameters;
             }
         };
 
-        EJBQLTranslationContext tr = new EJBQLTranslationContext(getDomain()
+        EJBQLTranslationContext tr = new EJBQLTranslationContext(runtime
+                .getDataDomain()
                 .getEntityResolver(), query, select, new JdbcEJBQLTranslatorFactory());
         select.getExpression().visit(new EJBQLSelectTranslator(tr));
         return tr.getQuery();
     }
 
-
     public void testSelectFrom() {
         SQLTemplate query = translateSelect("select a from Artist a");
         String sql = query.getDefaultTemplate();
@@ -175,7 +182,7 @@ public class EJBQLSelectTranslatorTest e
         assertTrue(sql, sql.startsWith("SELECT"));
         assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE > #bind($id0 'DECIMAL')"));
     }
-    
+
     public void testSelectFromWhereGreaterOrEqual() {
         SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice
>= 2");
         String sql = query.getDefaultTemplate();
@@ -283,35 +290,38 @@ public class EJBQLSelectTranslatorTest e
 
         return i;
     }
-    
+
     // if parameter value is null (in this test x := null) we will generate "IS NULL"
     public void testEqualsNullParameter() {
         String ejbql = "select p from Painting p WHERE p.toArtist=:x";
         EJBQLParser parser = EJBQLParserFactory.getParser();
-        EJBQLCompiledExpression select = parser.compile(ejbql, getDomain()
+        EJBQLCompiledExpression select = parser.compile(ejbql, runtime
+                .getDataDomain()
                 .getEntityResolver());
         EJBQLQuery query = new EJBQLQuery(ejbql);
         query.setParameter("x", null);
 
-        EJBQLTranslationContext tr = new EJBQLTranslationContext(getDomain()
+        EJBQLTranslationContext tr = new EJBQLTranslationContext(runtime
+                .getDataDomain()
                 .getEntityResolver(), query, select, new JdbcEJBQLTranslatorFactory());
         select.getExpression().visit(new EJBQLSelectTranslator(tr));
         String sql = tr.getQuery().getDefaultTemplate();
-        assertTrue(sql, sql
-                .endsWith("t0.ARTIST_ID IS NULL"));
+        assertTrue(sql, sql.endsWith("t0.ARTIST_ID IS NULL"));
     }
-    
+
     // if parameter value is null and more than one parameter in query
     public void testEqualsNullAndNotNullParameter() {
         String ejbql = "select p from Painting p WHERE p.toArtist=:x OR p.toArtist.artistName=:b";
         EJBQLParser parser = EJBQLParserFactory.getParser();
-        EJBQLCompiledExpression select = parser.compile(ejbql, getDomain()
+        EJBQLCompiledExpression select = parser.compile(ejbql, runtime
+                .getDataDomain()
                 .getEntityResolver());
         EJBQLQuery query = new EJBQLQuery(ejbql);
         query.setParameter("x", null);
         query.setParameter("b", "Y");
 
-        EJBQLTranslationContext tr = new EJBQLTranslationContext(getDomain()
+        EJBQLTranslationContext tr = new EJBQLTranslationContext(runtime
+                .getDataDomain()
                 .getEntityResolver(), query, select, new JdbcEJBQLTranslatorFactory());
         select.getExpression().visit(new EJBQLSelectTranslator(tr));
         String sql = tr.getQuery().getDefaultTemplate();



Mime
View raw message