cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [13/48] Installing Maven Failsafe Plugin
Date Sun, 02 Nov 2014 07:10:01 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/UpdateBatchTranslatorTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/UpdateBatchTranslatorTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/UpdateBatchTranslatorTest.java
deleted file mode 100644
index 37f751d..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/UpdateBatchTranslatorTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*****************************************************************
- *   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.access.translator.batch;
-
-import static org.mockito.Mockito.mock;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.cayenne.access.translator.batch.UpdateBatchTranslator;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dba.JdbcAdapter;
-import org.apache.cayenne.di.AdhocObjectFactory;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.query.UpdateBatchQuery;
-import org.apache.cayenne.testdo.locking.SimpleLockingTestEntity;
-import org.apache.cayenne.unit.UnitDbAdapter;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.LOCKING_PROJECT)
-public class UpdateBatchTranslatorTest extends ServerCase {
-
-    @Inject
-    private ServerRuntime runtime;
-
-    @Inject
-    private DbAdapter adapter;
-
-    @Inject
-    private UnitDbAdapter unitAdapter;
-
-    @Inject
-    private AdhocObjectFactory objectFactory;
-
-    public void testConstructor() throws Exception {
-        DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
-        UpdateBatchTranslator builder = new UpdateBatchTranslator(mock(UpdateBatchQuery.class), adapter, null);
-        assertSame(adapter, builder.adapter);
-    }
-
-    public void testCreateSqlString() throws Exception {
-        DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
-                .getDbEntity();
-
-        List idAttributes = Collections.singletonList(entity.getAttribute("LOCKING_TEST_ID"));
-        List updatedAttributes = Collections.singletonList(entity.getAttribute("DESCRIPTION"));
-
-        UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes,
-                Collections.<String> emptySet(), 1);
-
-        DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
-        UpdateBatchTranslator builder = new UpdateBatchTranslator(updateQuery, adapter, null);
-        String generatedSql = builder.getSql();
-        assertNotNull(generatedSql);
-        assertEquals("UPDATE " + entity.getName() + " SET DESCRIPTION = ? WHERE LOCKING_TEST_ID = ?", generatedSql);
-    }
-
-    public void testCreateSqlStringWithNulls() throws Exception {
-        DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
-                .getDbEntity();
-
-        List idAttributes = Arrays.asList(entity.getAttribute("LOCKING_TEST_ID"), entity.getAttribute("NAME"));
-
-        List updatedAttributes = Collections.singletonList(entity.getAttribute("DESCRIPTION"));
-
-        Collection nullAttributes = Collections.singleton("NAME");
-
-        UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes, nullAttributes, 1);
-
-        DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
-        UpdateBatchTranslator builder = new UpdateBatchTranslator(updateQuery, adapter, null);
-        String generatedSql = builder.getSql();
-        assertNotNull(generatedSql);
-
-        assertEquals("UPDATE " + entity.getName() + " SET DESCRIPTION = ? WHERE LOCKING_TEST_ID = ? AND NAME IS NULL",
-                generatedSql);
-    }
-
-    public void testCreateSqlStringWithIdentifiersQuote() throws Exception {
-        DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
-                .getDbEntity();
-        try {
-
-            entity.getDataMap().setQuotingSQLIdentifiers(true);
-            List idAttributes = Collections.singletonList(entity.getAttribute("LOCKING_TEST_ID"));
-            List updatedAttributes = Collections.singletonList(entity.getAttribute("DESCRIPTION"));
-
-            UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes,
-                    Collections.<String> emptySet(), 1);
-            JdbcAdapter adapter = (JdbcAdapter) this.adapter;
-
-            UpdateBatchTranslator builder = new UpdateBatchTranslator(updateQuery, adapter, null);
-            String generatedSql = builder.getSql();
-
-            String charStart = unitAdapter.getIdentifiersStartQuote();
-            String charEnd = unitAdapter.getIdentifiersEndQuote();
-
-            assertNotNull(generatedSql);
-            assertEquals("UPDATE " + charStart + entity.getName() + charEnd + " SET " + charStart + "DESCRIPTION"
-                    + charEnd + " = ? WHERE " + charStart + "LOCKING_TEST_ID" + charEnd + " = ?", generatedSql);
-
-        } finally {
-            entity.getDataMap().setQuotingSQLIdentifiers(false);
-        }
-    }
-
-    public void testCreateSqlStringWithNullsWithIdentifiersQuote() throws Exception {
-        DbEntity entity = runtime.getDataDomain().getEntityResolver().getObjEntity(SimpleLockingTestEntity.class)
-                .getDbEntity();
-        try {
-
-            entity.getDataMap().setQuotingSQLIdentifiers(true);
-            List idAttributes = Arrays.asList(entity.getAttribute("LOCKING_TEST_ID"), entity.getAttribute("NAME"));
-
-            List updatedAttributes = Collections.singletonList(entity.getAttribute("DESCRIPTION"));
-
-            Collection nullAttributes = Collections.singleton("NAME");
-
-            UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes,
-                    nullAttributes, 1);
-            JdbcAdapter adapter = (JdbcAdapter) this.adapter;
-
-            UpdateBatchTranslator builder = new UpdateBatchTranslator(updateQuery, adapter, null);
-            String generatedSql = builder.getSql();
-            assertNotNull(generatedSql);
-
-            String charStart = unitAdapter.getIdentifiersStartQuote();
-            String charEnd = unitAdapter.getIdentifiersEndQuote();
-            assertEquals("UPDATE " + charStart + entity.getName() + charEnd + " SET " + charStart + "DESCRIPTION"
-                    + charEnd + " = ? WHERE " + charStart + "LOCKING_TEST_ID" + charEnd + " = ? AND " + charStart
-                    + "NAME" + charEnd + " IS NULL", generatedSql);
-
-        } finally {
-            entity.getDataMap().setQuotingSQLIdentifiers(false);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslatorIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslatorIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslatorIT.java
new file mode 100644
index 0000000..0da0982
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslatorIT.java
@@ -0,0 +1,313 @@
+/*****************************************************************
+ *   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.access.translator.ejbql;
+
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.dba.DbAdapter;
+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.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class EJBQLSelectTranslatorIT extends ServerCase {
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private DbAdapter adapter;
+
+    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, runtime.getDataDomain().getEntityResolver());
+        EJBQLQuery query = new EJBQLQuery(ejbql) {
+
+            @Override
+            public Map<Integer, Object> getPositionalParameters() {
+                return queryParameters;
+            }
+        };
+
+        EJBQLTranslationContext tr = new EJBQLTranslationContext(runtime.getDataDomain().getEntityResolver(), query,
+                select, new JdbcEJBQLTranslatorFactory(), adapter.getQuotingStrategy());
+        select.getExpression().visit(new EJBQLSelectTranslator(tr));
+        return tr.getQuery();
+    }
+
+    public void testSelectFrom() {
+        SQLTemplate query = translateSelect("select a from Artist a");
+        String sql = query.getDefaultTemplate();
+
+        // column order is unpredictable, just need to ensure that they are all
+        // there
+        assertTrue(sql, sql.startsWith("SELECT"));
+        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(" FROM ARTIST t0"));
+    }
+
+    public void testSelectMultipleJoinsToTheSameTable() throws Exception {
+        SQLTemplate query = translateSelect("SELECT a "
+                + "FROM Artist a JOIN a.paintingArray b JOIN a.paintingArray c "
+                + "WHERE b.paintingTitle = 'P1' AND c.paintingTitle = 'P2'");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.startsWith("SELECT"));
+
+        assertTrue(sql, sql.indexOf("INNER JOIN PAINTING t1 ON (t0.ARTIST_ID = t1.ARTIST_ID)") > 0);
+        assertTrue(sql, sql.indexOf("INNER JOIN PAINTING t2 ON (t0.ARTIST_ID = t2.ARTIST_ID)") > 0);
+    }
+
+    public void testSelectImplicitColumnJoins() throws Exception {
+        SQLTemplate query = translateSelect("SELECT a.paintingArray.toGallery.galleryName "
+                + "FROM Artist a JOIN a.paintingArray b");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.startsWith("SELECT"));
+
+        // check that overlapping implicit and explicit joins did not result in
+        // duplicates
+
+        assertTrue(sql, sql.contains("INNER JOIN GALLERY"));
+        assertTrue(sql, sql.contains("INNER JOIN PAINTING"));
+
+        int i1 = sql.indexOf("INNER JOIN PAINTING");
+        assertTrue(sql, i1 >= 0);
+
+        // TODO: andrus 1/6/2008 - this fails
+        // int i2 = sql.indexOf("INNER JOIN PAINTING", i1 + 1);
+        // assertTrue(sql, i2 < 0);
+    }
+
+    public void testSelectDistinct() {
+        SQLTemplate query = translateSelect("select distinct a from Artist a");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.startsWith("SELECT DISTINCT "));
+    }
+
+    public void testSelectFromWhereEqual() {
+        SQLTemplate query = translateSelect("select a from Artist a where a.artistName = 'Dali'");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.startsWith("SELECT"));
+
+        assertTrue(sql, sql.endsWith(" FROM ARTIST t0 WHERE t0.ARTIST_NAME =" + " #bind('Dali' 'VARCHAR')"));
+    }
+
+    public void testSelectFromWhereOrEqual() {
+        SQLTemplate query = translateSelect("select a from Artist a where a.artistName = 'Dali' "
+                + "or a.artistName = 'Malevich'");
+        String sql = query.getDefaultTemplate();
+
+        SQLTemplate query1 = translateSelect("select a from Artist a where a.artistName = 'Picasso' "
+                + "or a.artistName = 'Malevich' " + "or a.artistName = 'Dali'");
+        String sql1 = query1.getDefaultTemplate();
+
+        assertTrue(sql, sql.startsWith("SELECT"));
+        assertTrue(sql, sql.indexOf(" FROM ARTIST t0 WHERE ") > 0);
+        assertEquals(1, countDelimiters(sql, " OR ", sql.indexOf("WHERE ")));
+
+        assertTrue(sql1, sql1.startsWith("SELECT"));
+        assertTrue(sql1, sql.indexOf(" FROM ARTIST t0 WHERE ") > 0);
+        assertEquals(2, countDelimiters(sql1, " OR ", sql.indexOf("WHERE ")));
+    }
+
+    public void testSelectFromWhereAndEqual() {
+
+        SQLTemplate query = translateSelect("select a from Artist a where a.artistName = 'Dali' "
+                + "and a.artistName = 'Malevich'");
+        String sql = query.getDefaultTemplate();
+
+        SQLTemplate query1 = translateSelect("select a from Artist a where a.artistName = 'Picasso' "
+                + "and a.artistName = 'Malevich' " + "and a.artistName = 'Dali'");
+        String sql1 = query1.getDefaultTemplate();
+
+        assertTrue(sql, sql.startsWith("SELECT"));
+        assertTrue(sql, sql.indexOf("WHERE ") > 0);
+        assertEquals(1, countDelimiters(sql, " AND ", sql.indexOf("WHERE ")));
+
+        assertTrue(sql1, sql1.startsWith("SELECT"));
+        assertTrue(sql1, sql1.indexOf("WHERE ") > 0);
+        assertEquals(2, countDelimiters(sql1, " AND ", sql1.indexOf("WHERE ")));
+    }
+
+    public void testSelectFromWhereNot() {
+        SQLTemplate query = translateSelect("select a from Artist a where not (a.artistName = 'Dali')");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.startsWith("SELECT"));
+        assertTrue(sql, sql.endsWith("WHERE NOT " + "t0.ARTIST_NAME = #bind('Dali' 'VARCHAR')"));
+    }
+
+    public void testSelectFromWhereGreater() {
+        SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice > 1.0");
+        String sql = query.getDefaultTemplate();
+
+        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();
+        assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE >= #bind($id0 'INTEGER')"));
+    }
+
+    public void testSelectFromWhereLess() {
+        SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice < 1.0");
+        String sql = query.getDefaultTemplate();
+        assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE < #bind($id0 'DECIMAL')"));
+    }
+
+    public void testSelectFromWhereLessOrEqual() {
+        SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice <= 1.0");
+        String sql = query.getDefaultTemplate();
+        assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE <= #bind($id0 'DECIMAL')"));
+    }
+
+    public void testSelectFromWhereNotEqual() {
+        SQLTemplate query = translateSelect("select a from Artist a where a.artistName <> 'Dali'");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.endsWith("WHERE t0.ARTIST_NAME <> #bind('Dali' 'VARCHAR')"));
+    }
+
+    public void testSelectFromWhereBetween() {
+        SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice between 3 and 5");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE "
+                + "BETWEEN #bind($id0 'INTEGER') AND #bind($id1 'INTEGER')"));
+    }
+
+    public void testSelectFromWhereNotBetween() {
+        SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice not between 3 and 5");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE "
+                + "NOT BETWEEN #bind($id0 'INTEGER') AND #bind($id1 'INTEGER')"));
+    }
+
+    public void testSelectFromWhereLike() {
+        SQLTemplate query = translateSelect("select p from Painting p where p.paintingTitle like 'Stuff'");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.endsWith("WHERE t0.PAINTING_TITLE " + "LIKE #bind('Stuff' 'VARCHAR')"));
+    }
+
+    public void testSelectFromWhereNotLike() {
+        SQLTemplate query = translateSelect("select p from Painting p where p.paintingTitle NOT like 'Stuff'");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.endsWith("WHERE t0.PAINTING_TITLE " + "NOT LIKE #bind('Stuff' 'VARCHAR')"));
+    }
+
+    public void testSelectPositionalParameters() {
+        Map<Integer, Object> params = new HashMap<Integer, Object>();
+        params.put(new Integer(1), "X");
+        params.put(new Integer(2), "Y");
+        SQLTemplate query = translateSelect("select a from Artist a where a.artistName = ?1 or a.artistName = ?2",
+                params);
+        String sql = query.getDefaultTemplate();
+        assertTrue(sql, sql.endsWith("t0.ARTIST_NAME = #bind($id0) OR t0.ARTIST_NAME = #bind($id1)"));
+    }
+
+    public void testMax() {
+        SQLTemplate query = translateSelect("select max(p.estimatedPrice) from Painting p");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.startsWith("SELECT " + "#result('MAX(t0.ESTIMATED_PRICE)' 'java.math.BigDecimal' 'sc0') "
+                + "FROM PAINTING t0"));
+    }
+
+    public void testDistinctSum() {
+        SQLTemplate query = translateSelect("select sum( distinct p.estimatedPrice) from Painting p");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql,
+                sql.startsWith("SELECT #result('SUM(DISTINCT t0.ESTIMATED_PRICE)' 'java.math.BigDecimal' 'sc0') "
+                        + "FROM PAINTING t0"));
+    }
+
+    public void testColumnPaths() {
+        SQLTemplate query = translateSelect("select p.estimatedPrice, p.toArtist.artistName from Painting p");
+        String sql = query.getDefaultTemplate();
+
+        assertTrue(sql, sql.startsWith("SELECT "
+                + "#result('t0.ESTIMATED_PRICE' 'java.math.BigDecimal' 'sc0' 'sc0' 3), "
+                + "#result('t1.ARTIST_NAME' 'java.lang.String' 'sc1' 'sc1' 1) FROM"));
+    }
+
+    private int countDelimiters(String string, String delim, int fromIndex) {
+        int i = 0;
+        while ((fromIndex = string.indexOf(delim, fromIndex)) >= 0) {
+            fromIndex += delim.length();
+            i++;
+        }
+
+        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, runtime.getDataDomain().getEntityResolver());
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        query.setParameter("x", null);
+
+        EJBQLTranslationContext tr = new EJBQLTranslationContext(runtime.getDataDomain().getEntityResolver(), query,
+                select, new JdbcEJBQLTranslatorFactory(), adapter.getQuotingStrategy());
+        select.getExpression().visit(new EJBQLSelectTranslator(tr));
+        String sql = tr.getQuery().getDefaultTemplate();
+        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, runtime.getDataDomain().getEntityResolver());
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        query.setParameter("x", null);
+        query.setParameter("b", "Y");
+
+        EJBQLTranslationContext tr = new EJBQLTranslationContext(runtime.getDataDomain().getEntityResolver(), query,
+                select, new JdbcEJBQLTranslatorFactory(), adapter.getQuotingStrategy());
+        select.getExpression().visit(new EJBQLSelectTranslator(tr));
+        String sql = tr.getQuery().getDefaultTemplate();
+        assertTrue(sql, sql.endsWith("t0.ARTIST_ID IS NULL OR t1.ARTIST_NAME = #bind($id0)"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslatorTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslatorTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslatorTest.java
deleted file mode 100644
index bfa924e..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslatorTest.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*****************************************************************
- *   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.access.translator.ejbql;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLSelectTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslatorFactory;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.dba.DbAdapter;
-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.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class EJBQLSelectTranslatorTest extends ServerCase {
-
-    @Inject
-    private ServerRuntime runtime;
-
-    @Inject
-    private DbAdapter adapter;
-
-    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, runtime.getDataDomain().getEntityResolver());
-        EJBQLQuery query = new EJBQLQuery(ejbql) {
-
-            @Override
-            public Map<Integer, Object> getPositionalParameters() {
-                return queryParameters;
-            }
-        };
-
-        EJBQLTranslationContext tr = new EJBQLTranslationContext(runtime.getDataDomain().getEntityResolver(), query,
-                select, new JdbcEJBQLTranslatorFactory(), adapter.getQuotingStrategy());
-        select.getExpression().visit(new EJBQLSelectTranslator(tr));
-        return tr.getQuery();
-    }
-
-    public void testSelectFrom() {
-        SQLTemplate query = translateSelect("select a from Artist a");
-        String sql = query.getDefaultTemplate();
-
-        // column order is unpredictable, just need to ensure that they are all
-        // there
-        assertTrue(sql, sql.startsWith("SELECT"));
-        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(" FROM ARTIST t0"));
-    }
-
-    public void testSelectMultipleJoinsToTheSameTable() throws Exception {
-        SQLTemplate query = translateSelect("SELECT a "
-                + "FROM Artist a JOIN a.paintingArray b JOIN a.paintingArray c "
-                + "WHERE b.paintingTitle = 'P1' AND c.paintingTitle = 'P2'");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.startsWith("SELECT"));
-
-        assertTrue(sql, sql.indexOf("INNER JOIN PAINTING t1 ON (t0.ARTIST_ID = t1.ARTIST_ID)") > 0);
-        assertTrue(sql, sql.indexOf("INNER JOIN PAINTING t2 ON (t0.ARTIST_ID = t2.ARTIST_ID)") > 0);
-    }
-
-    public void testSelectImplicitColumnJoins() throws Exception {
-        SQLTemplate query = translateSelect("SELECT a.paintingArray.toGallery.galleryName "
-                + "FROM Artist a JOIN a.paintingArray b");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.startsWith("SELECT"));
-
-        // check that overlapping implicit and explicit joins did not result in
-        // duplicates
-
-        assertTrue(sql, sql.contains("INNER JOIN GALLERY"));
-        assertTrue(sql, sql.contains("INNER JOIN PAINTING"));
-
-        int i1 = sql.indexOf("INNER JOIN PAINTING");
-        assertTrue(sql, i1 >= 0);
-
-        // TODO: andrus 1/6/2008 - this fails
-        // int i2 = sql.indexOf("INNER JOIN PAINTING", i1 + 1);
-        // assertTrue(sql, i2 < 0);
-    }
-
-    public void testSelectDistinct() {
-        SQLTemplate query = translateSelect("select distinct a from Artist a");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.startsWith("SELECT DISTINCT "));
-    }
-
-    public void testSelectFromWhereEqual() {
-        SQLTemplate query = translateSelect("select a from Artist a where a.artistName = 'Dali'");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.startsWith("SELECT"));
-
-        assertTrue(sql, sql.endsWith(" FROM ARTIST t0 WHERE t0.ARTIST_NAME =" + " #bind('Dali' 'VARCHAR')"));
-    }
-
-    public void testSelectFromWhereOrEqual() {
-        SQLTemplate query = translateSelect("select a from Artist a where a.artistName = 'Dali' "
-                + "or a.artistName = 'Malevich'");
-        String sql = query.getDefaultTemplate();
-
-        SQLTemplate query1 = translateSelect("select a from Artist a where a.artistName = 'Picasso' "
-                + "or a.artistName = 'Malevich' " + "or a.artistName = 'Dali'");
-        String sql1 = query1.getDefaultTemplate();
-
-        assertTrue(sql, sql.startsWith("SELECT"));
-        assertTrue(sql, sql.indexOf(" FROM ARTIST t0 WHERE ") > 0);
-        assertEquals(1, countDelimiters(sql, " OR ", sql.indexOf("WHERE ")));
-
-        assertTrue(sql1, sql1.startsWith("SELECT"));
-        assertTrue(sql1, sql.indexOf(" FROM ARTIST t0 WHERE ") > 0);
-        assertEquals(2, countDelimiters(sql1, " OR ", sql.indexOf("WHERE ")));
-    }
-
-    public void testSelectFromWhereAndEqual() {
-
-        SQLTemplate query = translateSelect("select a from Artist a where a.artistName = 'Dali' "
-                + "and a.artistName = 'Malevich'");
-        String sql = query.getDefaultTemplate();
-
-        SQLTemplate query1 = translateSelect("select a from Artist a where a.artistName = 'Picasso' "
-                + "and a.artistName = 'Malevich' " + "and a.artistName = 'Dali'");
-        String sql1 = query1.getDefaultTemplate();
-
-        assertTrue(sql, sql.startsWith("SELECT"));
-        assertTrue(sql, sql.indexOf("WHERE ") > 0);
-        assertEquals(1, countDelimiters(sql, " AND ", sql.indexOf("WHERE ")));
-
-        assertTrue(sql1, sql1.startsWith("SELECT"));
-        assertTrue(sql1, sql1.indexOf("WHERE ") > 0);
-        assertEquals(2, countDelimiters(sql1, " AND ", sql1.indexOf("WHERE ")));
-    }
-
-    public void testSelectFromWhereNot() {
-        SQLTemplate query = translateSelect("select a from Artist a where not (a.artistName = 'Dali')");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.startsWith("SELECT"));
-        assertTrue(sql, sql.endsWith("WHERE NOT " + "t0.ARTIST_NAME = #bind('Dali' 'VARCHAR')"));
-    }
-
-    public void testSelectFromWhereGreater() {
-        SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice > 1.0");
-        String sql = query.getDefaultTemplate();
-
-        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();
-        assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE >= #bind($id0 'INTEGER')"));
-    }
-
-    public void testSelectFromWhereLess() {
-        SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice < 1.0");
-        String sql = query.getDefaultTemplate();
-        assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE < #bind($id0 'DECIMAL')"));
-    }
-
-    public void testSelectFromWhereLessOrEqual() {
-        SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice <= 1.0");
-        String sql = query.getDefaultTemplate();
-        assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE <= #bind($id0 'DECIMAL')"));
-    }
-
-    public void testSelectFromWhereNotEqual() {
-        SQLTemplate query = translateSelect("select a from Artist a where a.artistName <> 'Dali'");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.endsWith("WHERE t0.ARTIST_NAME <> #bind('Dali' 'VARCHAR')"));
-    }
-
-    public void testSelectFromWhereBetween() {
-        SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice between 3 and 5");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE "
-                + "BETWEEN #bind($id0 'INTEGER') AND #bind($id1 'INTEGER')"));
-    }
-
-    public void testSelectFromWhereNotBetween() {
-        SQLTemplate query = translateSelect("select p from Painting p where p.estimatedPrice not between 3 and 5");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.endsWith("WHERE t0.ESTIMATED_PRICE "
-                + "NOT BETWEEN #bind($id0 'INTEGER') AND #bind($id1 'INTEGER')"));
-    }
-
-    public void testSelectFromWhereLike() {
-        SQLTemplate query = translateSelect("select p from Painting p where p.paintingTitle like 'Stuff'");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.endsWith("WHERE t0.PAINTING_TITLE " + "LIKE #bind('Stuff' 'VARCHAR')"));
-    }
-
-    public void testSelectFromWhereNotLike() {
-        SQLTemplate query = translateSelect("select p from Painting p where p.paintingTitle NOT like 'Stuff'");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.endsWith("WHERE t0.PAINTING_TITLE " + "NOT LIKE #bind('Stuff' 'VARCHAR')"));
-    }
-
-    public void testSelectPositionalParameters() {
-        Map<Integer, Object> params = new HashMap<Integer, Object>();
-        params.put(new Integer(1), "X");
-        params.put(new Integer(2), "Y");
-        SQLTemplate query = translateSelect("select a from Artist a where a.artistName = ?1 or a.artistName = ?2",
-                params);
-        String sql = query.getDefaultTemplate();
-        assertTrue(sql, sql.endsWith("t0.ARTIST_NAME = #bind($id0) OR t0.ARTIST_NAME = #bind($id1)"));
-    }
-
-    public void testMax() {
-        SQLTemplate query = translateSelect("select max(p.estimatedPrice) from Painting p");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.startsWith("SELECT " + "#result('MAX(t0.ESTIMATED_PRICE)' 'java.math.BigDecimal' 'sc0') "
-                + "FROM PAINTING t0"));
-    }
-
-    public void testDistinctSum() {
-        SQLTemplate query = translateSelect("select sum( distinct p.estimatedPrice) from Painting p");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql,
-                sql.startsWith("SELECT #result('SUM(DISTINCT t0.ESTIMATED_PRICE)' 'java.math.BigDecimal' 'sc0') "
-                        + "FROM PAINTING t0"));
-    }
-
-    public void testColumnPaths() {
-        SQLTemplate query = translateSelect("select p.estimatedPrice, p.toArtist.artistName from Painting p");
-        String sql = query.getDefaultTemplate();
-
-        assertTrue(sql, sql.startsWith("SELECT "
-                + "#result('t0.ESTIMATED_PRICE' 'java.math.BigDecimal' 'sc0' 'sc0' 3), "
-                + "#result('t1.ARTIST_NAME' 'java.lang.String' 'sc1' 'sc1' 1) FROM"));
-    }
-
-    private int countDelimiters(String string, String delim, int fromIndex) {
-        int i = 0;
-        while ((fromIndex = string.indexOf(delim, fromIndex)) >= 0) {
-            fromIndex += delim.length();
-            i++;
-        }
-
-        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, runtime.getDataDomain().getEntityResolver());
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-        query.setParameter("x", null);
-
-        EJBQLTranslationContext tr = new EJBQLTranslationContext(runtime.getDataDomain().getEntityResolver(), query,
-                select, new JdbcEJBQLTranslatorFactory(), adapter.getQuotingStrategy());
-        select.getExpression().visit(new EJBQLSelectTranslator(tr));
-        String sql = tr.getQuery().getDefaultTemplate();
-        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, runtime.getDataDomain().getEntityResolver());
-        EJBQLQuery query = new EJBQLQuery(ejbql);
-        query.setParameter("x", null);
-        query.setParameter("b", "Y");
-
-        EJBQLTranslationContext tr = new EJBQLTranslationContext(runtime.getDataDomain().getEntityResolver(), query,
-                select, new JdbcEJBQLTranslatorFactory(), adapter.getQuotingStrategy());
-        select.getExpression().visit(new EJBQLSelectTranslator(tr));
-        String sql = tr.getQuery().getDefaultTemplate();
-        assertTrue(sql, sql.endsWith("t0.ARTIST_ID IS NULL OR t1.ARTIST_NAME = #bind($id0)"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/OrderingTranslatorIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/OrderingTranslatorIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/OrderingTranslatorIT.java
new file mode 100644
index 0000000..fc580f3
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/OrderingTranslatorIT.java
@@ -0,0 +1,178 @@
+/*****************************************************************
+ *   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.access.translator.select;
+
+import org.apache.cayenne.TranslationCase;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.query.SortOrder;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.Connection;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class OrderingTranslatorIT extends ServerCase {
+
+    @Inject
+    private DataNode node;
+
+    @Inject
+    private ServerCaseDataSourceFactory dataSourceFactory;
+
+    private Connection connection;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        this.connection = dataSourceFactory.getSharedDataSource().getConnection();
+    }
+
+    @Override
+    protected void tearDownBeforeInjection() throws Exception {
+        connection.close();
+    }
+
+    /**
+     * Tests ascending ordering on string attribute.
+     */
+    public void testDoTranslation1() throws Exception {
+        SelectQuery q = new SelectQuery(Artist.class);
+        q.addOrdering("artistName", SortOrder.ASCENDING);
+
+        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
+
+        TranslationCase tstCase = new TranslationCase("Artist", null, "ta.ARTIST_NAME");
+
+        StringBuilder out = new StringBuilder();
+        new OrderingTranslator(qa).appendPart(out);
+
+        assertTrue(out.length() > 0);
+        tstCase.assertTranslatedWell(out.toString());
+    }
+
+    /**
+     * Tests descending ordering on string attribute.
+     */
+    public void testDoTranslation2() throws Exception {
+        SelectQuery q = new SelectQuery(Artist.class);
+        q.addOrdering("artistName", SortOrder.DESCENDING);
+
+        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
+
+        TranslationCase tstCase = new TranslationCase("Artist", null, "ta.ARTIST_NAME DESC");
+
+        StringBuilder out = new StringBuilder();
+        new OrderingTranslator(qa).appendPart(out);
+
+        assertTrue(out.length() > 0);
+        tstCase.assertTranslatedWell(out.toString());
+    }
+
+    /**
+     * Tests ascending case-insensitive ordering on string attribute.
+     */
+    public void testDoTranslation4() throws Exception {
+        SelectQuery q = new SelectQuery(Artist.class);
+        q.addOrdering("artistName", SortOrder.ASCENDING_INSENSITIVE);
+
+        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
+
+        TranslationCase tstCase = new TranslationCase("Artist", null, "UPPER(ta.ARTIST_NAME)");
+
+        StringBuilder out = new StringBuilder();
+        new OrderingTranslator(qa).appendPart(out);
+
+        assertTrue(out.length() > 0);
+        String orderBySql = out.toString();
+        assertTrue(orderBySql.contains("UPPER("));
+        tstCase.assertTranslatedWell(orderBySql);
+    }
+
+    public void testDoTranslation5() throws Exception {
+        SelectQuery q = new SelectQuery(Artist.class);
+        q.addOrdering("artistName", SortOrder.DESCENDING_INSENSITIVE);
+        q.addOrdering("paintingArray.estimatedPrice", SortOrder.ASCENDING);
+
+        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
+
+        TranslationCase tstCase = new TranslationCase("Artist", null, "UPPER(ta.ARTIST_NAME) DESC, ta.ESTIMATED_PRICE");
+
+        StringBuilder out = new StringBuilder();
+        new OrderingTranslator(qa).appendPart(out);
+
+        assertTrue(out.length() > 0);
+        String orderBySql = out.toString();
+
+        // Check there is an UPPER modifier
+        int indexOfUpper = orderBySql.indexOf("UPPER(");
+        assertTrue(indexOfUpper != -1);
+
+        // and ensure there is only ONE upper modifier
+        assertTrue(orderBySql.indexOf("UPPER(", indexOfUpper + 1) == -1);
+        tstCase.assertTranslatedWell(orderBySql);
+    }
+
+    public void testDoTranslation6() throws Exception {
+        SelectQuery q = new SelectQuery(Artist.class);
+        q.addOrdering("artistName", SortOrder.ASCENDING_INSENSITIVE);
+        q.addOrdering("paintingArray.estimatedPrice", SortOrder.ASCENDING_INSENSITIVE);
+
+        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
+
+        TranslationCase tstCase = new TranslationCase("Artist", null,
+                "UPPER(ta.ARTIST_NAME), UPPER(ta.ESTIMATED_PRICE)");
+
+        StringBuilder out = new StringBuilder();
+        new OrderingTranslator(qa).appendPart(out);
+
+        assertTrue(out.length() > 0);
+        String orderBySql = out.toString();
+
+        // Check there is at least one UPPER modifier
+        int indexOfUpper = orderBySql.indexOf("UPPER(");
+        assertTrue(indexOfUpper != -1);
+
+        // and ensure there is another after it
+        assertTrue(orderBySql.indexOf("UPPER(", indexOfUpper + 1) != -1);
+
+        tstCase.assertTranslatedWell(orderBySql);
+    }
+
+    public void testDoTranslation3() throws Exception {
+        SelectQuery q = new SelectQuery(Artist.class);
+
+        q.addOrdering("artistName", SortOrder.DESCENDING);
+        q.addOrdering("paintingArray.estimatedPrice", SortOrder.ASCENDING);
+
+        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
+
+        TranslationCase tstCase = new TranslationCase("Artist", null, "ta.ARTIST_NAME DESC, ta.ESTIMATED_PRICE");
+
+        StringBuilder out = new StringBuilder();
+        new OrderingTranslator(qa).appendPart(out);
+
+        assertTrue(out.length() > 0);
+        String orderBySql = out.toString();
+        tstCase.assertTranslatedWell(orderBySql);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/OrderingTranslatorTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/OrderingTranslatorTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/OrderingTranslatorTest.java
deleted file mode 100644
index 84bebb7..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/OrderingTranslatorTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*****************************************************************
- *   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.access.translator.select;
-
-import java.sql.Connection;
-
-import org.apache.cayenne.TranslationCase;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.translator.select.OrderingTranslator;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.query.SortOrder;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class OrderingTranslatorTest extends ServerCase {
-
-    @Inject
-    private DataNode node;
-
-    @Inject
-    private ServerCaseDataSourceFactory dataSourceFactory;
-
-    private Connection connection;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        this.connection = dataSourceFactory.getSharedDataSource().getConnection();
-    }
-
-    @Override
-    protected void tearDownBeforeInjection() throws Exception {
-        connection.close();
-    }
-
-    /**
-     * Tests ascending ordering on string attribute.
-     */
-    public void testDoTranslation1() throws Exception {
-        SelectQuery q = new SelectQuery(Artist.class);
-        q.addOrdering("artistName", SortOrder.ASCENDING);
-
-        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
-
-        TranslationCase tstCase = new TranslationCase("Artist", null, "ta.ARTIST_NAME");
-
-        StringBuilder out = new StringBuilder();
-        new OrderingTranslator(qa).appendPart(out);
-
-        assertTrue(out.length() > 0);
-        tstCase.assertTranslatedWell(out.toString());
-    }
-
-    /**
-     * Tests descending ordering on string attribute.
-     */
-    public void testDoTranslation2() throws Exception {
-        SelectQuery q = new SelectQuery(Artist.class);
-        q.addOrdering("artistName", SortOrder.DESCENDING);
-
-        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
-
-        TranslationCase tstCase = new TranslationCase("Artist", null, "ta.ARTIST_NAME DESC");
-
-        StringBuilder out = new StringBuilder();
-        new OrderingTranslator(qa).appendPart(out);
-
-        assertTrue(out.length() > 0);
-        tstCase.assertTranslatedWell(out.toString());
-    }
-
-    /**
-     * Tests ascending case-insensitive ordering on string attribute.
-     */
-    public void testDoTranslation4() throws Exception {
-        SelectQuery q = new SelectQuery(Artist.class);
-        q.addOrdering("artistName", SortOrder.ASCENDING_INSENSITIVE);
-
-        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
-
-        TranslationCase tstCase = new TranslationCase("Artist", null, "UPPER(ta.ARTIST_NAME)");
-
-        StringBuilder out = new StringBuilder();
-        new OrderingTranslator(qa).appendPart(out);
-
-        assertTrue(out.length() > 0);
-        String orderBySql = out.toString();
-        assertTrue(orderBySql.contains("UPPER("));
-        tstCase.assertTranslatedWell(orderBySql);
-    }
-
-    public void testDoTranslation5() throws Exception {
-        SelectQuery q = new SelectQuery(Artist.class);
-        q.addOrdering("artistName", SortOrder.DESCENDING_INSENSITIVE);
-        q.addOrdering("paintingArray.estimatedPrice", SortOrder.ASCENDING);
-
-        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
-
-        TranslationCase tstCase = new TranslationCase("Artist", null, "UPPER(ta.ARTIST_NAME) DESC, ta.ESTIMATED_PRICE");
-
-        StringBuilder out = new StringBuilder();
-        new OrderingTranslator(qa).appendPart(out);
-
-        assertTrue(out.length() > 0);
-        String orderBySql = out.toString();
-
-        // Check there is an UPPER modifier
-        int indexOfUpper = orderBySql.indexOf("UPPER(");
-        assertTrue(indexOfUpper != -1);
-
-        // and ensure there is only ONE upper modifier
-        assertTrue(orderBySql.indexOf("UPPER(", indexOfUpper + 1) == -1);
-        tstCase.assertTranslatedWell(orderBySql);
-    }
-
-    public void testDoTranslation6() throws Exception {
-        SelectQuery q = new SelectQuery(Artist.class);
-        q.addOrdering("artistName", SortOrder.ASCENDING_INSENSITIVE);
-        q.addOrdering("paintingArray.estimatedPrice", SortOrder.ASCENDING_INSENSITIVE);
-
-        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
-
-        TranslationCase tstCase = new TranslationCase("Artist", null,
-                "UPPER(ta.ARTIST_NAME), UPPER(ta.ESTIMATED_PRICE)");
-
-        StringBuilder out = new StringBuilder();
-        new OrderingTranslator(qa).appendPart(out);
-
-        assertTrue(out.length() > 0);
-        String orderBySql = out.toString();
-
-        // Check there is at least one UPPER modifier
-        int indexOfUpper = orderBySql.indexOf("UPPER(");
-        assertTrue(indexOfUpper != -1);
-
-        // and ensure there is another after it
-        assertTrue(orderBySql.indexOf("UPPER(", indexOfUpper + 1) != -1);
-
-        tstCase.assertTranslatedWell(orderBySql);
-    }
-
-    public void testDoTranslation3() throws Exception {
-        SelectQuery q = new SelectQuery(Artist.class);
-
-        q.addOrdering("artistName", SortOrder.DESCENDING);
-        q.addOrdering("paintingArray.estimatedPrice", SortOrder.ASCENDING);
-
-        TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
-
-        TranslationCase tstCase = new TranslationCase("Artist", null, "ta.ARTIST_NAME DESC, ta.ESTIMATED_PRICE");
-
-        StringBuilder out = new StringBuilder();
-        new OrderingTranslator(qa).appendPart(out);
-
-        assertTrue(out.length() > 0);
-        String orderBySql = out.toString();
-        tstCase.assertTranslatedWell(orderBySql);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QualifierTranslatorIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QualifierTranslatorIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QualifierTranslatorIT.java
new file mode 100644
index 0000000..c463839
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QualifierTranslatorIT.java
@@ -0,0 +1,138 @@
+/*****************************************************************
+ *   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.access.translator.select;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.exp.TstBinaryExpSuite;
+import org.apache.cayenne.exp.TstExpressionCase;
+import org.apache.cayenne.exp.TstExpressionSuite;
+import org.apache.cayenne.exp.TstTernaryExpSuite;
+import org.apache.cayenne.exp.TstUnaryExpSuite;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.query.MockQuery;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.testdo.testmap.Gallery;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.Connection;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class QualifierTranslatorIT extends ServerCase {
+
+    @Inject
+    private DataNode node;
+
+    @Inject
+    private ServerCaseDataSourceFactory dataSourceFactory;
+
+    private Connection connection;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        this.connection = dataSourceFactory.getSharedDataSource().getConnection();
+    }
+
+    @Override
+    protected void tearDownBeforeInjection() throws Exception {
+        connection.close();
+    }
+
+    public void testNonQualifiedQuery() throws Exception {
+        TstQueryAssembler qa = new TstQueryAssembler(new MockQuery(), node, connection);
+
+        try {
+            new QualifierTranslator(qa).appendPart(new StringBuilder());
+            fail();
+        } catch (ClassCastException ccex) {
+            // exception expected
+        }
+    }
+
+    public void testNullQualifier() throws Exception {
+        TstQueryAssembler qa = new TstQueryAssembler(new SelectQuery<Object>(), node, connection);
+
+        StringBuilder out = new StringBuilder();
+        new QualifierTranslator(qa).appendPart(out);
+        assertEquals(0, out.length());
+    }
+
+    public void testUnary() throws Exception {
+        doExpressionTest(new TstUnaryExpSuite());
+    }
+
+    public void testBinary() throws Exception {
+        doExpressionTest(new TstBinaryExpSuite());
+    }
+
+    public void testTernary() throws Exception {
+        doExpressionTest(new TstTernaryExpSuite());
+    }
+
+    public void testExtras() throws Exception {
+        ObjectId oid1 = new ObjectId("Gallery", "GALLERY_ID", 1);
+        ObjectId oid2 = new ObjectId("Gallery", "GALLERY_ID", 2);
+        Gallery g1 = new Gallery();
+        Gallery g2 = new Gallery();
+        g1.setObjectId(oid1);
+        g2.setObjectId(oid2);
+
+        Expression e1 = ExpressionFactory.matchExp("toGallery", g1);
+        Expression e2 = e1.orExp(ExpressionFactory.matchExp("toGallery", g2));
+
+        TstExpressionCase extraCase = new TstExpressionCase("Exhibit", e2,
+                "(ta.GALLERY_ID = ?) OR (ta.GALLERY_ID = ?)", 4, 4);
+
+        TstExpressionSuite suite = new TstExpressionSuite() {
+        };
+        suite.addCase(extraCase);
+        doExpressionTest(suite);
+    }
+
+    private void doExpressionTest(TstExpressionSuite suite) throws Exception {
+
+        TstExpressionCase[] cases = suite.cases();
+
+        int len = cases.length;
+        for (int i = 0; i < len; i++) {
+            try {
+
+                ObjEntity entity = node.getEntityResolver().getObjEntity(cases[i].getRootEntity());
+                assertNotNull(entity);
+                SelectQuery q = new SelectQuery(entity);
+                q.setQualifier(cases[i].getCayenneExp());
+
+                TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
+
+                StringBuilder out = new StringBuilder();
+                new QualifierTranslator(qa).appendPart(out);
+                cases[i].assertTranslatedWell(out.toString());
+            } catch (Exception ex) {
+                throw new CayenneRuntimeException("Failed case: [" + i + "]: " + cases[i], ex);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QualifierTranslatorTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QualifierTranslatorTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QualifierTranslatorTest.java
deleted file mode 100644
index ed94e37..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QualifierTranslatorTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*****************************************************************
- *   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.access.translator.select;
-
-import java.sql.Connection;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.translator.select.QualifierTranslator;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.exp.TstBinaryExpSuite;
-import org.apache.cayenne.exp.TstExpressionCase;
-import org.apache.cayenne.exp.TstExpressionSuite;
-import org.apache.cayenne.exp.TstTernaryExpSuite;
-import org.apache.cayenne.exp.TstUnaryExpSuite;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.query.MockQuery;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.testdo.testmap.Gallery;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class QualifierTranslatorTest extends ServerCase {
-
-    @Inject
-    private DataNode node;
-
-    @Inject
-    private ServerCaseDataSourceFactory dataSourceFactory;
-
-    private Connection connection;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        this.connection = dataSourceFactory.getSharedDataSource().getConnection();
-    }
-
-    @Override
-    protected void tearDownBeforeInjection() throws Exception {
-        connection.close();
-    }
-
-    public void testNonQualifiedQuery() throws Exception {
-        TstQueryAssembler qa = new TstQueryAssembler(new MockQuery(), node, connection);
-
-        try {
-            new QualifierTranslator(qa).appendPart(new StringBuilder());
-            fail();
-        } catch (ClassCastException ccex) {
-            // exception expected
-        }
-    }
-
-    public void testNullQualifier() throws Exception {
-        TstQueryAssembler qa = new TstQueryAssembler(new SelectQuery<Object>(), node, connection);
-
-        StringBuilder out = new StringBuilder();
-        new QualifierTranslator(qa).appendPart(out);
-        assertEquals(0, out.length());
-    }
-
-    public void testUnary() throws Exception {
-        doExpressionTest(new TstUnaryExpSuite());
-    }
-
-    public void testBinary() throws Exception {
-        doExpressionTest(new TstBinaryExpSuite());
-    }
-
-    public void testTernary() throws Exception {
-        doExpressionTest(new TstTernaryExpSuite());
-    }
-
-    public void testExtras() throws Exception {
-        ObjectId oid1 = new ObjectId("Gallery", "GALLERY_ID", 1);
-        ObjectId oid2 = new ObjectId("Gallery", "GALLERY_ID", 2);
-        Gallery g1 = new Gallery();
-        Gallery g2 = new Gallery();
-        g1.setObjectId(oid1);
-        g2.setObjectId(oid2);
-
-        Expression e1 = ExpressionFactory.matchExp("toGallery", g1);
-        Expression e2 = e1.orExp(ExpressionFactory.matchExp("toGallery", g2));
-
-        TstExpressionCase extraCase = new TstExpressionCase("Exhibit", e2,
-                "(ta.GALLERY_ID = ?) OR (ta.GALLERY_ID = ?)", 4, 4);
-
-        TstExpressionSuite suite = new TstExpressionSuite() {
-        };
-        suite.addCase(extraCase);
-        doExpressionTest(suite);
-    }
-
-    private void doExpressionTest(TstExpressionSuite suite) throws Exception {
-
-        TstExpressionCase[] cases = suite.cases();
-
-        int len = cases.length;
-        for (int i = 0; i < len; i++) {
-            try {
-
-                ObjEntity entity = node.getEntityResolver().getObjEntity(cases[i].getRootEntity());
-                assertNotNull(entity);
-                SelectQuery q = new SelectQuery(entity);
-                q.setQualifier(cases[i].getCayenneExp());
-
-                TstQueryAssembler qa = new TstQueryAssembler(q, node, connection);
-
-                StringBuilder out = new StringBuilder();
-                new QualifierTranslator(qa).appendPart(out);
-                cases[i].assertTranslatedWell(out.toString());
-            } catch (Exception ex) {
-                throw new CayenneRuntimeException("Failed case: [" + i + "]: " + cases[i], ex);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QueryAssemblerIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QueryAssemblerIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QueryAssemblerIT.java
new file mode 100644
index 0000000..e2b299b
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QueryAssemblerIT.java
@@ -0,0 +1,73 @@
+/*****************************************************************
+ *   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.access.translator.select;
+
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.Connection;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class QueryAssemblerIT extends ServerCase {
+
+    @Inject
+    private DataNode dataNode;
+
+    @Inject
+    private ServerCaseDataSourceFactory dataSourceFactory;
+
+    private Connection connection;
+
+    private TstQueryAssembler qa;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        this.connection = dataSourceFactory.getSharedDataSource().getConnection();
+        this.qa = new TstQueryAssembler(new SelectQuery<Object>(), dataNode, connection);
+    }
+
+    @Override
+    protected void tearDownBeforeInjection() throws Exception {
+        connection.close();
+    }
+
+    public void testGetQuery() throws Exception {
+        assertNotNull(qa.getQuery());
+    }
+
+    public void testAddToParamList() throws Exception {
+
+        assertEquals(0, qa.getAttributes().size());
+        assertEquals(0, qa.getValues().size());
+
+        qa.addToParamList(new DbAttribute(), new Object());
+        assertEquals(1, qa.getAttributes().size());
+        assertEquals(1, qa.getValues().size());
+    }
+
+    public void testCreateStatement() throws Exception {
+        assertNotNull(qa.createStatement());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QueryAssemblerTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QueryAssemblerTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QueryAssemblerTest.java
deleted file mode 100644
index e0e2ed1..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/select/QueryAssemblerTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*****************************************************************
- *   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.access.translator.select;
-
-import java.sql.Connection;
-
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class QueryAssemblerTest extends ServerCase {
-
-    @Inject
-    private DataNode dataNode;
-
-    @Inject
-    private ServerCaseDataSourceFactory dataSourceFactory;
-
-    private Connection connection;
-
-    private TstQueryAssembler qa;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        this.connection = dataSourceFactory.getSharedDataSource().getConnection();
-        this.qa = new TstQueryAssembler(new SelectQuery<Object>(), dataNode, connection);
-    }
-
-    @Override
-    protected void tearDownBeforeInjection() throws Exception {
-        connection.close();
-    }
-
-    public void testGetQuery() throws Exception {
-        assertNotNull(qa.getQuery());
-    }
-
-    public void testAddToParamList() throws Exception {
-
-        assertEquals(0, qa.getAttributes().size());
-        assertEquals(0, qa.getValues().size());
-
-        qa.addToParamList(new DbAttribute(), new Object());
-        assertEquals(1, qa.getAttributes().size());
-        assertEquals(1, qa.getValues().size());
-    }
-
-    public void testCreateStatement() throws Exception {
-        assertNotNull(qa.createStatement());
-    }
-}


Mime
View raw message