cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [15/48] Installing Maven Failsafe Plugin
Date Sun, 02 Nov 2014 07:10:03 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionIT.java
new file mode 100644
index 0000000..be323bb
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionIT.java
@@ -0,0 +1,90 @@
+/*****************************************************************
+ *   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.jdbc;
+
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.query.InsertBatchQuery;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.GeneratedColumnTestEntity;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import static org.mockito.Mockito.mock;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class BatchActionIT extends ServerCase {
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private AdhocObjectFactory objectFactory;
+
+    public void testHasGeneratedKeys1() throws Exception {
+        EntityResolver resolver = runtime.getChannel().getEntityResolver();
+
+        // test with adapter that supports keys
+        JdbcAdapter adapter = buildAdapter(true);
+
+        InsertBatchQuery batch1 = new InsertBatchQuery(resolver.getObjEntity(GeneratedColumnTestEntity.class)
+                .getDbEntity(), 5);
+        DataNode node = new DataNode();
+        node.setAdapter(adapter);
+        node.setEntityResolver(resolver);
+        node.setRowReaderFactory(mock(RowReaderFactory.class));
+
+        assertTrue(new BatchAction(batch1, node, false).hasGeneratedKeys());
+
+        InsertBatchQuery batch2 = new InsertBatchQuery(resolver.getObjEntity(Artist.class).getDbEntity(), 5);
+        assertFalse(new BatchAction(batch2, node, false).hasGeneratedKeys());
+    }
+
+    public void testHasGeneratedKeys2() throws Exception {
+        EntityResolver resolver = runtime.getChannel().getEntityResolver();
+
+        // test with adapter that does not support keys...
+        JdbcAdapter adapter = buildAdapter(false);
+
+        InsertBatchQuery batch1 = new InsertBatchQuery(resolver.getObjEntity(GeneratedColumnTestEntity.class)
+                .getDbEntity(), 5);
+
+        DataNode node = new DataNode();
+        node.setAdapter(adapter);
+        node.setEntityResolver(resolver);
+        node.setRowReaderFactory(mock(RowReaderFactory.class));
+
+        assertFalse(new BatchAction(batch1, node, false).hasGeneratedKeys());
+
+        InsertBatchQuery batch2 = new InsertBatchQuery(resolver.getObjEntity(Artist.class).getDbEntity(), 5);
+        assertFalse(new BatchAction(batch2, node, false).hasGeneratedKeys());
+    }
+
+    JdbcAdapter buildAdapter(boolean supportGeneratedKeys) {
+        JdbcAdapter adapter = objectFactory.newInstance(JdbcAdapter.class, JdbcAdapter.class.getName());
+        adapter.setSupportsGeneratedKeys(supportGeneratedKeys);
+        return adapter;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingIT.java
new file mode 100644
index 0000000..42061b8
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingIT.java
@@ -0,0 +1,154 @@
+/*****************************************************************
+ *   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.jdbc;
+
+import com.mockrunner.jdbc.PreparedStatementResultSetHandler;
+import com.mockrunner.mock.jdbc.MockConnection;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.MockOperationObserver;
+import org.apache.cayenne.access.OptimisticLockException;
+import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
+import org.apache.cayenne.access.translator.batch.DeleteBatchTranslator;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.query.DeleteBatchQuery;
+import org.apache.cayenne.testdo.locking.SimpleLockingTestEntity;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Mockito.mock;
+
+@UseServerRuntime(ServerCase.LOCKING_PROJECT)
+public class BatchActionLockingIT extends ServerCase {
+
+    @Inject
+    protected ServerRuntime runtime;
+
+    @Inject
+    private Injector injector;
+
+    @Inject
+    private AdhocObjectFactory objectFactory;
+
+    public void testRunAsIndividualQueriesSuccess() throws Exception {
+        EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
+
+        // test with adapter that supports keys...
+        JdbcAdapter adapter = buildAdapter(true);
+
+        DbEntity dbEntity = resolver.getObjEntity(SimpleLockingTestEntity.class).getDbEntity();
+
+        List<DbAttribute> qualifierAttributes = Arrays.asList(dbEntity.getAttribute("LOCKING_TEST_ID"),
+                dbEntity.getAttribute("NAME"));
+
+        Collection<String> nullAttributeNames = Collections.singleton("NAME");
+
+        Map<String, Object> qualifierSnapshot = new HashMap<String, Object>();
+        qualifierSnapshot.put("LOCKING_TEST_ID", new Integer(1));
+
+        DeleteBatchQuery batchQuery = new DeleteBatchQuery(dbEntity, qualifierAttributes, nullAttributeNames, 5);
+        batchQuery.setUsingOptimisticLocking(true);
+        batchQuery.add(qualifierSnapshot);
+
+        DeleteBatchTranslator batchQueryBuilder = new DeleteBatchTranslator(batchQuery, adapter, null);
+
+        MockConnection mockConnection = new MockConnection();
+        PreparedStatementResultSetHandler preparedStatementResultSetHandler = mockConnection
+                .getPreparedStatementResultSetHandler();
+        preparedStatementResultSetHandler.setExactMatch(false);
+        preparedStatementResultSetHandler.setCaseSensitive(false);
+        preparedStatementResultSetHandler.prepareUpdateCount("DELETE", 1);
+
+        boolean generatesKeys = false;
+
+        DataNode node = new DataNode();
+        node.setAdapter(adapter);
+        node.setEntityResolver(resolver);
+        node.setRowReaderFactory(mock(RowReaderFactory.class));
+        BatchAction action = new BatchAction(batchQuery, node, false);
+        action.runAsIndividualQueries(mockConnection, batchQueryBuilder, new MockOperationObserver(), generatesKeys);
+        assertEquals(0, mockConnection.getNumberCommits());
+        assertEquals(0, mockConnection.getNumberRollbacks());
+    }
+
+    public void testRunAsIndividualQueriesOptimisticLockingFailure() throws Exception {
+        EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
+
+        // test with adapter that supports keys...
+        JdbcAdapter adapter = buildAdapter(true);
+
+        DbEntity dbEntity = resolver.getObjEntity(SimpleLockingTestEntity.class).getDbEntity();
+
+        List<DbAttribute> qualifierAttributes = Arrays.asList(dbEntity.getAttribute("LOCKING_TEST_ID"),
+                dbEntity.getAttribute("NAME"));
+
+        Collection<String> nullAttributeNames = Collections.singleton("NAME");
+
+        Map<String, Object> qualifierSnapshot = new HashMap<String, Object>();
+        qualifierSnapshot.put("LOCKING_TEST_ID", new Integer(1));
+
+        DeleteBatchQuery batchQuery = new DeleteBatchQuery(dbEntity, qualifierAttributes, nullAttributeNames, 5);
+        batchQuery.setUsingOptimisticLocking(true);
+        batchQuery.add(qualifierSnapshot);
+
+        DeleteBatchTranslator batchQueryBuilder = new DeleteBatchTranslator(batchQuery, adapter, null);
+
+        MockConnection mockConnection = new MockConnection();
+        PreparedStatementResultSetHandler preparedStatementResultSetHandler = mockConnection
+                .getPreparedStatementResultSetHandler();
+        preparedStatementResultSetHandler.setExactMatch(false);
+        preparedStatementResultSetHandler.setCaseSensitive(false);
+        preparedStatementResultSetHandler.prepareUpdateCount("DELETE", 0);
+
+        boolean generatesKeys = false;
+        DataNode node = new DataNode();
+        node.setAdapter(adapter);
+        node.setEntityResolver(resolver);
+        node.setRowReaderFactory(mock(RowReaderFactory.class));
+        BatchAction action = new BatchAction(batchQuery, node, false);
+        try {
+            action.runAsIndividualQueries(mockConnection, batchQueryBuilder, new MockOperationObserver(), generatesKeys);
+            fail("No OptimisticLockingFailureException thrown.");
+        } catch (OptimisticLockException e) {
+        }
+        assertEquals(0, mockConnection.getNumberCommits());
+        assertEquals(0, mockConnection.getNumberRollbacks());
+    }
+
+    JdbcAdapter buildAdapter(boolean supportGeneratedKeys) {
+        JdbcAdapter adapter = objectFactory.newInstance(JdbcAdapter.class, JdbcAdapter.class.getName());
+        adapter.setSupportsGeneratedKeys(supportGeneratedKeys);
+        injector.injectMembers(adapter);
+        return adapter;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingTest.java
deleted file mode 100644
index be650c3..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingTest.java
+++ /dev/null
@@ -1,155 +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.jdbc;
-
-import static org.mockito.Mockito.mock;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.MockOperationObserver;
-import org.apache.cayenne.access.OptimisticLockException;
-import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
-import org.apache.cayenne.access.translator.batch.DeleteBatchTranslator;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.dba.JdbcAdapter;
-import org.apache.cayenne.di.AdhocObjectFactory;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.di.Injector;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.query.DeleteBatchQuery;
-import org.apache.cayenne.testdo.locking.SimpleLockingTestEntity;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-import com.mockrunner.jdbc.PreparedStatementResultSetHandler;
-import com.mockrunner.mock.jdbc.MockConnection;
-
-@UseServerRuntime(ServerCase.LOCKING_PROJECT)
-public class BatchActionLockingTest extends ServerCase {
-
-    @Inject
-    protected ServerRuntime runtime;
-
-    @Inject
-    private Injector injector;
-
-    @Inject
-    private AdhocObjectFactory objectFactory;
-
-    public void testRunAsIndividualQueriesSuccess() throws Exception {
-        EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
-
-        // test with adapter that supports keys...
-        JdbcAdapter adapter = buildAdapter(true);
-
-        DbEntity dbEntity = resolver.getObjEntity(SimpleLockingTestEntity.class).getDbEntity();
-
-        List<DbAttribute> qualifierAttributes = Arrays.asList(dbEntity.getAttribute("LOCKING_TEST_ID"),
-                dbEntity.getAttribute("NAME"));
-
-        Collection<String> nullAttributeNames = Collections.singleton("NAME");
-
-        Map<String, Object> qualifierSnapshot = new HashMap<String, Object>();
-        qualifierSnapshot.put("LOCKING_TEST_ID", new Integer(1));
-
-        DeleteBatchQuery batchQuery = new DeleteBatchQuery(dbEntity, qualifierAttributes, nullAttributeNames, 5);
-        batchQuery.setUsingOptimisticLocking(true);
-        batchQuery.add(qualifierSnapshot);
-
-        DeleteBatchTranslator batchQueryBuilder = new DeleteBatchTranslator(batchQuery, adapter, null);
-
-        MockConnection mockConnection = new MockConnection();
-        PreparedStatementResultSetHandler preparedStatementResultSetHandler = mockConnection
-                .getPreparedStatementResultSetHandler();
-        preparedStatementResultSetHandler.setExactMatch(false);
-        preparedStatementResultSetHandler.setCaseSensitive(false);
-        preparedStatementResultSetHandler.prepareUpdateCount("DELETE", 1);
-
-        boolean generatesKeys = false;
-
-        DataNode node = new DataNode();
-        node.setAdapter(adapter);
-        node.setEntityResolver(resolver);
-        node.setRowReaderFactory(mock(RowReaderFactory.class));
-        BatchAction action = new BatchAction(batchQuery, node, false);
-        action.runAsIndividualQueries(mockConnection, batchQueryBuilder, new MockOperationObserver(), generatesKeys);
-        assertEquals(0, mockConnection.getNumberCommits());
-        assertEquals(0, mockConnection.getNumberRollbacks());
-    }
-
-    public void testRunAsIndividualQueriesOptimisticLockingFailure() throws Exception {
-        EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
-
-        // test with adapter that supports keys...
-        JdbcAdapter adapter = buildAdapter(true);
-
-        DbEntity dbEntity = resolver.getObjEntity(SimpleLockingTestEntity.class).getDbEntity();
-
-        List<DbAttribute> qualifierAttributes = Arrays.asList(dbEntity.getAttribute("LOCKING_TEST_ID"),
-                dbEntity.getAttribute("NAME"));
-
-        Collection<String> nullAttributeNames = Collections.singleton("NAME");
-
-        Map<String, Object> qualifierSnapshot = new HashMap<String, Object>();
-        qualifierSnapshot.put("LOCKING_TEST_ID", new Integer(1));
-
-        DeleteBatchQuery batchQuery = new DeleteBatchQuery(dbEntity, qualifierAttributes, nullAttributeNames, 5);
-        batchQuery.setUsingOptimisticLocking(true);
-        batchQuery.add(qualifierSnapshot);
-
-        DeleteBatchTranslator batchQueryBuilder = new DeleteBatchTranslator(batchQuery, adapter, null);
-
-        MockConnection mockConnection = new MockConnection();
-        PreparedStatementResultSetHandler preparedStatementResultSetHandler = mockConnection
-                .getPreparedStatementResultSetHandler();
-        preparedStatementResultSetHandler.setExactMatch(false);
-        preparedStatementResultSetHandler.setCaseSensitive(false);
-        preparedStatementResultSetHandler.prepareUpdateCount("DELETE", 0);
-
-        boolean generatesKeys = false;
-        DataNode node = new DataNode();
-        node.setAdapter(adapter);
-        node.setEntityResolver(resolver);
-        node.setRowReaderFactory(mock(RowReaderFactory.class));
-        BatchAction action = new BatchAction(batchQuery, node, false);
-        try {
-            action.runAsIndividualQueries(mockConnection, batchQueryBuilder, new MockOperationObserver(), generatesKeys);
-            fail("No OptimisticLockingFailureException thrown.");
-        } catch (OptimisticLockException e) {
-        }
-        assertEquals(0, mockConnection.getNumberCommits());
-        assertEquals(0, mockConnection.getNumberRollbacks());
-    }
-
-    JdbcAdapter buildAdapter(boolean supportGeneratedKeys) {
-        JdbcAdapter adapter = objectFactory.newInstance(JdbcAdapter.class, JdbcAdapter.class.getName());
-        adapter.setSupportsGeneratedKeys(supportGeneratedKeys);
-        injector.injectMembers(adapter);
-        return adapter;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionTest.java
deleted file mode 100644
index 8f26afb..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BatchActionTest.java
+++ /dev/null
@@ -1,90 +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.jdbc;
-
-import static org.mockito.Mockito.mock;
-
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.dba.JdbcAdapter;
-import org.apache.cayenne.di.AdhocObjectFactory;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.query.InsertBatchQuery;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.testdo.testmap.GeneratedColumnTestEntity;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class BatchActionTest extends ServerCase {
-
-    @Inject
-    private ServerRuntime runtime;
-
-    @Inject
-    private AdhocObjectFactory objectFactory;
-
-    public void testHasGeneratedKeys1() throws Exception {
-        EntityResolver resolver = runtime.getChannel().getEntityResolver();
-
-        // test with adapter that supports keys
-        JdbcAdapter adapter = buildAdapter(true);
-
-        InsertBatchQuery batch1 = new InsertBatchQuery(resolver.getObjEntity(GeneratedColumnTestEntity.class)
-                .getDbEntity(), 5);
-        DataNode node = new DataNode();
-        node.setAdapter(adapter);
-        node.setEntityResolver(resolver);
-        node.setRowReaderFactory(mock(RowReaderFactory.class));
-
-        assertTrue(new BatchAction(batch1, node, false).hasGeneratedKeys());
-
-        InsertBatchQuery batch2 = new InsertBatchQuery(resolver.getObjEntity(Artist.class).getDbEntity(), 5);
-        assertFalse(new BatchAction(batch2, node, false).hasGeneratedKeys());
-    }
-
-    public void testHasGeneratedKeys2() throws Exception {
-        EntityResolver resolver = runtime.getChannel().getEntityResolver();
-
-        // test with adapter that does not support keys...
-        JdbcAdapter adapter = buildAdapter(false);
-
-        InsertBatchQuery batch1 = new InsertBatchQuery(resolver.getObjEntity(GeneratedColumnTestEntity.class)
-                .getDbEntity(), 5);
-
-        DataNode node = new DataNode();
-        node.setAdapter(adapter);
-        node.setEntityResolver(resolver);
-        node.setRowReaderFactory(mock(RowReaderFactory.class));
-
-        assertFalse(new BatchAction(batch1, node, false).hasGeneratedKeys());
-
-        InsertBatchQuery batch2 = new InsertBatchQuery(resolver.getObjEntity(Artist.class).getDbEntity(), 5);
-        assertFalse(new BatchAction(batch2, node, false).hasGeneratedKeys());
-    }
-
-    JdbcAdapter buildAdapter(boolean supportGeneratedKeys) {
-        JdbcAdapter adapter = objectFactory.newInstance(JdbcAdapter.class, JdbcAdapter.class.getName());
-        adapter.setSupportsGeneratedKeys(supportGeneratedKeys);
-        return adapter;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveIT.java
new file mode 100644
index 0000000..e9beaa8
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveIT.java
@@ -0,0 +1,267 @@
+/*****************************************************************
+ *   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.jdbc;
+
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.MockOperationObserver;
+import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
+import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.dba.oracle.OracleAdapter;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.log.JdbcEventLogger;
+import org.apache.cayenne.query.CapsStrategy;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+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;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.mockito.Mockito.mock;
+
+/**
+ * Tests BindDirective for passed null parameters and for not passed parameters
+ */
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class BindDirectiveIT extends ServerCase {
+
+    @Inject
+    private ServerCaseDataSourceFactory dataSourceFactory;
+
+    @Inject
+    private JdbcAdapter adapter;
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Inject
+    private JdbcEventLogger logger;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+    }
+
+    public void testBindTimestamp() throws Exception {
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put("id", new Integer(1));
+        parameters.put("name", "ArtistWithDOB");
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(2010, 2, 8);
+        parameters.put("dob", new Timestamp(cal.getTime().getTime()));
+
+        // without JDBC usage
+        Map<String, ?> row = performInsertForParameters(parameters, false, 1);
+        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
+        assertEquals(cal.getTime(), row.get("DATE_OF_BIRTH"));
+        assertNotNull(row.get("DATE_OF_BIRTH"));
+        assertEquals(Date.class, row.get("DATE_OF_BIRTH").getClass());
+    }
+
+    public void testBindSQLDate() throws Exception {
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put("id", new Integer(1));
+        parameters.put("name", "ArtistWithDOB");
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(2010, 2, 8);
+        parameters.put("dob", new java.sql.Date(cal.getTime().getTime()));
+
+        // without JDBC usage
+        Map<String, ?> row = performInsertForParameters(parameters, false, 1);
+        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
+        assertEquals(parameters.get("dob"), row.get("DATE_OF_BIRTH"));
+        assertNotNull(row.get("DATE_OF_BIRTH"));
+        assertEquals(Date.class, row.get("DATE_OF_BIRTH").getClass());
+    }
+
+    public void testBindUtilDate() throws Exception {
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put("id", new Integer(1));
+        parameters.put("name", "ArtistWithDOB");
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(2010, 2, 8);
+        parameters.put("dob", cal.getTime());
+
+        // without JDBC usage
+        Map<String, ?> row = performInsertForParameters(parameters, false, 1);
+        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
+        assertEquals(parameters.get("dob"), row.get("DATE_OF_BIRTH"));
+        assertNotNull(row.get("DATE_OF_BIRTH"));
+        assertEquals(Date.class, row.get("DATE_OF_BIRTH").getClass());
+    }
+
+    public void testBindingForCollection() throws Exception {
+
+        // insert 3 artists
+        for (int i = 1; i < 4; i++) {
+            Map<String, Object> parameters = new HashMap<String, Object>();
+            parameters.put("id", new Long(i));
+            parameters.put("name", "Artist" + i);
+            performInsertForParameters(parameters, true, i);
+        }
+
+        // now select only with names: Artist1 and Artist3
+        Set<String> artistNames = new HashSet<String>();
+        artistNames.add("Artist1");
+        artistNames.add("Artist3");
+        String sql = "SELECT * FROM ARTIST WHERE ARTIST_NAME in (#bind($ARTISTNAMES))";
+        SQLTemplate query = new SQLTemplate(Artist.class, sql);
+        
+        // customize for DB's that require trimming CHAR spaces 
+        query.setTemplate(OracleAdapter.class.getName(), "SELECT * FROM ARTIST WHERE RTRIM(ARTIST_NAME) in (#bind($ARTISTNAMES))");
+        
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+        query.setParameters(Collections.singletonMap("ARTISTNAMES", artistNames));
+        List<DataRow> result = context.performQuery(query);
+        assertEquals(2, result.size());
+    }
+
+    public void testBindForPassedNullParam() throws Exception {
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put("id", new Long(1));
+        parameters.put("name", "ArtistWithoutDOB");
+        // passing null in parameter
+        parameters.put("dob", null);
+
+        // without JDBC usage
+        Map<String, ?> row = performInsertForParameters(parameters, false, 1);
+        assertEquals(parameters.get("id"), row.get("ARTIST_ID"));
+        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
+        assertEquals(parameters.get("dob"), row.get("DATE_OF_BIRTH"));
+        assertNull(row.get("DATE_OF_BIRTH"));
+    }
+
+    public void testBindWithJDBCForPassedNullParam() throws Exception {
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put("id", new Long(1));
+        parameters.put("name", "ArtistWithoutDOB");
+        // passing null in parameter
+        parameters.put("dob", null);
+
+        // use JDBC
+        Map<String, ?> row = performInsertForParameters(parameters, true, 1);
+        assertEquals(parameters.get("id"), row.get("ARTIST_ID"));
+        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
+        assertEquals(parameters.get("dob"), row.get("DATE_OF_BIRTH"));
+        assertNull(row.get("DATE_OF_BIRTH"));
+    }
+
+    public void testBindForNotPassedParam() throws Exception {
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put("id", new Long(1));
+        parameters.put("name", "ArtistWithoutDOB");
+        // not passing parameter parameters.put("dob", not passed!);
+
+        // without JDBC usage
+        Map<String, ?> row = performInsertForParameters(parameters, false, 1);
+        assertEquals(parameters.get("id"), row.get("ARTIST_ID"));
+        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
+        // parameter should be passed as null
+        assertNull(row.get("DATE_OF_BIRTH"));
+    }
+
+    public void testBindWithJDBCForNotPassedParam() throws Exception {
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put("id", new Long(1));
+        parameters.put("name", "ArtistWithoutDOB");
+        // not passing parameter parameters.put("dob", not passed!);
+
+        // use JDBC
+        Map<String, ?> row = performInsertForParameters(parameters, true, 1);
+        assertEquals(parameters.get("id"), row.get("ARTIST_ID"));
+        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
+        // parameter should be passed as null
+        assertNull(row.get("DATE_OF_BIRTH"));
+    }
+
+    /**
+     * Inserts row for given parameters
+     * 
+     * @return inserted row
+     */
+    private Map<String, ?> performInsertForParameters(
+            Map<String, Object> parameters,
+            boolean useJDBCType,
+            int expectedRowCount) throws Exception {
+
+        String templateString;
+        if (useJDBCType) {
+            templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
+                    + "VALUES (#bind($id), #bind($name), #bind($dob 'DATE'))";
+        }
+        else {
+            templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
+                    + "VALUES (#bind($id), #bind($name), #bind($dob))";
+        }
+        SQLTemplate template = new SQLTemplate(Object.class, templateString);
+
+        template.setParameters(parameters);
+
+        DataNode node = new DataNode();
+        node.setEntityResolver(context.getEntityResolver());
+        node.setRowReaderFactory(mock(RowReaderFactory.class));
+        node.setAdapter(adapter);
+        SQLTemplateAction action = new SQLTemplateAction(template, node);
+
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
+        try {
+            MockOperationObserver observer = new MockOperationObserver();
+            action.performAction(c, observer);
+
+            int[] batches = observer.countsForQuery(template);
+            assertNotNull(batches);
+            assertEquals(1, batches.length);
+            assertEquals(1, batches[0]);
+        }
+        finally {
+            c.close();
+        }
+
+        SelectQuery query = new SelectQuery(Artist.class);
+        query.setFetchingDataRows(true);
+
+        List<DataRow> data = context.performQuery(query);
+        assertEquals(expectedRowCount, data.size());
+        return data.get(0);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveTest.java
deleted file mode 100644
index 05bf796..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/BindDirectiveTest.java
+++ /dev/null
@@ -1,267 +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.jdbc;
-
-import static org.mockito.Mockito.mock;
-
-import java.sql.Connection;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.MockOperationObserver;
-import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
-import org.apache.cayenne.dba.JdbcAdapter;
-import org.apache.cayenne.dba.oracle.OracleAdapter;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.log.JdbcEventLogger;
-import org.apache.cayenne.query.CapsStrategy;
-import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-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;
-
-/**
- * Tests BindDirective for passed null parameters and for not passed parameters
- */
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class BindDirectiveTest extends ServerCase {
-
-    @Inject
-    private ServerCaseDataSourceFactory dataSourceFactory;
-
-    @Inject
-    private JdbcAdapter adapter;
-
-    @Inject
-    private ObjectContext context;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    @Inject
-    private JdbcEventLogger logger;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("PAINTING_INFO");
-        dbHelper.deleteAll("PAINTING");
-        dbHelper.deleteAll("ARTIST_EXHIBIT");
-        dbHelper.deleteAll("ARTIST_GROUP");
-        dbHelper.deleteAll("ARTIST");
-    }
-
-    public void testBindTimestamp() throws Exception {
-        Map<String, Object> parameters = new HashMap<String, Object>();
-        parameters.put("id", new Integer(1));
-        parameters.put("name", "ArtistWithDOB");
-        Calendar cal = Calendar.getInstance();
-        cal.clear();
-        cal.set(2010, 2, 8);
-        parameters.put("dob", new Timestamp(cal.getTime().getTime()));
-
-        // without JDBC usage
-        Map<String, ?> row = performInsertForParameters(parameters, false, 1);
-        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
-        assertEquals(cal.getTime(), row.get("DATE_OF_BIRTH"));
-        assertNotNull(row.get("DATE_OF_BIRTH"));
-        assertEquals(Date.class, row.get("DATE_OF_BIRTH").getClass());
-    }
-
-    public void testBindSQLDate() throws Exception {
-        Map<String, Object> parameters = new HashMap<String, Object>();
-        parameters.put("id", new Integer(1));
-        parameters.put("name", "ArtistWithDOB");
-        Calendar cal = Calendar.getInstance();
-        cal.clear();
-        cal.set(2010, 2, 8);
-        parameters.put("dob", new java.sql.Date(cal.getTime().getTime()));
-
-        // without JDBC usage
-        Map<String, ?> row = performInsertForParameters(parameters, false, 1);
-        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
-        assertEquals(parameters.get("dob"), row.get("DATE_OF_BIRTH"));
-        assertNotNull(row.get("DATE_OF_BIRTH"));
-        assertEquals(Date.class, row.get("DATE_OF_BIRTH").getClass());
-    }
-
-    public void testBindUtilDate() throws Exception {
-        Map<String, Object> parameters = new HashMap<String, Object>();
-        parameters.put("id", new Integer(1));
-        parameters.put("name", "ArtistWithDOB");
-        Calendar cal = Calendar.getInstance();
-        cal.clear();
-        cal.set(2010, 2, 8);
-        parameters.put("dob", cal.getTime());
-
-        // without JDBC usage
-        Map<String, ?> row = performInsertForParameters(parameters, false, 1);
-        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
-        assertEquals(parameters.get("dob"), row.get("DATE_OF_BIRTH"));
-        assertNotNull(row.get("DATE_OF_BIRTH"));
-        assertEquals(Date.class, row.get("DATE_OF_BIRTH").getClass());
-    }
-
-    public void testBindingForCollection() throws Exception {
-
-        // insert 3 artists
-        for (int i = 1; i < 4; i++) {
-            Map<String, Object> parameters = new HashMap<String, Object>();
-            parameters.put("id", new Long(i));
-            parameters.put("name", "Artist" + i);
-            performInsertForParameters(parameters, true, i);
-        }
-
-        // now select only with names: Artist1 and Artist3
-        Set<String> artistNames = new HashSet<String>();
-        artistNames.add("Artist1");
-        artistNames.add("Artist3");
-        String sql = "SELECT * FROM ARTIST WHERE ARTIST_NAME in (#bind($ARTISTNAMES))";
-        SQLTemplate query = new SQLTemplate(Artist.class, sql);
-        
-        // customize for DB's that require trimming CHAR spaces 
-        query.setTemplate(OracleAdapter.class.getName(), "SELECT * FROM ARTIST WHERE RTRIM(ARTIST_NAME) in (#bind($ARTISTNAMES))");
-        
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        query.setParameters(Collections.singletonMap("ARTISTNAMES", artistNames));
-        List<DataRow> result = context.performQuery(query);
-        assertEquals(2, result.size());
-    }
-
-    public void testBindForPassedNullParam() throws Exception {
-        Map<String, Object> parameters = new HashMap<String, Object>();
-        parameters.put("id", new Long(1));
-        parameters.put("name", "ArtistWithoutDOB");
-        // passing null in parameter
-        parameters.put("dob", null);
-
-        // without JDBC usage
-        Map<String, ?> row = performInsertForParameters(parameters, false, 1);
-        assertEquals(parameters.get("id"), row.get("ARTIST_ID"));
-        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
-        assertEquals(parameters.get("dob"), row.get("DATE_OF_BIRTH"));
-        assertNull(row.get("DATE_OF_BIRTH"));
-    }
-
-    public void testBindWithJDBCForPassedNullParam() throws Exception {
-        Map<String, Object> parameters = new HashMap<String, Object>();
-        parameters.put("id", new Long(1));
-        parameters.put("name", "ArtistWithoutDOB");
-        // passing null in parameter
-        parameters.put("dob", null);
-
-        // use JDBC
-        Map<String, ?> row = performInsertForParameters(parameters, true, 1);
-        assertEquals(parameters.get("id"), row.get("ARTIST_ID"));
-        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
-        assertEquals(parameters.get("dob"), row.get("DATE_OF_BIRTH"));
-        assertNull(row.get("DATE_OF_BIRTH"));
-    }
-
-    public void testBindForNotPassedParam() throws Exception {
-        Map<String, Object> parameters = new HashMap<String, Object>();
-        parameters.put("id", new Long(1));
-        parameters.put("name", "ArtistWithoutDOB");
-        // not passing parameter parameters.put("dob", not passed!);
-
-        // without JDBC usage
-        Map<String, ?> row = performInsertForParameters(parameters, false, 1);
-        assertEquals(parameters.get("id"), row.get("ARTIST_ID"));
-        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
-        // parameter should be passed as null
-        assertNull(row.get("DATE_OF_BIRTH"));
-    }
-
-    public void testBindWithJDBCForNotPassedParam() throws Exception {
-        Map<String, Object> parameters = new HashMap<String, Object>();
-        parameters.put("id", new Long(1));
-        parameters.put("name", "ArtistWithoutDOB");
-        // not passing parameter parameters.put("dob", not passed!);
-
-        // use JDBC
-        Map<String, ?> row = performInsertForParameters(parameters, true, 1);
-        assertEquals(parameters.get("id"), row.get("ARTIST_ID"));
-        assertEquals(parameters.get("name"), row.get("ARTIST_NAME"));
-        // parameter should be passed as null
-        assertNull(row.get("DATE_OF_BIRTH"));
-    }
-
-    /**
-     * Inserts row for given parameters
-     * 
-     * @return inserted row
-     */
-    private Map<String, ?> performInsertForParameters(
-            Map<String, Object> parameters,
-            boolean useJDBCType,
-            int expectedRowCount) throws Exception {
-
-        String templateString;
-        if (useJDBCType) {
-            templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
-                    + "VALUES (#bind($id), #bind($name), #bind($dob 'DATE'))";
-        }
-        else {
-            templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
-                    + "VALUES (#bind($id), #bind($name), #bind($dob))";
-        }
-        SQLTemplate template = new SQLTemplate(Object.class, templateString);
-
-        template.setParameters(parameters);
-
-        DataNode node = new DataNode();
-        node.setEntityResolver(context.getEntityResolver());
-        node.setRowReaderFactory(mock(RowReaderFactory.class));
-        node.setAdapter(adapter);
-        SQLTemplateAction action = new SQLTemplateAction(template, node);
-
-        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
-        try {
-            MockOperationObserver observer = new MockOperationObserver();
-            action.performAction(c, observer);
-
-            int[] batches = observer.countsForQuery(template);
-            assertNotNull(batches);
-            assertEquals(1, batches.length);
-            assertEquals(1, batches[0]);
-        }
-        finally {
-            c.close();
-        }
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        query.setFetchingDataRows(true);
-
-        List<DataRow> data = context.performQuery(query);
-        assertEquals(expectedRowCount, data.size());
-        return data.get(0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveIT.java
new file mode 100644
index 0000000..7b9bce4
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveIT.java
@@ -0,0 +1,187 @@
+/*****************************************************************
+ *   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.jdbc;
+
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.MockOperationObserver;
+import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.CapsStrategy;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.Connection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Mockito.mock;
+
+/**
+ * Test for Result directive to check if we could use ResultDitrective optionally.
+ */
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class ResultDirectiveIT extends ServerCase {
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Inject
+    private JdbcAdapter dbAdapter;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("PAINTING1");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+        dbHelper.deleteAll("EXHIBIT");
+        dbHelper.deleteAll("GALLERY");
+    }
+
+    public void testWithoutResultDirective() throws Exception {
+        String sql = "SELECT ARTIST_ID, ARTIST_NAME FROM ARTIST";
+        Map<String, Object> artist = insertArtist();
+        Map<String, Object> selectResult = selectForQuery(sql);
+
+        assertEquals(artist.get("ARTIST_ID"), selectResult.get("ARTIST_ID"));
+        assertEquals(artist.get("ARTIST_NAME"), selectResult.get("ARTIST_NAME"));
+    }
+
+    public void testWithOnlyResultDirective() throws Exception {
+        String sql = "SELECT #result('ARTIST_ID' 'java.lang.Integer'),"
+                + " #result('ARTIST_NAME' 'java.lang.String')"
+                + " FROM ARTIST";
+        Map<String, Object> artist = insertArtist();
+        Map<String, Object> selectResult = selectForQuery(sql);
+
+        assertEquals(artist.get("ARTIST_ID"), selectResult.get("ARTIST_ID"));
+        assertEquals(artist.get("ARTIST_NAME"), selectResult
+                .get("ARTIST_NAME")
+                .toString()
+                .trim());
+    }
+
+    public void testWithMixedDirectiveUse1() throws Exception {
+        String sql = "SELECT ARTIST_ID,"
+                + " #result('ARTIST_NAME' 'java.lang.String')"
+                + " FROM ARTIST";
+        Map<String, Object> artist = insertArtist();
+        Map<String, Object> selectResult = selectForQuery(sql);
+
+        assertEquals(artist.get("ARTIST_ID"), selectResult.get("ARTIST_ID"));
+        assertEquals(artist.get("ARTIST_NAME"), selectResult
+                .get("ARTIST_NAME")
+                .toString()
+                .trim());
+    }
+
+    public void testWithMixedDirectiveUse2() throws Exception {
+        String sql = "SELECT #result('ARTIST_ID' 'java.lang.Integer'),"
+                + " ARTIST_NAME "
+                + " FROM ARTIST";
+        Map<String, Object> artist = insertArtist();
+        Map<String, Object> selectResult = selectForQuery(sql);
+
+        assertEquals(artist.get("ARTIST_ID"), selectResult.get("ARTIST_ID"));
+        assertEquals(artist.get("ARTIST_NAME"), selectResult.get("ARTIST_NAME"));
+    }
+
+    private Map<String, Object> selectForQuery(String sql) {
+        SQLTemplate template = new SQLTemplate(Artist.class, sql);
+        template.setColumnNamesCapitalization(CapsStrategy.UPPER);
+        MockOperationObserver observer = new MockOperationObserver();
+        runtime.getDataDomain().performQueries(
+                Collections.singletonList(template),
+                observer);
+
+        List<Map<String, Object>> data = observer.rowsForQuery(template);
+        assertEquals(1, data.size());
+        Map<String, Object> row = data.get(0);
+        return row;
+    }
+
+    /**
+     * Inserts one Artist
+     * 
+     * @return Inserted Artist as a DataRow
+     */
+    private Map<String, Object> insertArtist() throws Exception {
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put("id", new Integer(1));
+        parameters.put("name", "ArtistToTestResult");
+        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
+                + "VALUES (#bind($id), #bind($name), #bind($dob))";
+
+        SQLTemplate template = new SQLTemplate(Object.class, templateString);
+
+        template.setParameters(parameters);
+
+        DataNode node = new DataNode();
+        node.setEntityResolver(runtime.getDataDomain().getEntityResolver());
+        node.setRowReaderFactory(mock(RowReaderFactory.class));
+        node.setAdapter(dbAdapter);
+        
+        SQLTemplateAction action = new SQLTemplateAction(template, node);
+
+        Connection c = runtime
+                .getDataDomain()
+                .getDataNodes()
+                .iterator()
+                .next()
+                .getDataSource()
+                .getConnection();
+        try {
+            MockOperationObserver observer = new MockOperationObserver();
+            action.performAction(c, observer);
+
+            int[] batches = observer.countsForQuery(template);
+            assertNotNull(batches);
+            assertEquals(1, batches.length);
+            assertEquals(1, batches[0]);
+        }
+        finally {
+            c.close();
+        }
+
+        MockOperationObserver observer = new MockOperationObserver();
+        SelectQuery query = new SelectQuery(Artist.class);
+        runtime
+                .getDataDomain()
+                .performQueries(Collections.singletonList(query), observer);
+
+        List<?> data = observer.rowsForQuery(query);
+        assertEquals(1, data.size());
+        DataRow row = (DataRow) data.get(0);
+        return row;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveTest.java
deleted file mode 100644
index cfa5d94..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveTest.java
+++ /dev/null
@@ -1,187 +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.jdbc;
-
-import static org.mockito.Mockito.mock;
-
-import java.sql.Connection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.MockOperationObserver;
-import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.dba.JdbcAdapter;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.CapsStrategy;
-import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-/**
- * Test for Result directive to check if we could use ResultDitrective optionally.
- */
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class ResultDirectiveTest extends ServerCase {
-
-    @Inject
-    private ServerRuntime runtime;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    @Inject
-    private JdbcAdapter dbAdapter;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("PAINTING_INFO");
-        dbHelper.deleteAll("PAINTING");
-        dbHelper.deleteAll("PAINTING1");
-        dbHelper.deleteAll("ARTIST_EXHIBIT");
-        dbHelper.deleteAll("ARTIST_GROUP");
-        dbHelper.deleteAll("ARTIST");
-        dbHelper.deleteAll("EXHIBIT");
-        dbHelper.deleteAll("GALLERY");
-    }
-
-    public void testWithoutResultDirective() throws Exception {
-        String sql = "SELECT ARTIST_ID, ARTIST_NAME FROM ARTIST";
-        Map<String, Object> artist = insertArtist();
-        Map<String, Object> selectResult = selectForQuery(sql);
-
-        assertEquals(artist.get("ARTIST_ID"), selectResult.get("ARTIST_ID"));
-        assertEquals(artist.get("ARTIST_NAME"), selectResult.get("ARTIST_NAME"));
-    }
-
-    public void testWithOnlyResultDirective() throws Exception {
-        String sql = "SELECT #result('ARTIST_ID' 'java.lang.Integer'),"
-                + " #result('ARTIST_NAME' 'java.lang.String')"
-                + " FROM ARTIST";
-        Map<String, Object> artist = insertArtist();
-        Map<String, Object> selectResult = selectForQuery(sql);
-
-        assertEquals(artist.get("ARTIST_ID"), selectResult.get("ARTIST_ID"));
-        assertEquals(artist.get("ARTIST_NAME"), selectResult
-                .get("ARTIST_NAME")
-                .toString()
-                .trim());
-    }
-
-    public void testWithMixedDirectiveUse1() throws Exception {
-        String sql = "SELECT ARTIST_ID,"
-                + " #result('ARTIST_NAME' 'java.lang.String')"
-                + " FROM ARTIST";
-        Map<String, Object> artist = insertArtist();
-        Map<String, Object> selectResult = selectForQuery(sql);
-
-        assertEquals(artist.get("ARTIST_ID"), selectResult.get("ARTIST_ID"));
-        assertEquals(artist.get("ARTIST_NAME"), selectResult
-                .get("ARTIST_NAME")
-                .toString()
-                .trim());
-    }
-
-    public void testWithMixedDirectiveUse2() throws Exception {
-        String sql = "SELECT #result('ARTIST_ID' 'java.lang.Integer'),"
-                + " ARTIST_NAME "
-                + " FROM ARTIST";
-        Map<String, Object> artist = insertArtist();
-        Map<String, Object> selectResult = selectForQuery(sql);
-
-        assertEquals(artist.get("ARTIST_ID"), selectResult.get("ARTIST_ID"));
-        assertEquals(artist.get("ARTIST_NAME"), selectResult.get("ARTIST_NAME"));
-    }
-
-    private Map<String, Object> selectForQuery(String sql) {
-        SQLTemplate template = new SQLTemplate(Artist.class, sql);
-        template.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        MockOperationObserver observer = new MockOperationObserver();
-        runtime.getDataDomain().performQueries(
-                Collections.singletonList(template),
-                observer);
-
-        List<Map<String, Object>> data = observer.rowsForQuery(template);
-        assertEquals(1, data.size());
-        Map<String, Object> row = data.get(0);
-        return row;
-    }
-
-    /**
-     * Inserts one Artist
-     * 
-     * @return Inserted Artist as a DataRow
-     */
-    private Map<String, Object> insertArtist() throws Exception {
-        Map<String, Object> parameters = new HashMap<String, Object>();
-        parameters.put("id", new Integer(1));
-        parameters.put("name", "ArtistToTestResult");
-        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
-                + "VALUES (#bind($id), #bind($name), #bind($dob))";
-
-        SQLTemplate template = new SQLTemplate(Object.class, templateString);
-
-        template.setParameters(parameters);
-
-        DataNode node = new DataNode();
-        node.setEntityResolver(runtime.getDataDomain().getEntityResolver());
-        node.setRowReaderFactory(mock(RowReaderFactory.class));
-        node.setAdapter(dbAdapter);
-        
-        SQLTemplateAction action = new SQLTemplateAction(template, node);
-
-        Connection c = runtime
-                .getDataDomain()
-                .getDataNodes()
-                .iterator()
-                .next()
-                .getDataSource()
-                .getConnection();
-        try {
-            MockOperationObserver observer = new MockOperationObserver();
-            action.performAction(c, observer);
-
-            int[] batches = observer.countsForQuery(template);
-            assertNotNull(batches);
-            assertEquals(1, batches.length);
-            assertEquals(1, batches[0]);
-        }
-        finally {
-            c.close();
-        }
-
-        MockOperationObserver observer = new MockOperationObserver();
-        SelectQuery query = new SelectQuery(Artist.class);
-        runtime
-                .getDataDomain()
-                .performQueries(Collections.singletonList(query), observer);
-
-        List<?> data = observer.rowsForQuery(query);
-        assertEquals(1, data.size());
-        DataRow row = (DataRow) data.get(0);
-        return row;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionIT.java
new file mode 100644
index 0000000..ab1b1c9
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionIT.java
@@ -0,0 +1,365 @@
+/*****************************************************************
+ *   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.jdbc;
+
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.MockOperationObserver;
+import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.Query;
+import org.apache.cayenne.query.SQLAction;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.query.SortOrder;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+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 org.apache.cayenne.unit.util.SQLTemplateCustomizer;
+
+import java.sql.Connection;
+import java.sql.Date;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class SQLTemplateActionIT extends ServerCase {
+
+    @Inject
+    protected ServerCaseDataSourceFactory dataSourceFactory;
+
+    @Inject
+    protected DataNode node;
+
+    @Inject
+    protected JdbcAdapter adapter;
+
+    @Inject
+    protected ObjectContext objectContext;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    @Inject
+    protected SQLTemplateCustomizer sqlTemplateCustomizer;
+
+    protected TableHelper tArtist;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME", "DATE_OF_BIRTH");
+    }
+
+    protected void createFourArtists() throws Exception {
+
+        Date date = new Date(System.currentTimeMillis());
+
+        tArtist.insert(11, "artist2", date);
+        tArtist.insert(101, "artist3", date);
+        tArtist.insert(201, "artist4", date);
+        tArtist.insert(3001, "artist5", date);
+    }
+
+    public void testProperties() throws Exception {
+        SQLTemplate template = new SQLTemplate(Object.class, "AAAAA");      
+  
+        SQLTemplateAction action = new SQLTemplateAction(template, node);
+        assertSame(template, action.getQuery());
+        assertSame(node, action.dataNode);
+    }
+
+    public void testExecuteSelect() throws Exception {
+        createFourArtists();
+
+        String templateString = "SELECT * FROM ARTIST WHERE ARTIST_ID = #bind($id)";
+        SQLTemplate template = new SQLTemplate(Object.class, templateString);
+        sqlTemplateCustomizer.updateSQLTemplate(template);
+
+        Map<String, Object> bindings = new HashMap<String, Object>();
+        bindings.put("id", 201l);
+        template.setParameters(bindings);
+
+        // must ensure the right SQLTemplateAction is created
+
+        SQLAction plan = adapter.getAction(template, node);
+        assertTrue(plan instanceof SQLTemplateAction);
+
+        MockOperationObserver observer = new MockOperationObserver();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
+
+        try {
+            plan.performAction(c, observer);
+        }
+        finally {
+            c.close();
+        }
+
+        List<DataRow> rows = observer.rowsForQuery(template);
+        assertNotNull(rows);
+        assertEquals(1, rows.size());
+        DataRow row = rows.get(0);
+
+        // In the absence of ObjEntity most DB's return a Long here, except for Oracle
+        // that has no BIGINT type and
+        // returns BigDecimal, so do a Number comparison
+        Number id = (Number) row.get("ARTIST_ID");
+        assertNotNull(id);
+        assertEquals(((Number) bindings.get("id")).longValue(), id.longValue());
+        assertEquals("artist4", row.get("ARTIST_NAME"));
+        assertTrue(row.containsKey("DATE_OF_BIRTH"));
+    }
+
+    public void testSelectUtilDate() throws Exception {
+        createFourArtists();
+
+        String templateString = "SELECT #result('DATE_OF_BIRTH' 'java.util.Date' 'DOB') "
+                + "FROM ARTIST WHERE ARTIST_ID = #bind($id)";
+        SQLTemplate template = new SQLTemplate(Object.class, templateString);
+        sqlTemplateCustomizer.updateSQLTemplate(template);
+
+        Map<String, Object> bindings = new HashMap<String, Object>();
+        bindings.put("id", 101);
+        template.setParameters(bindings);
+
+        SQLAction plan = adapter.getAction(template, node);
+
+        MockOperationObserver observer = new MockOperationObserver();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
+
+        try {
+            plan.performAction(c, observer);
+        }
+        finally {
+            c.close();
+        }
+
+        List<DataRow> rows = observer.rowsForQuery(template);
+        assertNotNull(rows);
+        assertEquals(1, rows.size());
+        DataRow row = rows.get(0);
+
+        assertNotNull(row.get("DOB"));
+        assertEquals(java.util.Date.class, row.get("DOB").getClass());
+    }
+
+    public void testSelectSQLDate() throws Exception {
+        createFourArtists();
+
+        String templateString = "SELECT #result('DATE_OF_BIRTH' 'java.sql.Date' 'DOB') "
+                + "FROM ARTIST WHERE ARTIST_ID = #bind($id)";
+        SQLTemplate template = new SQLTemplate(Object.class, templateString);
+        sqlTemplateCustomizer.updateSQLTemplate(template);
+
+        Map<String, Object> bindings = new HashMap<String, Object>();
+        bindings.put("id", 101);
+        template.setParameters(bindings);
+
+        SQLAction plan = adapter.getAction(template, node);
+
+        MockOperationObserver observer = new MockOperationObserver();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
+
+        try {
+            plan.performAction(c, observer);
+        }
+        finally {
+            c.close();
+        }
+
+        List<DataRow> rows = observer.rowsForQuery(template);
+        assertNotNull(rows);
+        assertEquals(1, rows.size());
+        DataRow row = rows.get(0);
+
+        assertNotNull(row.get("DOB"));
+        assertEquals(java.sql.Date.class, row.get("DOB").getClass());
+    }
+
+    public void testSelectSQLTimestamp() throws Exception {
+        createFourArtists();
+
+        String templateString = "SELECT #result('DATE_OF_BIRTH' 'java.sql.Timestamp' 'DOB') "
+                + "FROM ARTIST WHERE ARTIST_ID = #bind($id)";
+        SQLTemplate template = new SQLTemplate(Object.class, templateString);
+        sqlTemplateCustomizer.updateSQLTemplate(template);
+
+        Map<String, Object> bindings = new HashMap<String, Object>();
+        bindings.put("id", 201);
+        template.setParameters(bindings);
+
+        SQLAction plan = adapter.getAction(template, node);
+
+        MockOperationObserver observer = new MockOperationObserver();
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
+
+        try {
+            plan.performAction(c, observer);
+        }
+        finally {
+            c.close();
+        }
+
+        List<DataRow> rows = observer.rowsForQuery(template);
+        assertNotNull(rows);
+        assertEquals(1, rows.size());
+        DataRow row = rows.get(0);
+
+        assertNotNull(row.get("DOB"));
+        // Sybase returns a Timestamp subclass... so can't test equality
+        assertTrue(java.sql.Timestamp.class.isAssignableFrom(row.get("DOB").getClass()));
+    }
+
+    public void testExecuteUpdate() throws Exception {
+        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
+                + "VALUES (#bind($id), #bind($name), #bind($dob 'DATE'))";
+        SQLTemplate template = new SQLTemplate(Object.class, templateString);
+
+        Map<String, Object> bindings = new HashMap<String, Object>();
+        bindings.put("id", new Long(1));
+        bindings.put("name", "a1");
+        bindings.put("dob", new Date(System.currentTimeMillis()));
+        template.setParameters(bindings);
+
+        SQLAction action = adapter.getAction(template, node);
+
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
+        try {
+            MockOperationObserver observer = new MockOperationObserver();
+            action.performAction(c, observer);
+
+            int[] batches = observer.countsForQuery(template);
+            assertNotNull(batches);
+            assertEquals(1, batches.length);
+            assertEquals(1, batches[0]);
+        }
+        finally {
+            c.close();
+        }
+
+        assertEquals(1, tArtist.getRowCount());
+        assertEquals(1l, tArtist.getLong("ARTIST_ID"));
+        assertEquals("a1", tArtist.getString("ARTIST_NAME").trim());
+    }
+
+    public void testExecuteUpdateNoParameters() throws Exception {
+        createFourArtists();
+
+        SQLTemplate template = new SQLTemplate(
+                Object.class,
+                "delete from ARTIST where ARTIST_NAME like 'a%'");
+
+        SQLAction action = adapter.getAction(template, node);
+
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
+        try {
+            MockOperationObserver observer = new MockOperationObserver();
+            action.performAction(c, observer);
+
+            int[] batches = observer.countsForQuery(template);
+            assertNotNull(batches);
+            assertEquals(1, batches.length);
+            assertEquals(4, batches[0]);
+        }
+        finally {
+            c.close();
+        }
+    }
+
+    public void testExecuteUpdateBatch() throws Exception {
+        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
+                + "VALUES (#bind($id), #bind($name), #bind($dob 'DATE'))";
+        SQLTemplate template = new SQLTemplate(Object.class, templateString);
+
+        Map<String, Object> bindings1 = new HashMap<String, Object>();
+        bindings1.put("id", new Long(1));
+        bindings1.put("name", "a1");
+        bindings1.put("dob", new Date(System.currentTimeMillis()));
+
+        Map<String, Object> bindings2 = new HashMap<String, Object>();
+        bindings2.put("id", new Long(33));
+        bindings2.put("name", "a$$$$$");
+        bindings2.put("dob", new Date(System.currentTimeMillis()));
+        template.setParameters(new Map[] {
+                bindings1, bindings2
+        });
+
+        SQLAction genericAction = adapter.getAction(template, node);
+        assertTrue(genericAction instanceof SQLTemplateAction);
+        SQLTemplateAction action = (SQLTemplateAction) genericAction;
+
+        assertSame(node, action.dataNode);
+        assertSame(template, action.getQuery());
+
+        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
+        try {
+            MockOperationObserver observer = new MockOperationObserver();
+            action.performAction(c, observer);
+
+            int[] batches = observer.countsForQuery(template);
+            assertNotNull(batches);
+            assertEquals(2, batches.length);
+            assertEquals(1, batches[0]);
+            assertEquals(1, batches[1]);
+        }
+        finally {
+            c.close();
+        }
+
+        MockOperationObserver observer = new MockOperationObserver();
+        SelectQuery query = new SelectQuery(Artist.class);
+        query.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
+        node.performQueries(Collections.singletonList((Query) query), observer);
+
+        List<DataRow> data = observer.rowsForQuery(query);
+        assertEquals(2, data.size());
+        DataRow row1 = data.get(0);
+        assertEquals(bindings1.get("id"), row1.get("ARTIST_ID"));
+        assertEquals(bindings1.get("name"), row1.get("ARTIST_NAME"));
+        // to compare dates we need to create the binding correctly
+        // assertEquals(bindings1.get("dob"), row.get("DATE_OF_BIRTH"));
+
+        DataRow row2 = data.get(1);
+        assertEquals(bindings2.get("id"), row2.get("ARTIST_ID"));
+        assertEquals(bindings2.get("name"), row2.get("ARTIST_NAME"));
+        // to compare dates we need to create the binding correctly
+        // assertEquals(bindings2.get("dob"), row2.get("DATE_OF_BIRTH"));
+    }
+
+    public void testExtractTemplateString() throws Exception {
+        SQLTemplate template = new SQLTemplate(Artist.class, "A\nBC");
+        SQLTemplateAction action = new SQLTemplateAction(template, node);
+
+        assertEquals("A BC", action.extractTemplateString());
+    }
+
+}


Mime
View raw message