You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2014/11/02 08:10:30 UTC

[42/48] Installing Maven Failsafe Plugin

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/OneWayRelationshipsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/OneWayRelationshipsTest.java b/cayenne-server/src/test/java/org/apache/cayenne/OneWayRelationshipsTest.java
deleted file mode 100644
index dadcc1d..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/OneWayRelationshipsTest.java
+++ /dev/null
@@ -1,217 +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;
-
-import java.sql.SQLException;
-import java.util.List;
-
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.SQLSelect;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.oneway.OnewayTable1;
-import org.apache.cayenne.testdo.oneway.OnewayTable2;
-import org.apache.cayenne.testdo.oneway.OnewayTable3;
-import org.apache.cayenne.testdo.oneway.OnewayTable4;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.ONEWAY_PROJECT)
-public class OneWayRelationshipsTest extends ServerCase {
-
-    @Inject
-    private ObjectContext context;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    private TableHelper t1Helper;
-    private TableHelper t2Helper;
-    private TableHelper t3Helper;
-    private TableHelper t4Helper;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-
-        dbHelper.deleteAll("oneway_table2");
-        dbHelper.deleteAll("oneway_table1");
-        dbHelper.deleteAll("oneway_table4");
-        dbHelper.deleteAll("oneway_table3");
-
-        t1Helper = new TableHelper(dbHelper, "oneway_table1");
-        t1Helper.setColumns("ID");
-        t2Helper = new TableHelper(dbHelper, "oneway_table2");
-        t2Helper.setColumns("ID", "TABLE1_ID");
-
-        t3Helper = new TableHelper(dbHelper, "oneway_table3");
-        t3Helper.setColumns("ID");
-        t4Helper = new TableHelper(dbHelper, "oneway_table4");
-        t4Helper.setColumns("ID", "TABLE3_ID");
-    }
-
-    public void testToOne_TwoNew() throws SQLException {
-
-        OnewayTable1 t1 = context.newObject(OnewayTable1.class);
-        OnewayTable2 t2 = context.newObject(OnewayTable2.class);
-        t2.setToOneOneWayDb(t1);
-
-        context.commitChanges();
-
-        int t1Pk = t1Helper.getInt("ID");
-        assertEquals(Cayenne.intPKForObject(t1), t1Pk);
-        int t2FK = t2Helper.getInt("TABLE1_ID");
-        assertEquals(t1Pk, t2FK);
-    }
-
-    public void testToOne_Replace() throws SQLException {
-
-        t1Helper.insert(1).insert(2);
-        t2Helper.insert(1, 1);
-
-        OnewayTable1 t11 = Cayenne.objectForPK(context, OnewayTable1.class, 1);
-        OnewayTable1 t12 = Cayenne.objectForPK(context, OnewayTable1.class, 2);
-        OnewayTable2 t2 = Cayenne.objectForPK(context, OnewayTable2.class, 1);
-
-        assertSame(t11, t2.getToOneOneWayDb());
-
-        t2.setToOneOneWayDb(t12);
-        context.commitChanges();
-
-        assertSame(t12, t2.getToOneOneWayDb());
-
-        int t2FK = t2Helper.getInt("TABLE1_ID");
-        assertEquals(2, t2FK);
-    }
-
-    public void testToOne_ReplaceWithNull() throws SQLException {
-
-        t1Helper.insert(1);
-        t2Helper.insert(1, 1);
-
-        OnewayTable1 t11 = Cayenne.objectForPK(context, OnewayTable1.class, 1);
-        OnewayTable2 t2 = Cayenne.objectForPK(context, OnewayTable2.class, 1);
-
-        assertSame(t11, t2.getToOneOneWayDb());
-
-        t2.setToOneOneWayDb(null);
-        context.commitChanges();
-
-        assertNull(t2.getToOneOneWayDb());
-
-        Object t2FK = t2Helper.getObject("TABLE1_ID");
-        assertNull(t2FK);
-    }
-
-    public void testToMany_TwoNew() throws SQLException {
-
-        OnewayTable3 t3 = context.newObject(OnewayTable3.class);
-        OnewayTable4 t4 = context.newObject(OnewayTable4.class);
-        t3.addToToManyOneWayDb(t4);
-
-        context.commitChanges();
-
-        int t3Pk = t3Helper.getInt("ID");
-        assertEquals(Cayenne.intPKForObject(t3), t3Pk);
-        int t4FK = t4Helper.getInt("TABLE3_ID");
-        assertEquals(t3Pk, t4FK);
-    }
-
-    public void testToMany_AddNew() throws SQLException {
-
-        t3Helper.insert(1);
-        t4Helper.insert(1, 1);
-
-        OnewayTable3 t3 = Cayenne.objectForPK(context, OnewayTable3.class, 1);
-        assertEquals(1, t3.getToManyOneWayDb().size());
-
-        OnewayTable4 t41 = Cayenne.objectForPK(context, OnewayTable4.class, 1);
-        assertTrue(t3.getToManyOneWayDb().contains(t41));
-
-        OnewayTable4 t42 = context.newObject(OnewayTable4.class);
-        t3.addToToManyOneWayDb(t42);
-        context.commitChanges();
-
-        assertEquals(2, t3.getToManyOneWayDb().size());
-
-        SQLSelect<Integer> fksQuery = SQLSelect.scalarQuery(Integer.class, "oneway-rels",
-                "SELECT TABLE3_ID FROM oneway_table4");
-
-        List<Integer> fks = context.select(fksQuery);
-        assertEquals(2, fks.size());
-        for (Integer fk : fks) {
-            assertEquals(Integer.valueOf(1), fk);
-        }
-    }
-
-    public void testToMany_AddExisting() throws SQLException {
-
-        t3Helper.insert(1);
-        t4Helper.insert(1, 1).insert(2, null);
-
-        OnewayTable3 t3 = Cayenne.objectForPK(context, OnewayTable3.class, 1);
-        assertEquals(1, t3.getToManyOneWayDb().size());
-
-        OnewayTable4 t41 = Cayenne.objectForPK(context, OnewayTable4.class, 1);
-        assertTrue(t3.getToManyOneWayDb().contains(t41));
-
-        OnewayTable4 t42 = Cayenne.objectForPK(context, OnewayTable4.class, 2);
-
-        t3.addToToManyOneWayDb(t42);
-        context.commitChanges();
-
-        assertEquals(2, t3.getToManyOneWayDb().size());
-
-        SQLSelect<Integer> fksQuery = SQLSelect.scalarQuery(Integer.class, "oneway-rels",
-                "SELECT TABLE3_ID FROM oneway_table4");
-
-        List<Integer> fks = context.select(fksQuery);
-        assertEquals(2, fks.size());
-        for (Integer fk : fks) {
-            assertEquals(Integer.valueOf(1), fk);
-        }
-    }
-
-    public void testToMany_RemoveExisting() throws SQLException {
-
-        t3Helper.insert(1);
-        t4Helper.insert(1, 1).insert(2, 1);
-
-        OnewayTable3 t3 = Cayenne.objectForPK(context, OnewayTable3.class, 1);
-        assertEquals(2, t3.getToManyOneWayDb().size());
-
-        OnewayTable4 t41 = Cayenne.objectForPK(context, OnewayTable4.class, 1);
-        assertTrue(t3.getToManyOneWayDb().contains(t41));
-
-        OnewayTable4 t42 = Cayenne.objectForPK(context, OnewayTable4.class, 2);
-        assertTrue(t3.getToManyOneWayDb().contains(t42));
-
-        t3.removeFromToManyOneWayDb(t42);
-        context.commitChanges();
-
-        assertEquals(1, t3.getToManyOneWayDb().size());
-
-        SQLSelect<Integer> fksQuery = SQLSelect.scalarQuery(Integer.class, "oneway-rels",
-                "SELECT TABLE3_ID FROM oneway_table4");
-
-        List<Integer> fks = context.select(fksQuery);
-        assertEquals(2, fks.size());
-        assertTrue(fks.contains(1));
-        assertTrue(fks.contains(null));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/PersistenceByReachabilityIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/PersistenceByReachabilityIT.java b/cayenne-server/src/test/java/org/apache/cayenne/PersistenceByReachabilityIT.java
new file mode 100644
index 0000000..9139841
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/PersistenceByReachabilityIT.java
@@ -0,0 +1,103 @@
+/*****************************************************************
+ *   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;
+
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.Painting;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class PersistenceByReachabilityIT extends ServerCase {
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private ObjectContext context1;
+
+    public void testToOneTargetTransient() throws Exception {
+        Painting persistentDO = context.newObject(Painting.class);
+
+        Artist transientDO = new Artist();
+        persistentDO.setToOneTarget(Painting.TO_ARTIST_PROPERTY, transientDO, false);
+
+        assertEquals(PersistenceState.NEW, transientDO.getPersistenceState());
+    }
+
+    public void testToOneTargetPersistent() throws Exception {
+        Painting transientDO = context.newObject(Painting.class);
+
+        Artist persistentDO = new Artist();
+        transientDO.setToOneTarget(Painting.TO_ARTIST_PROPERTY, persistentDO, false);
+
+        assertEquals(PersistenceState.NEW, transientDO.getPersistenceState());
+    }
+
+    public void testToOneTargetDifferentContext() throws Exception {
+
+        Painting doC1 = context.newObject(Painting.class);
+        Artist doC2 = context1.newObject(Artist.class);
+
+        // this is the case where exception must be thrown as DataContexts are
+        // different
+        try {
+            doC1.setToOneTarget(Painting.TO_ARTIST_PROPERTY, doC2, false);
+            fail("failed to detect relationship between objects in different DataContexts");
+        }
+        catch (CayenneRuntimeException ex) {
+            // expected
+        }
+    }
+
+    public void testToManyTargetDifferentContext() throws Exception {
+        Painting doC1 = context.newObject(Painting.class);
+        Artist doC2 = context1.newObject(Artist.class);
+
+        // this is the case where exception must be thrown as DataContexts are
+        // different
+        try {
+            doC2.addToManyTarget(Artist.PAINTING_ARRAY_PROPERTY, doC1, false);
+            fail("failed to detect relationship between objects in different DataContexts");
+        }
+        catch (CayenneRuntimeException ex) {
+
+        }
+    }
+
+    public void testToManyTargetTransient() throws Exception {
+        Painting transientDO = context.newObject(Painting.class);
+
+        Artist persistentDO = new Artist();
+        persistentDO.addToManyTarget(Artist.PAINTING_ARRAY_PROPERTY, transientDO, false);
+
+        assertEquals(PersistenceState.NEW, transientDO.getPersistenceState());
+    }
+
+    public void testToManyTargetPersistent() throws Exception {
+        Painting persistentDO = context.newObject(Painting.class);
+
+        Artist transientDO = new Artist();
+        transientDO.addToManyTarget(Artist.PAINTING_ARRAY_PROPERTY, persistentDO, false);
+
+        assertEquals(PersistenceState.NEW, transientDO.getPersistenceState());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/PersistenceByReachabilityTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/PersistenceByReachabilityTest.java b/cayenne-server/src/test/java/org/apache/cayenne/PersistenceByReachabilityTest.java
deleted file mode 100644
index 9653a53..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/PersistenceByReachabilityTest.java
+++ /dev/null
@@ -1,103 +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;
-
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.testdo.testmap.Painting;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class PersistenceByReachabilityTest extends ServerCase {
-
-    @Inject
-    private ObjectContext context;
-
-    @Inject
-    private ObjectContext context1;
-
-    public void testToOneTargetTransient() throws Exception {
-        Painting persistentDO = context.newObject(Painting.class);
-
-        Artist transientDO = new Artist();
-        persistentDO.setToOneTarget(Painting.TO_ARTIST_PROPERTY, transientDO, false);
-
-        assertEquals(PersistenceState.NEW, transientDO.getPersistenceState());
-    }
-
-    public void testToOneTargetPersistent() throws Exception {
-        Painting transientDO = context.newObject(Painting.class);
-
-        Artist persistentDO = new Artist();
-        transientDO.setToOneTarget(Painting.TO_ARTIST_PROPERTY, persistentDO, false);
-
-        assertEquals(PersistenceState.NEW, transientDO.getPersistenceState());
-    }
-
-    public void testToOneTargetDifferentContext() throws Exception {
-
-        Painting doC1 = context.newObject(Painting.class);
-        Artist doC2 = context1.newObject(Artist.class);
-
-        // this is the case where exception must be thrown as DataContexts are
-        // different
-        try {
-            doC1.setToOneTarget(Painting.TO_ARTIST_PROPERTY, doC2, false);
-            fail("failed to detect relationship between objects in different DataContexts");
-        }
-        catch (CayenneRuntimeException ex) {
-            // expected
-        }
-    }
-
-    public void testToManyTargetDifferentContext() throws Exception {
-        Painting doC1 = context.newObject(Painting.class);
-        Artist doC2 = context1.newObject(Artist.class);
-
-        // this is the case where exception must be thrown as DataContexts are
-        // different
-        try {
-            doC2.addToManyTarget(Artist.PAINTING_ARRAY_PROPERTY, doC1, false);
-            fail("failed to detect relationship between objects in different DataContexts");
-        }
-        catch (CayenneRuntimeException ex) {
-
-        }
-    }
-
-    public void testToManyTargetTransient() throws Exception {
-        Painting transientDO = context.newObject(Painting.class);
-
-        Artist persistentDO = new Artist();
-        persistentDO.addToManyTarget(Artist.PAINTING_ARRAY_PROPERTY, transientDO, false);
-
-        assertEquals(PersistenceState.NEW, transientDO.getPersistenceState());
-    }
-
-    public void testToManyTargetPersistent() throws Exception {
-        Painting persistentDO = context.newObject(Painting.class);
-
-        Artist transientDO = new Artist();
-        transientDO.addToManyTarget(Artist.PAINTING_ARRAY_PROPERTY, persistentDO, false);
-
-        assertEquals(PersistenceState.NEW, transientDO.getPersistenceState());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/PersistentObjectIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/PersistentObjectIT.java b/cayenne-server/src/test/java/org/apache/cayenne/PersistentObjectIT.java
new file mode 100644
index 0000000..1defd66
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/PersistentObjectIT.java
@@ -0,0 +1,56 @@
+/*****************************************************************
+ *   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;
+
+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 PersistentObjectIT extends ServerCase {
+
+    public void testObjectContext() {
+        ObjectContext context = mock(ObjectContext.class);
+        PersistentObject object = new MockPersistentObject();
+
+        assertNull(object.getObjectContext());
+        object.setObjectContext(context);
+        assertSame(context, object.getObjectContext());
+    }
+
+    public void testPersistenceState() {
+        PersistentObject object = new MockPersistentObject();
+        assertEquals(PersistenceState.TRANSIENT, object.getPersistenceState());
+        object.setPersistenceState(PersistenceState.DELETED);
+        assertEquals(PersistenceState.DELETED, object.getPersistenceState());
+    }
+
+    public void testObjectID() {
+        ObjectId id = new ObjectId("test");
+
+        PersistentObject object = new MockPersistentObject();
+
+        assertNull(object.getObjectId());
+        object.setObjectId(id);
+        assertSame(id, object.getObjectId());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/PersistentObjectTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/PersistentObjectTest.java b/cayenne-server/src/test/java/org/apache/cayenne/PersistentObjectTest.java
deleted file mode 100644
index ac42a6a..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/PersistentObjectTest.java
+++ /dev/null
@@ -1,56 +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;
-
-import static org.mockito.Mockito.mock;
-
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class PersistentObjectTest extends ServerCase {
-
-    public void testObjectContext() {
-        ObjectContext context = mock(ObjectContext.class);
-        PersistentObject object = new MockPersistentObject();
-
-        assertNull(object.getObjectContext());
-        object.setObjectContext(context);
-        assertSame(context, object.getObjectContext());
-    }
-
-    public void testPersistenceState() {
-        PersistentObject object = new MockPersistentObject();
-        assertEquals(PersistenceState.TRANSIENT, object.getPersistenceState());
-        object.setPersistenceState(PersistenceState.DELETED);
-        assertEquals(PersistenceState.DELETED, object.getPersistenceState());
-    }
-
-    public void testObjectID() {
-        ObjectId id = new ObjectId("test");
-
-        PersistentObject object = new MockPersistentObject();
-
-        assertNull(object.getObjectId());
-        object.setObjectId(id);
-        assertSame(id, object.getObjectId());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/PregeneratedPKIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/PregeneratedPKIT.java b/cayenne-server/src/test/java/org/apache/cayenne/PregeneratedPKIT.java
new file mode 100644
index 0000000..d8d71b8
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/PregeneratedPKIT.java
@@ -0,0 +1,85 @@
+/*****************************************************************
+ *   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;
+
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.map.DbEntity;
+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;
+
+/**
+ * This test case ensures that PK pre-generated for the entity manually before commit is
+ * used during commit as well.
+ */
+// TODO: 1/16/2006 - the algorithm used to generate the PK may be included in
+// DataObjectUtils to pull the PK on demand. A caveat - we need to analyze DataObject in
+// question to see if a PK is numeric and not propagated.
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class PregeneratedPKIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+        dbHelper.deleteAll("EXHIBIT");
+        dbHelper.deleteAll("GALLERY");
+    }
+
+    public void testLongPk() throws Exception {
+        Artist a = context.newObject(Artist.class);
+        a.setArtistName("XXX");
+
+        updateId(context, a.getObjectId());
+
+        Object pk = a.getObjectId().getReplacementIdMap().get(Artist.ARTIST_ID_PK_COLUMN);
+        assertNotNull(pk);
+
+        assertEquals(pk, Cayenne.longPKForObject(a));
+
+        context.commitChanges();
+
+        Object pkAfterCommit = a.getObjectId().getIdSnapshot().get(
+                Artist.ARTIST_ID_PK_COLUMN);
+        assertEquals(pk, pkAfterCommit);
+    }
+
+    void updateId(DataContext context, ObjectId id) throws Exception {
+        DbEntity entity = context.getEntityResolver().getDbEntity("ARTIST");
+        DataNode node = context.getParentDataDomain().lookupDataNode(entity.getDataMap());
+
+        Object pk = node.getAdapter().getPkGenerator().generatePk(
+                node,
+                entity.getPrimaryKeys().iterator().next());
+        id.getReplacementIdMap().put(Artist.ARTIST_ID_PK_COLUMN, pk);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/PregeneratedPKTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/PregeneratedPKTest.java b/cayenne-server/src/test/java/org/apache/cayenne/PregeneratedPKTest.java
deleted file mode 100644
index c508db4..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/PregeneratedPKTest.java
+++ /dev/null
@@ -1,85 +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;
-
-import org.apache.cayenne.access.DataContext;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.DbEntity;
-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;
-
-/**
- * This test case ensures that PK pre-generated for the entity manually before commit is
- * used during commit as well.
- */
-// TODO: 1/16/2006 - the algorithm used to generate the PK may be included in
-// DataObjectUtils to pull the PK on demand. A caveat - we need to analyze DataObject in
-// question to see if a PK is numeric and not propagated.
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class PregeneratedPKTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("PAINTING_INFO");
-        dbHelper.deleteAll("PAINTING");
-        dbHelper.deleteAll("ARTIST_EXHIBIT");
-        dbHelper.deleteAll("ARTIST_GROUP");
-        dbHelper.deleteAll("ARTIST");
-        dbHelper.deleteAll("EXHIBIT");
-        dbHelper.deleteAll("GALLERY");
-    }
-
-    public void testLongPk() throws Exception {
-        Artist a = context.newObject(Artist.class);
-        a.setArtistName("XXX");
-
-        updateId(context, a.getObjectId());
-
-        Object pk = a.getObjectId().getReplacementIdMap().get(Artist.ARTIST_ID_PK_COLUMN);
-        assertNotNull(pk);
-
-        assertEquals(pk, Cayenne.longPKForObject(a));
-
-        context.commitChanges();
-
-        Object pkAfterCommit = a.getObjectId().getIdSnapshot().get(
-                Artist.ARTIST_ID_PK_COLUMN);
-        assertEquals(pk, pkAfterCommit);
-    }
-
-    void updateId(DataContext context, ObjectId id) throws Exception {
-        DbEntity entity = context.getEntityResolver().getDbEntity("ARTIST");
-        DataNode node = context.getParentDataDomain().lookupDataNode(entity.getDataMap());
-
-        Object pk = node.getAdapter().getPkGenerator().generatePk(
-                node,
-                entity.getPrimaryKeys().iterator().next());
-        id.getReplacementIdMap().put(Artist.ARTIST_ID_PK_COLUMN, pk);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBinaryPKIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBinaryPKIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBinaryPKIT.java
new file mode 100644
index 0000000..3432c76
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBinaryPKIT.java
@@ -0,0 +1,95 @@
+/*****************************************************************
+ *   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;
+
+import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.BinaryPKTest1;
+import org.apache.cayenne.testdo.testmap.BinaryPKTest2;
+import org.apache.cayenne.unit.UnitDbAdapter;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextBinaryPKIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DataContext context1;
+
+    @Inject
+    private UnitDbAdapter accessStackAdapter;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        if (accessStackAdapter.supportsBinaryPK()) {
+            dbHelper.deleteAll("BINARY_PK_TEST2");
+            dbHelper.deleteAll("BINARY_PK_TEST1");
+        }
+    }
+
+    public void testInsertBinaryPK() throws Exception {
+        if (accessStackAdapter.supportsBinaryPK()) {
+
+            BinaryPKTest1 master = (BinaryPKTest1) context.newObject("BinaryPKTest1");
+            master.setName("master1");
+
+            BinaryPKTest2 detail = (BinaryPKTest2) context.newObject("BinaryPKTest2");
+            detail.setDetailName("detail2");
+
+            master.addToBinaryPKDetails(detail);
+
+            context.commitChanges();
+        }
+    }
+
+    public void testFetchRelationshipBinaryPK() throws Exception {
+        if (accessStackAdapter.supportsBinaryPK()) {
+
+            BinaryPKTest1 master = (BinaryPKTest1) context.newObject("BinaryPKTest1");
+            master.setName("master1");
+
+            BinaryPKTest2 detail = (BinaryPKTest2) context.newObject("BinaryPKTest2");
+            detail.setDetailName("detail2");
+
+            master.addToBinaryPKDetails(detail);
+
+            context.commitChanges();
+            context.invalidateObjects(master, detail);
+
+            BinaryPKTest2 fetchedDetail = (BinaryPKTest2) context1.performQuery(
+                    new SelectQuery(BinaryPKTest2.class)).get(0);
+
+            assertNotNull(fetchedDetail.readPropertyDirectly("toBinaryPKMaster"));
+
+            BinaryPKTest1 fetchedMaster = fetchedDetail.getToBinaryPKMaster();
+            assertNotNull(fetchedMaster);
+            assertEquals(PersistenceState.HOLLOW, fetchedMaster.getPersistenceState());
+            assertEquals("master1", fetchedMaster.getName());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBinaryPKTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBinaryPKTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBinaryPKTest.java
deleted file mode 100644
index cabf623..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBinaryPKTest.java
+++ /dev/null
@@ -1,95 +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;
-
-import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.BinaryPKTest1;
-import org.apache.cayenne.testdo.testmap.BinaryPKTest2;
-import org.apache.cayenne.unit.UnitDbAdapter;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextBinaryPKTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private DataContext context1;
-
-    @Inject
-    private UnitDbAdapter accessStackAdapter;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        if (accessStackAdapter.supportsBinaryPK()) {
-            dbHelper.deleteAll("BINARY_PK_TEST2");
-            dbHelper.deleteAll("BINARY_PK_TEST1");
-        }
-    }
-
-    public void testInsertBinaryPK() throws Exception {
-        if (accessStackAdapter.supportsBinaryPK()) {
-
-            BinaryPKTest1 master = (BinaryPKTest1) context.newObject("BinaryPKTest1");
-            master.setName("master1");
-
-            BinaryPKTest2 detail = (BinaryPKTest2) context.newObject("BinaryPKTest2");
-            detail.setDetailName("detail2");
-
-            master.addToBinaryPKDetails(detail);
-
-            context.commitChanges();
-        }
-    }
-
-    public void testFetchRelationshipBinaryPK() throws Exception {
-        if (accessStackAdapter.supportsBinaryPK()) {
-
-            BinaryPKTest1 master = (BinaryPKTest1) context.newObject("BinaryPKTest1");
-            master.setName("master1");
-
-            BinaryPKTest2 detail = (BinaryPKTest2) context.newObject("BinaryPKTest2");
-            detail.setDetailName("detail2");
-
-            master.addToBinaryPKDetails(detail);
-
-            context.commitChanges();
-            context.invalidateObjects(master, detail);
-
-            BinaryPKTest2 fetchedDetail = (BinaryPKTest2) context1.performQuery(
-                    new SelectQuery(BinaryPKTest2.class)).get(0);
-
-            assertNotNull(fetchedDetail.readPropertyDirectly("toBinaryPKMaster"));
-
-            BinaryPKTest1 fetchedMaster = fetchedDetail.getToBinaryPKMaster();
-            assertNotNull(fetchedMaster);
-            assertEquals(PersistenceState.HOLLOW, fetchedMaster.getPersistenceState());
-            assertEquals("master1", fetchedMaster.getName());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBlobIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBlobIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBlobIT.java
new file mode 100644
index 0000000..da19e51
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBlobIT.java
@@ -0,0 +1,189 @@
+/*****************************************************************
+ *   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;
+
+import org.apache.cayenne.access.types.ByteArrayTypeTest;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.BlobTestEntity;
+import org.apache.cayenne.unit.UnitDbAdapter;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.List;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextBlobIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DataContext context2;
+
+    @Inject
+    private DataContext context3;
+
+    @Inject
+    private UnitDbAdapter accessStackAdapter;
+    
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        if (accessStackAdapter.supportsLobs()) {
+            dbHelper.deleteAll("BLOB_TEST");
+        }
+    }
+
+    protected boolean skipTests() {
+        return !accessStackAdapter.supportsLobs();
+    }
+
+    protected boolean skipEmptyLOBTests() {
+        return !accessStackAdapter.handlesNullVsEmptyLOBs();
+    }
+    
+    public void testManyBlobsInOneTX() throws Exception {
+        if (skipTests()) {
+            return;
+        }
+
+        for (int i = 0; i < 3; i++) {
+            BlobTestEntity b = context.newObject(BlobTestEntity.class);
+
+            byte[] bytes = new byte[1024];
+            for (int j = 0; j < 1024; j++) {
+                bytes[j] = (byte) (65 + (50 + j) % 50);
+            }
+
+            b.setBlobCol(bytes);
+            context.commitChanges();
+        }
+
+        // read the CLOB in the new context
+        List<BlobTestEntity> objects2 = context2.select(new SelectQuery<BlobTestEntity>(BlobTestEntity.class));
+        assertEquals(3, objects2.size());
+    }
+
+    public void testEmptyBlob() throws Exception {
+        if (skipTests()) {
+            return;
+        }
+        if (skipEmptyLOBTests()) {
+            return;
+        }
+        runWithBlobSize(0);
+    }
+
+    public void test5ByteBlob() throws Exception {
+        if (skipTests()) {
+            return;
+        }
+        runWithBlobSize(5);
+    }
+
+    public void test5KByteBlob() throws Exception {
+        if (skipTests()) {
+            return;
+        }
+        runWithBlobSize(5 * 1024);
+    }
+
+    public void test1MBBlob() throws Exception {
+        if (skipTests()) {
+            return;
+        }
+        runWithBlobSize(1024 * 1024);
+    }
+
+    public void testNullBlob() throws Exception {
+        if (skipTests()) {
+            return;
+        }
+
+        byte[] bytes2 = new byte[] {
+                'a', 'b', 'c', 'd'
+        };
+
+        // insert new blob
+        context.newObject(BlobTestEntity.class);
+        context.commitChanges();
+
+        // read the BLOB in the new context
+
+        List<?> objects2 = context2.performQuery(new SelectQuery(BlobTestEntity.class));
+        assertEquals(1, objects2.size());
+
+        BlobTestEntity blobObj2 = (BlobTestEntity) objects2.get(0);
+        assertNull(blobObj2.getBlobCol());
+
+        // update and save Blob
+        blobObj2.setBlobCol(bytes2);
+        context2.commitChanges();
+
+        // read into yet another context and check for changes
+        List<?> objects3 = context3.performQuery(new SelectQuery(BlobTestEntity.class));
+        assertEquals(1, objects3.size());
+
+        BlobTestEntity blobObj3 = (BlobTestEntity) objects3.get(0);
+        ByteArrayTypeTest.assertByteArraysEqual(blobObj2.getBlobCol(), blobObj3
+                .getBlobCol());
+      
+    }
+
+    protected void runWithBlobSize(int sizeBytes) throws Exception {
+        // insert new clob
+        BlobTestEntity blobObj1 = context.newObject(BlobTestEntity.class);
+
+        // init BLOB of a specified size
+        byte[] bytes = new byte[sizeBytes];
+        for (int i = 0; i < sizeBytes; i++) {
+            bytes[i] = (byte) (65 + (50 + i) % 50);
+        }
+
+        blobObj1.setBlobCol(bytes);
+        context.commitChanges();
+
+        // read the CLOB in the new context
+        List<?> objects2 = context2.performQuery(new SelectQuery(BlobTestEntity.class));
+        assertEquals(1, objects2.size());
+
+        BlobTestEntity blobObj2 = (BlobTestEntity) objects2.get(0);
+        ByteArrayTypeTest.assertByteArraysEqual(blobObj1.getBlobCol(), blobObj2
+                .getBlobCol());
+
+        // update and save Blob
+        blobObj2.setBlobCol(new byte[] {
+                '1', '2'
+        });
+        context2.commitChanges();
+
+        // read into yet another context and check for changes
+        List<?> objects3 = context3.performQuery(new SelectQuery(BlobTestEntity.class));
+        assertEquals(1, objects3.size());
+
+        BlobTestEntity blobObj3 = (BlobTestEntity) objects3.get(0);
+        ByteArrayTypeTest.assertByteArraysEqual(blobObj2.getBlobCol(), blobObj3
+                .getBlobCol());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBlobTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBlobTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBlobTest.java
deleted file mode 100644
index f8f1344..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextBlobTest.java
+++ /dev/null
@@ -1,189 +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;
-
-import java.util.List;
-
-import org.apache.cayenne.access.types.ByteArrayTypeTest;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.BlobTestEntity;
-import org.apache.cayenne.unit.UnitDbAdapter;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextBlobTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private DataContext context2;
-
-    @Inject
-    private DataContext context3;
-
-    @Inject
-    private UnitDbAdapter accessStackAdapter;
-    
-    @Inject
-    private DBHelper dbHelper;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        if (accessStackAdapter.supportsLobs()) {
-            dbHelper.deleteAll("BLOB_TEST");
-        }
-    }
-
-    protected boolean skipTests() {
-        return !accessStackAdapter.supportsLobs();
-    }
-
-    protected boolean skipEmptyLOBTests() {
-        return !accessStackAdapter.handlesNullVsEmptyLOBs();
-    }
-    
-    public void testManyBlobsInOneTX() throws Exception {
-        if (skipTests()) {
-            return;
-        }
-
-        for (int i = 0; i < 3; i++) {
-            BlobTestEntity b = context.newObject(BlobTestEntity.class);
-
-            byte[] bytes = new byte[1024];
-            for (int j = 0; j < 1024; j++) {
-                bytes[j] = (byte) (65 + (50 + j) % 50);
-            }
-
-            b.setBlobCol(bytes);
-            context.commitChanges();
-        }
-
-        // read the CLOB in the new context
-        List<BlobTestEntity> objects2 = context2.select(new SelectQuery<BlobTestEntity>(BlobTestEntity.class));
-        assertEquals(3, objects2.size());
-    }
-
-    public void testEmptyBlob() throws Exception {
-        if (skipTests()) {
-            return;
-        }
-        if (skipEmptyLOBTests()) {
-            return;
-        }
-        runWithBlobSize(0);
-    }
-
-    public void test5ByteBlob() throws Exception {
-        if (skipTests()) {
-            return;
-        }
-        runWithBlobSize(5);
-    }
-
-    public void test5KByteBlob() throws Exception {
-        if (skipTests()) {
-            return;
-        }
-        runWithBlobSize(5 * 1024);
-    }
-
-    public void test1MBBlob() throws Exception {
-        if (skipTests()) {
-            return;
-        }
-        runWithBlobSize(1024 * 1024);
-    }
-
-    public void testNullBlob() throws Exception {
-        if (skipTests()) {
-            return;
-        }
-
-        byte[] bytes2 = new byte[] {
-                'a', 'b', 'c', 'd'
-        };
-
-        // insert new blob
-        context.newObject(BlobTestEntity.class);
-        context.commitChanges();
-
-        // read the BLOB in the new context
-
-        List<?> objects2 = context2.performQuery(new SelectQuery(BlobTestEntity.class));
-        assertEquals(1, objects2.size());
-
-        BlobTestEntity blobObj2 = (BlobTestEntity) objects2.get(0);
-        assertNull(blobObj2.getBlobCol());
-
-        // update and save Blob
-        blobObj2.setBlobCol(bytes2);
-        context2.commitChanges();
-
-        // read into yet another context and check for changes
-        List<?> objects3 = context3.performQuery(new SelectQuery(BlobTestEntity.class));
-        assertEquals(1, objects3.size());
-
-        BlobTestEntity blobObj3 = (BlobTestEntity) objects3.get(0);
-        ByteArrayTypeTest.assertByteArraysEqual(blobObj2.getBlobCol(), blobObj3
-                .getBlobCol());
-      
-    }
-
-    protected void runWithBlobSize(int sizeBytes) throws Exception {
-        // insert new clob
-        BlobTestEntity blobObj1 = context.newObject(BlobTestEntity.class);
-
-        // init BLOB of a specified size
-        byte[] bytes = new byte[sizeBytes];
-        for (int i = 0; i < sizeBytes; i++) {
-            bytes[i] = (byte) (65 + (50 + i) % 50);
-        }
-
-        blobObj1.setBlobCol(bytes);
-        context.commitChanges();
-
-        // read the CLOB in the new context
-        List<?> objects2 = context2.performQuery(new SelectQuery(BlobTestEntity.class));
-        assertEquals(1, objects2.size());
-
-        BlobTestEntity blobObj2 = (BlobTestEntity) objects2.get(0);
-        ByteArrayTypeTest.assertByteArraysEqual(blobObj1.getBlobCol(), blobObj2
-                .getBlobCol());
-
-        // update and save Blob
-        blobObj2.setBlobCol(new byte[] {
-                '1', '2'
-        });
-        context2.commitChanges();
-
-        // read into yet another context and check for changes
-        List<?> objects3 = context3.performQuery(new SelectQuery(BlobTestEntity.class));
-        assertEquals(1, objects3.size());
-
-        BlobTestEntity blobObj3 = (BlobTestEntity) objects3.get(0);
-        ByteArrayTypeTest.assertByteArraysEqual(blobObj2.getBlobCol(), blobObj3
-                .getBlobCol());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCallbacksIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCallbacksIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCallbacksIT.java
new file mode 100644
index 0000000..9450aea
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCallbacksIT.java
@@ -0,0 +1,181 @@
+/*****************************************************************
+ *   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;
+
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.LifecycleEvent;
+import org.apache.cayenne.reflect.LifecycleCallbackRegistry;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.Painting;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextCallbacksIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+    }
+
+    @Override
+    protected void tearDownBeforeInjection() throws Exception {
+        EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
+        resolver.getCallbackRegistry().clear();
+    }
+
+    public void testPostAddCallbacks() {
+        LifecycleCallbackRegistry registry = runtime
+                .getDataDomain()
+                .getEntityResolver()
+                .getCallbackRegistry();
+
+        // no callbacks
+        Artist a1 = context.newObject(Artist.class);
+        assertNotNull(a1);
+        assertFalse(a1.isPostAdded());
+
+        registry.addCallback(LifecycleEvent.POST_ADD, Artist.class, "postAddCallback");
+
+        Artist a2 = context.newObject(Artist.class);
+        assertNotNull(a2);
+        assertTrue(a2.isPostAdded());
+
+        MockCallingBackListener listener2 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_ADD,
+                Artist.class,
+                listener2,
+                "publicCallback");
+
+        Artist a3 = context.newObject(Artist.class);
+        assertNotNull(a3);
+        assertTrue(a3.isPostAdded());
+
+        assertSame(a3, listener2.getPublicCalledbackEntity());
+
+        Painting p3 = context.newObject(Painting.class);
+        assertNotNull(p3);
+        assertFalse(p3.isPostAdded());
+        assertSame(a3, listener2.getPublicCalledbackEntity());
+    }
+
+    public void testPrePersistCallbacks() {
+        LifecycleCallbackRegistry registry = runtime
+                .getDataDomain()
+                .getEntityResolver()
+                .getCallbackRegistry();
+
+        // no callbacks
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("1");
+        assertFalse(a1.isPrePersisted());
+        context.commitChanges();
+        assertFalse(a1.isPrePersisted());
+
+        registry.addCallback(
+                LifecycleEvent.PRE_PERSIST,
+                Artist.class,
+                "prePersistCallback");
+
+        Artist a2 = context.newObject(Artist.class);
+        a2.setArtistName("2");
+        assertFalse(a2.isPrePersisted());
+        context.commitChanges();
+        assertTrue(a2.isPrePersisted());
+
+        MockCallingBackListener listener2 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.PRE_PERSIST,
+                Artist.class,
+                listener2,
+                "publicCallback");
+
+        Artist a3 = context.newObject(Artist.class);
+        a3.setArtistName("3");
+        assertNull(listener2.getPublicCalledbackEntity());
+        context.commitChanges();
+        assertSame(a3, listener2.getPublicCalledbackEntity());
+    }
+
+    public void testPreRemoveCallbacks() {
+        LifecycleCallbackRegistry registry = runtime
+                .getDataDomain()
+                .getEntityResolver()
+                .getCallbackRegistry();
+
+        // no callbacks
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.commitChanges();
+        context.deleteObjects(a1);
+        assertFalse(a1.isPostAdded());
+        assertFalse(a1.isPreRemoved());
+
+        registry
+                .addCallback(LifecycleEvent.PRE_REMOVE, Artist.class, "preRemoveCallback");
+
+        Artist a2 = context.newObject(Artist.class);
+        a2.setArtistName("XX");
+        context.commitChanges();
+        context.deleteObjects(a2);
+        assertFalse(a2.isPostAdded());
+        assertTrue(a2.isPreRemoved());
+
+        MockCallingBackListener listener2 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.PRE_REMOVE,
+                Artist.class,
+                listener2,
+                "publicCallback");
+
+        Artist a3 = context.newObject(Artist.class);
+        a3.setArtistName("XX");
+        context.commitChanges();
+        context.deleteObjects(a3);
+        assertFalse(a3.isPostAdded());
+        assertTrue(a3.isPreRemoved());
+
+        assertSame(a3, listener2.getPublicCalledbackEntity());
+
+        Painting p3 = context.newObject(Painting.class);
+        p3.setPaintingTitle("XX");
+        context.commitChanges();
+        context.deleteObjects(p3);
+        assertFalse(p3.isPostAdded());
+        assertFalse(p3.isPreRemoved());
+        assertSame(a3, listener2.getPublicCalledbackEntity());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCallbacksTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCallbacksTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCallbacksTest.java
deleted file mode 100644
index 9dcd8e3..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCallbacksTest.java
+++ /dev/null
@@ -1,181 +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;
-
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.LifecycleEvent;
-import org.apache.cayenne.reflect.LifecycleCallbackRegistry;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.testdo.testmap.Painting;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextCallbacksTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private ServerRuntime runtime;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("PAINTING_INFO");
-        dbHelper.deleteAll("PAINTING");
-        dbHelper.deleteAll("ARTIST_EXHIBIT");
-        dbHelper.deleteAll("ARTIST_GROUP");
-        dbHelper.deleteAll("ARTIST");
-    }
-
-    @Override
-    protected void tearDownBeforeInjection() throws Exception {
-        EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
-        resolver.getCallbackRegistry().clear();
-    }
-
-    public void testPostAddCallbacks() {
-        LifecycleCallbackRegistry registry = runtime
-                .getDataDomain()
-                .getEntityResolver()
-                .getCallbackRegistry();
-
-        // no callbacks
-        Artist a1 = context.newObject(Artist.class);
-        assertNotNull(a1);
-        assertFalse(a1.isPostAdded());
-
-        registry.addCallback(LifecycleEvent.POST_ADD, Artist.class, "postAddCallback");
-
-        Artist a2 = context.newObject(Artist.class);
-        assertNotNull(a2);
-        assertTrue(a2.isPostAdded());
-
-        MockCallingBackListener listener2 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_ADD,
-                Artist.class,
-                listener2,
-                "publicCallback");
-
-        Artist a3 = context.newObject(Artist.class);
-        assertNotNull(a3);
-        assertTrue(a3.isPostAdded());
-
-        assertSame(a3, listener2.getPublicCalledbackEntity());
-
-        Painting p3 = context.newObject(Painting.class);
-        assertNotNull(p3);
-        assertFalse(p3.isPostAdded());
-        assertSame(a3, listener2.getPublicCalledbackEntity());
-    }
-
-    public void testPrePersistCallbacks() {
-        LifecycleCallbackRegistry registry = runtime
-                .getDataDomain()
-                .getEntityResolver()
-                .getCallbackRegistry();
-
-        // no callbacks
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("1");
-        assertFalse(a1.isPrePersisted());
-        context.commitChanges();
-        assertFalse(a1.isPrePersisted());
-
-        registry.addCallback(
-                LifecycleEvent.PRE_PERSIST,
-                Artist.class,
-                "prePersistCallback");
-
-        Artist a2 = context.newObject(Artist.class);
-        a2.setArtistName("2");
-        assertFalse(a2.isPrePersisted());
-        context.commitChanges();
-        assertTrue(a2.isPrePersisted());
-
-        MockCallingBackListener listener2 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.PRE_PERSIST,
-                Artist.class,
-                listener2,
-                "publicCallback");
-
-        Artist a3 = context.newObject(Artist.class);
-        a3.setArtistName("3");
-        assertNull(listener2.getPublicCalledbackEntity());
-        context.commitChanges();
-        assertSame(a3, listener2.getPublicCalledbackEntity());
-    }
-
-    public void testPreRemoveCallbacks() {
-        LifecycleCallbackRegistry registry = runtime
-                .getDataDomain()
-                .getEntityResolver()
-                .getCallbackRegistry();
-
-        // no callbacks
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        context.commitChanges();
-        context.deleteObjects(a1);
-        assertFalse(a1.isPostAdded());
-        assertFalse(a1.isPreRemoved());
-
-        registry
-                .addCallback(LifecycleEvent.PRE_REMOVE, Artist.class, "preRemoveCallback");
-
-        Artist a2 = context.newObject(Artist.class);
-        a2.setArtistName("XX");
-        context.commitChanges();
-        context.deleteObjects(a2);
-        assertFalse(a2.isPostAdded());
-        assertTrue(a2.isPreRemoved());
-
-        MockCallingBackListener listener2 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.PRE_REMOVE,
-                Artist.class,
-                listener2,
-                "publicCallback");
-
-        Artist a3 = context.newObject(Artist.class);
-        a3.setArtistName("XX");
-        context.commitChanges();
-        context.deleteObjects(a3);
-        assertFalse(a3.isPostAdded());
-        assertTrue(a3.isPreRemoved());
-
-        assertSame(a3, listener2.getPublicCalledbackEntity());
-
-        Painting p3 = context.newObject(Painting.class);
-        p3.setPaintingTitle("XX");
-        context.commitChanges();
-        context.deleteObjects(p3);
-        assertFalse(p3.isPostAdded());
-        assertFalse(p3.isPreRemoved());
-        assertSame(a3, listener2.getPublicCalledbackEntity());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharPKIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharPKIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharPKIT.java
new file mode 100644
index 0000000..f066bd4
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharPKIT.java
@@ -0,0 +1,120 @@
+/*****************************************************************
+ *   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;
+
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.CharPkTestEntity;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.List;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextCharPKIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("CHAR_FK_TEST");
+        dbHelper.deleteAll("CHAR_PK_TEST");
+    }
+
+    public void testInsert() throws Exception {
+        CharPkTestEntity object = context.newObject(CharPkTestEntity.class);
+        object.setOtherCol("object-XYZ");
+        object.setPkCol("PK1");
+        context.commitChanges();
+
+        SQLTemplate q = new SQLTemplate(
+                CharPkTestEntity.class,
+                "SELECT * FROM CHAR_PK_TEST");
+
+        q.setFetchingDataRows(true);
+
+        List<?> rows = context.performQuery(q);
+        assertNotNull(rows);
+        assertEquals(1, rows.size());
+        DataRow row = (DataRow) rows.get(0);
+
+        Object val = row.get("OTHER_COL");
+        if (val == null) {
+            val = row.get("other_col");
+        }
+        assertEquals("object-XYZ", val);
+
+        val = row.get("PK_COL");
+        if (val == null) {
+            val = row.get("pk_col");
+        }
+        assertEquals("PK1", val);
+    }
+
+    public void testDelete() throws Exception {
+        CharPkTestEntity object = context.newObject(CharPkTestEntity.class);
+        object.setOtherCol("object-XYZ");
+        object.setPkCol("PK1");
+        context.commitChanges();
+
+        context.deleteObjects(object);
+        context.commitChanges();
+
+        SQLTemplate q = new SQLTemplate(
+                CharPkTestEntity.class,
+                "SELECT * FROM CHAR_PK_TEST");
+        q.setFetchingDataRows(true);
+
+        List<?> rows = context.performQuery(q);
+        assertNotNull(rows);
+        assertEquals(0, rows.size());
+    }
+
+    public void testUpdate() throws Exception {
+        CharPkTestEntity object = context.newObject(CharPkTestEntity.class);
+        object.setOtherCol("object-XYZ");
+        object.setPkCol("PK1");
+        context.commitChanges();
+
+        object.setOtherCol("UPDATED");
+        context.commitChanges();
+
+        SQLTemplate q = new SQLTemplate(
+                CharPkTestEntity.class,
+                "SELECT * FROM CHAR_PK_TEST");
+        q.setFetchingDataRows(true);
+
+        List<?> rows = context.performQuery(q);
+        assertNotNull(rows);
+        assertEquals(1, rows.size());
+        DataRow row = (DataRow) rows.get(0);
+        Object val = row.get("OTHER_COL");
+        if (val == null) {
+            val = row.get("other_col");
+        }
+        assertEquals("UPDATED", val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharPKTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharPKTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharPKTest.java
deleted file mode 100644
index b5238c5..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharPKTest.java
+++ /dev/null
@@ -1,120 +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;
-
-import java.util.List;
-
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.CharPkTestEntity;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextCharPKTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("CHAR_FK_TEST");
-        dbHelper.deleteAll("CHAR_PK_TEST");
-    }
-
-    public void testInsert() throws Exception {
-        CharPkTestEntity object = context.newObject(CharPkTestEntity.class);
-        object.setOtherCol("object-XYZ");
-        object.setPkCol("PK1");
-        context.commitChanges();
-
-        SQLTemplate q = new SQLTemplate(
-                CharPkTestEntity.class,
-                "SELECT * FROM CHAR_PK_TEST");
-
-        q.setFetchingDataRows(true);
-
-        List<?> rows = context.performQuery(q);
-        assertNotNull(rows);
-        assertEquals(1, rows.size());
-        DataRow row = (DataRow) rows.get(0);
-
-        Object val = row.get("OTHER_COL");
-        if (val == null) {
-            val = row.get("other_col");
-        }
-        assertEquals("object-XYZ", val);
-
-        val = row.get("PK_COL");
-        if (val == null) {
-            val = row.get("pk_col");
-        }
-        assertEquals("PK1", val);
-    }
-
-    public void testDelete() throws Exception {
-        CharPkTestEntity object = context.newObject(CharPkTestEntity.class);
-        object.setOtherCol("object-XYZ");
-        object.setPkCol("PK1");
-        context.commitChanges();
-
-        context.deleteObjects(object);
-        context.commitChanges();
-
-        SQLTemplate q = new SQLTemplate(
-                CharPkTestEntity.class,
-                "SELECT * FROM CHAR_PK_TEST");
-        q.setFetchingDataRows(true);
-
-        List<?> rows = context.performQuery(q);
-        assertNotNull(rows);
-        assertEquals(0, rows.size());
-    }
-
-    public void testUpdate() throws Exception {
-        CharPkTestEntity object = context.newObject(CharPkTestEntity.class);
-        object.setOtherCol("object-XYZ");
-        object.setPkCol("PK1");
-        context.commitChanges();
-
-        object.setOtherCol("UPDATED");
-        context.commitChanges();
-
-        SQLTemplate q = new SQLTemplate(
-                CharPkTestEntity.class,
-                "SELECT * FROM CHAR_PK_TEST");
-        q.setFetchingDataRows(true);
-
-        List<?> rows = context.performQuery(q);
-        assertNotNull(rows);
-        assertEquals(1, rows.size());
-        DataRow row = (DataRow) rows.get(0);
-        Object val = row.get("OTHER_COL");
-        if (val == null) {
-            val = row.get("other_col");
-        }
-        assertEquals("UPDATED", val);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharTypeIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharTypeIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharTypeIT.java
new file mode 100644
index 0000000..2a69198
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharTypeIT.java
@@ -0,0 +1,76 @@
+/*****************************************************************
+ *   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;
+
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.ReturnTypesMap1;
+import org.apache.cayenne.unit.UnitDbAdapter;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.List;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextCharTypeIT extends ServerCase {
+    
+    @Inject
+    protected ObjectContext context;
+    
+    @Inject
+    protected DBHelper dbHelper;
+    
+    @Inject
+    private UnitDbAdapter unitDbAdapter;
+    
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("TYPES_MAPPING_TEST1");
+    }
+    
+    public void testCharTrimming() {
+        if (unitDbAdapter.supportsLobs()) {
+            ReturnTypesMap1 map1 = context.newObject(ReturnTypesMap1.class);
+            map1.setCharColumn("  text   ");
+            ReturnTypesMap1 map2 = context.newObject(ReturnTypesMap1.class);
+            map2.setCharColumn("  text");
+            ReturnTypesMap1 map3 = context.newObject(ReturnTypesMap1.class);
+            map3.setCharColumn("text     ");
+            
+            context.commitChanges();
+            
+            Expression qual = ExpressionFactory.matchExp(ReturnTypesMap1.CHAR_COLUMN_PROPERTY, "  text");
+            SelectQuery query = new SelectQuery(ReturnTypesMap1.class, qual);
+            List<ReturnTypesMap1> result =  context.performQuery(query);
+            
+            assertTrue("CHAR type trimming is not valid.", result.get(0).getCharColumn().startsWith("  text"));
+            assertTrue("CHAR type trimming is not valid.", result.get(1).getCharColumn().startsWith("  text"));
+            
+            qual = ExpressionFactory.matchExp(ReturnTypesMap1.CHAR_COLUMN_PROPERTY, "text");
+            query = new SelectQuery(ReturnTypesMap1.class, qual);
+            result =  context.performQuery(query);
+            
+            assertTrue("CHAR type trimming is not valid.", result.get(0).getCharColumn().startsWith("text"));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharTypeTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharTypeTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharTypeTest.java
deleted file mode 100644
index ce2dd37..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextCharTypeTest.java
+++ /dev/null
@@ -1,76 +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;
-
-import java.util.List;
-
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.ReturnTypesMap1;
-import org.apache.cayenne.unit.UnitDbAdapter;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextCharTypeTest extends ServerCase {
-    
-    @Inject
-    protected ObjectContext context;
-    
-    @Inject
-    protected DBHelper dbHelper;
-    
-    @Inject
-    private UnitDbAdapter unitDbAdapter;
-    
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("TYPES_MAPPING_TEST1");
-    }
-    
-    public void testCharTrimming() {
-        if (unitDbAdapter.supportsLobs()) {
-            ReturnTypesMap1 map1 = context.newObject(ReturnTypesMap1.class);
-            map1.setCharColumn("  text   ");
-            ReturnTypesMap1 map2 = context.newObject(ReturnTypesMap1.class);
-            map2.setCharColumn("  text");
-            ReturnTypesMap1 map3 = context.newObject(ReturnTypesMap1.class);
-            map3.setCharColumn("text     ");
-            
-            context.commitChanges();
-            
-            Expression qual = ExpressionFactory.matchExp(ReturnTypesMap1.CHAR_COLUMN_PROPERTY, "  text");
-            SelectQuery query = new SelectQuery(ReturnTypesMap1.class, qual);
-            List<ReturnTypesMap1> result =  context.performQuery(query);
-            
-            assertTrue("CHAR type trimming is not valid.", result.get(0).getCharColumn().startsWith("  text"));
-            assertTrue("CHAR type trimming is not valid.", result.get(1).getCharColumn().startsWith("  text"));
-            
-            qual = ExpressionFactory.matchExp(ReturnTypesMap1.CHAR_COLUMN_PROPERTY, "text");
-            query = new SelectQuery(ReturnTypesMap1.class, qual);
-            result =  context.performQuery(query);
-            
-            assertTrue("CHAR type trimming is not valid.", result.get(0).getCharColumn().startsWith("text"));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextClobIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextClobIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextClobIT.java
new file mode 100644
index 0000000..4fae72b
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextClobIT.java
@@ -0,0 +1,158 @@
+/*****************************************************************
+ *   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;
+
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.ClobTestEntity;
+import org.apache.cayenne.unit.UnitDbAdapter;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.List;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextClobIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DataContext context2;
+
+    @Inject
+    private DataContext context3;
+
+    @Inject
+    private UnitDbAdapter accessStackAdapter;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        if (accessStackAdapter.supportsLobs()) {
+            dbHelper.deleteAll("CLOB_TEST");
+        }
+    }
+
+    private boolean skipTests() {
+        return !accessStackAdapter.supportsLobs();
+    }
+
+    private boolean skipEmptyLOBTests() {
+        return !accessStackAdapter.handlesNullVsEmptyLOBs();
+    }
+
+    public void testEmptyClob() throws Exception {
+        if (skipEmptyLOBTests()) {
+            return;
+        }
+        runWithClobSize(0);
+    }
+
+    public void test5ByteClob() throws Exception {
+        if (skipTests()) {
+            return;
+        }
+        runWithClobSize(5);
+    }
+
+    public void test5KByteClob() throws Exception {
+        if (skipTests()) {
+            return;
+        }
+        runWithClobSize(5 * 1024);
+    }
+
+    public void test1MBClob() throws Exception {
+        if (skipTests()) {
+            return;
+        }
+        runWithClobSize(1024 * 1024);
+    }
+
+    public void testNullClob() throws Exception {
+        if (skipTests()) {
+            return;
+        }
+
+        // insert new clob
+        context.newObject(ClobTestEntity.class);
+        context.commitChanges();
+
+        // read the CLOB in the new context
+        List<?> objects2 = context2.performQuery(new SelectQuery(ClobTestEntity.class));
+        assertEquals(1, objects2.size());
+
+        ClobTestEntity clobObj2 = (ClobTestEntity) objects2.get(0);
+        assertNull("Expected null, got: '" + clobObj2.getClobCol() + "'", clobObj2
+                .getClobCol());
+
+        // update and save Clob
+        clobObj2.setClobCol("updated rather small clob...");
+        context2.commitChanges();
+
+        // read into yet another context and check for changes
+        List<?> objects3 = context3.performQuery(new SelectQuery(ClobTestEntity.class));
+        assertEquals(1, objects3.size());
+
+        ClobTestEntity clobObj3 = (ClobTestEntity) objects3.get(0);
+        assertEquals(clobObj2.getClobCol(), clobObj3.getClobCol());
+    }
+
+    protected void runWithClobSize(int sizeBytes) throws Exception {
+        // insert new clob
+        ClobTestEntity clobObj1 = context.newObject(ClobTestEntity.class);
+
+        // init CLOB of a specified size
+        if (sizeBytes == 0) {
+            clobObj1.setClobCol("");
+        }
+        else {
+            byte[] bytes = new byte[sizeBytes];
+            for (int i = 0; i < sizeBytes; i++) {
+                bytes[i] = (byte) (65 + (50 + i) % 50);
+            }
+            clobObj1.setClobCol(new String(bytes));
+        }
+
+        context.commitChanges();
+
+        // read the CLOB in the new context
+        List<?> objects2 = context2.performQuery(new SelectQuery(ClobTestEntity.class));
+        assertEquals(1, objects2.size());
+
+        ClobTestEntity clobObj2 = (ClobTestEntity) objects2.get(0);
+        assertEquals(clobObj1.getClobCol(), clobObj2.getClobCol());
+
+        // update and save Clob
+        clobObj2.setClobCol("updated rather small clob...");
+        context2.commitChanges();
+
+        // read into yet another context and check for changes
+        List<?> objects3 = context3.performQuery(new SelectQuery(ClobTestEntity.class));
+        assertEquals(1, objects3.size());
+
+        ClobTestEntity clobObj3 = (ClobTestEntity) objects3.get(0);
+        assertEquals(clobObj2.getClobCol(), clobObj3.getClobCol());
+    }
+}