cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [16/48] Installing Maven Failsafe Plugin
Date Sun, 02 Nov 2014 07:10:04 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/TransactionThreadTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/TransactionThreadTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/TransactionThreadTest.java
deleted file mode 100644
index 9e16338..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/TransactionThreadTest.java
+++ /dev/null
@@ -1,118 +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.sql.Connection;
-
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.log.JdbcEventLogger;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.tx.BaseTransaction;
-import org.apache.cayenne.tx.CayenneTransaction;
-import org.apache.cayenne.tx.Transaction;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class TransactionThreadTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    protected 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 testThreadConnectionReuseOnSelect() throws Exception {
-
-        ConnectionCounterTx t = new ConnectionCounterTx(new CayenneTransaction(logger));
-        BaseTransaction.bindThreadTransaction(t);
-
-        try {
-
-            SelectQuery q1 = new SelectQuery(Artist.class);
-            context.performQuery(q1);
-            assertEquals(1, t.connectionCount);
-
-            // delegate will fail if the second query opens a new connection
-            SelectQuery q2 = new SelectQuery(Artist.class);
-            context.performQuery(q2);
-
-        } finally {
-            BaseTransaction.bindThreadTransaction(null);
-            t.commit();
-        }
-    }
-
-    class ConnectionCounterTx implements Transaction {
-
-        private Transaction delegate;
-        int connectionCount;
-
-        ConnectionCounterTx(Transaction delegate) {
-            this.delegate = delegate;
-        }
-
-        public void begin() {
-            delegate.begin();
-        }
-
-        public void commit() {
-            delegate.commit();
-        }
-
-        public void rollback() {
-            delegate.rollback();
-        }
-
-        public void setRollbackOnly() {
-            delegate.setRollbackOnly();
-        }
-
-        public boolean isRollbackOnly() {
-            return delegate.isRollbackOnly();
-        }
-
-        public Connection getConnection(String name) {
-            return delegate.getConnection(name);
-        }
-
-        public void addConnection(String name, Connection connection) {
-            if (connectionCount++ > 0) {
-                fail("Invalid attempt to add connection");
-            }
-
-            delegate.addConnection(name, connection);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/UUIDIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/UUIDIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/UUIDIT.java
new file mode 100644
index 0000000..9275638
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/UUIDIT.java
@@ -0,0 +1,93 @@
+/*****************************************************************
+ *   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.Cayenne;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.testmap.UuidPkEntity;
+import org.apache.cayenne.testdo.testmap.UuidTestEntity;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.UUID;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class UUIDIT extends ServerCase {
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    private TableHelper uuidPkEntity;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("UUID_TEST");
+        dbHelper.deleteAll("UUID_PK_ENTITY");
+
+        uuidPkEntity = new TableHelper(dbHelper, "UUID_PK_ENTITY", "ID");
+    }
+
+    public void testUUID() throws Exception {
+
+        UuidTestEntity test = context.newObject(UuidTestEntity.class);
+
+        UUID id = UUID.randomUUID();
+        test.setUuid(id);
+        context.commitChanges();
+
+        SelectQuery q = new SelectQuery(UuidTestEntity.class);
+        UuidTestEntity testRead = (UuidTestEntity) context.performQuery(q).get(0);
+        assertNotNull(testRead.getUuid());
+        assertEquals(id, testRead.getUuid());
+
+        test.setUuid(null);
+        context.commitChanges();
+    }
+
+    public void testUUIDMeaningfulPkInsert() throws Exception {
+        UUID id = UUID.randomUUID();
+
+        UuidPkEntity o1 = context.newObject(UuidPkEntity.class);
+        o1.setId(id);
+
+        context.commitChanges();
+
+        String fetched = uuidPkEntity.getString("ID");
+        assertEquals(id, UUID.fromString(fetched));
+    }
+
+    public void testUUIDMeaningfulPkSelect() throws Exception {
+        UUID id = UUID.randomUUID();
+
+        uuidPkEntity.insert(id.toString());
+
+        UuidPkEntity o1 = Cayenne.objectForPK(context, UuidPkEntity.class, id);
+
+        assertNotNull(o1);
+        assertEquals(id, o1.getId());
+        assertEquals(id, o1.getObjectId().getIdSnapshot().get("ID"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/UUIDTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/UUIDTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/UUIDTest.java
deleted file mode 100644
index 3ff4b37..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/UUIDTest.java
+++ /dev/null
@@ -1,93 +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.UUID;
-
-import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.testmap.UuidPkEntity;
-import org.apache.cayenne.testdo.testmap.UuidTestEntity;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class UUIDTest extends ServerCase {
-
-    @Inject
-    private ObjectContext context;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    private TableHelper uuidPkEntity;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("UUID_TEST");
-        dbHelper.deleteAll("UUID_PK_ENTITY");
-
-        uuidPkEntity = new TableHelper(dbHelper, "UUID_PK_ENTITY", "ID");
-    }
-
-    public void testUUID() throws Exception {
-
-        UuidTestEntity test = context.newObject(UuidTestEntity.class);
-
-        UUID id = UUID.randomUUID();
-        test.setUuid(id);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(UuidTestEntity.class);
-        UuidTestEntity testRead = (UuidTestEntity) context.performQuery(q).get(0);
-        assertNotNull(testRead.getUuid());
-        assertEquals(id, testRead.getUuid());
-
-        test.setUuid(null);
-        context.commitChanges();
-    }
-
-    public void testUUIDMeaningfulPkInsert() throws Exception {
-        UUID id = UUID.randomUUID();
-
-        UuidPkEntity o1 = context.newObject(UuidPkEntity.class);
-        o1.setId(id);
-
-        context.commitChanges();
-
-        String fetched = uuidPkEntity.getString("ID");
-        assertEquals(id, UUID.fromString(fetched));
-    }
-
-    public void testUUIDMeaningfulPkSelect() throws Exception {
-        UUID id = UUID.randomUUID();
-
-        uuidPkEntity.insert(id.toString());
-
-        UuidPkEntity o1 = Cayenne.objectForPK(context, UuidPkEntity.class, id);
-
-        assertNotNull(o1);
-        assertEquals(id, o1.getId());
-        assertEquals(id, o1.getObjectId().getIdSnapshot().get("ID"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/UserTransactionIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/UserTransactionIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/UserTransactionIT.java
new file mode 100644
index 0000000..5e6c461
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/UserTransactionIT.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.access;
+
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.log.JdbcEventLogger;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.tx.BaseTransaction;
+import org.apache.cayenne.tx.CayenneTransaction;
+import org.apache.cayenne.tx.Transaction;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.Connection;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class UserTransactionIT extends ServerCase {
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private JdbcEventLogger logger;
+
+    public void testCommit() throws Exception {
+
+        Artist a = context.newObject(Artist.class);
+        a.setArtistName("AAA");
+
+        TxWrapper t = new TxWrapper(new CayenneTransaction(logger));
+        BaseTransaction.bindThreadTransaction(t);
+
+        try {
+            context.commitChanges();
+        } finally {
+            t.rollback();
+            BaseTransaction.bindThreadTransaction(null);
+        }
+
+        assertEquals(0, t.commitCount);
+        assertEquals(1, t.connectionCount);
+    }
+
+    class TxWrapper implements Transaction {
+
+        private Transaction delegate;
+        int commitCount;
+        int connectionCount;
+
+        TxWrapper(Transaction delegate) {
+            this.delegate = delegate;
+        }
+
+        public void begin() {
+            delegate.begin();
+        }
+
+        public void commit() {
+            commitCount++;
+            delegate.commit();
+        }
+
+        public void rollback() {
+            delegate.rollback();
+        }
+
+        public void setRollbackOnly() {
+            delegate.setRollbackOnly();
+        }
+
+        public boolean isRollbackOnly() {
+            return delegate.isRollbackOnly();
+        }
+
+        public Connection getConnection(String name) {
+            return delegate.getConnection(name);
+        }
+
+        public void addConnection(String name, Connection connection) {
+            connectionCount++;
+            delegate.addConnection(name, connection);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/UserTransactionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/UserTransactionTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/UserTransactionTest.java
deleted file mode 100644
index 1ca8e1a..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/UserTransactionTest.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.access;
-
-import java.sql.Connection;
-
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.log.JdbcEventLogger;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.tx.BaseTransaction;
-import org.apache.cayenne.tx.CayenneTransaction;
-import org.apache.cayenne.tx.Transaction;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class UserTransactionTest extends ServerCase {
-
-    @Inject
-    private ObjectContext context;
-
-    @Inject
-    private JdbcEventLogger logger;
-
-    public void testCommit() throws Exception {
-
-        Artist a = context.newObject(Artist.class);
-        a.setArtistName("AAA");
-
-        TxWrapper t = new TxWrapper(new CayenneTransaction(logger));
-        BaseTransaction.bindThreadTransaction(t);
-
-        try {
-            context.commitChanges();
-        } finally {
-            t.rollback();
-            BaseTransaction.bindThreadTransaction(null);
-        }
-
-        assertEquals(0, t.commitCount);
-        assertEquals(1, t.connectionCount);
-    }
-
-    class TxWrapper implements Transaction {
-
-        private Transaction delegate;
-        int commitCount;
-        int connectionCount;
-
-        TxWrapper(Transaction delegate) {
-            this.delegate = delegate;
-        }
-
-        public void begin() {
-            delegate.begin();
-        }
-
-        public void commit() {
-            commitCount++;
-            delegate.commit();
-        }
-
-        public void rollback() {
-            delegate.rollback();
-        }
-
-        public void setRollbackOnly() {
-            delegate.setRollbackOnly();
-        }
-
-        public boolean isRollbackOnly() {
-            return delegate.isRollbackOnly();
-        }
-
-        public Connection getConnection(String name) {
-            return delegate.getConnection(name);
-        }
-
-        public void addConnection(String name, Connection connection) {
-            connectionCount++;
-            delegate.addConnection(name, connection);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
new file mode 100644
index 0000000..46bdc11
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
@@ -0,0 +1,528 @@
+/*****************************************************************
+ *   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.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.inheritance.vertical.Iv1Root;
+import org.apache.cayenne.testdo.inheritance.vertical.Iv1Sub1;
+import org.apache.cayenne.testdo.inheritance.vertical.Iv2Sub1;
+import org.apache.cayenne.testdo.inheritance.vertical.Iv2X;
+import org.apache.cayenne.testdo.inheritance.vertical.IvRoot;
+import org.apache.cayenne.testdo.inheritance.vertical.IvSub1;
+import org.apache.cayenne.testdo.inheritance.vertical.IvSub1Sub1;
+import org.apache.cayenne.testdo.inheritance.vertical.IvSub2;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@UseServerRuntime(ServerCase.INHERTITANCE_VERTICAL_PROJECT)
+public class VerticalInheritanceIT extends ServerCase {
+
+	@Inject
+	protected ObjectContext context;
+
+	@Inject
+	protected DBHelper dbHelper;
+
+	@Override
+	protected void setUpAfterInjection() throws Exception {
+
+		dbHelper.deleteAll("IV_SUB1_SUB1");
+		dbHelper.deleteAll("IV_SUB1");
+		dbHelper.deleteAll("IV_SUB2");
+		dbHelper.deleteAll("IV_ROOT");
+
+		dbHelper.deleteAll("IV1_SUB1");
+		dbHelper.deleteAll("IV1_ROOT");
+
+		dbHelper.deleteAll("IV2_SUB1");
+		dbHelper.deleteAll("IV2_ROOT");
+		dbHelper.deleteAll("IV2_X");
+	}
+
+	public void testInsert_Root() throws Exception {
+
+		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
+		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
+
+		assertEquals(0, ivRootTable.getRowCount());
+
+		IvRoot root = context.newObject(IvRoot.class);
+		root.setName("XyZ");
+		root.getObjectContext().commitChanges();
+
+		assertEquals(1, ivRootTable.getRowCount());
+
+		Object[] rootData = ivRootTable.select();
+		assertEquals(3, rootData.length);
+		assertTrue(rootData[0] instanceof Number);
+		assertTrue(((Number) rootData[0]).intValue() > 0);
+		assertEquals("XyZ", rootData[1]);
+		assertNull(rootData[2]);
+	}
+
+	public void testInsert_Sub1() throws Exception {
+
+		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
+		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
+
+		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
+		ivSub1Table.setColumns("ID", "SUB1_NAME");
+
+		IvSub1 sub1 = context.newObject(IvSub1.class);
+		sub1.setName("XyZX");
+		sub1.getObjectContext().commitChanges();
+
+		assertEquals(1, ivRootTable.getRowCount());
+		assertEquals(1, ivSub1Table.getRowCount());
+
+		Object[] data = ivRootTable.select();
+		assertEquals(3, data.length);
+		assertTrue(data[0] instanceof Number);
+		assertTrue(((Number) data[0]).intValue() > 0);
+		assertEquals("XyZX", data[1]);
+		assertEquals("IvSub1", data[2]);
+
+		Object[] subdata = ivSub1Table.select();
+		assertEquals(2, subdata.length);
+		assertEquals(data[0], subdata[0]);
+		assertNull(subdata[1]);
+
+		ivSub1Table.deleteAll();
+		ivRootTable.deleteAll();
+
+		IvSub1 sub11 = context.newObject(IvSub1.class);
+		sub11.setName("XyZXY");
+		sub11.setSub1Name("BdE2");
+		sub11.getObjectContext().commitChanges();
+
+		data = ivRootTable.select();
+		assertEquals(3, data.length);
+		assertTrue(data[0] instanceof Number);
+		assertTrue(((Number) data[0]).intValue() > 0);
+		assertEquals("XyZXY", data[1]);
+		assertEquals("IvSub1", data[2]);
+
+		subdata = ivSub1Table.select();
+		assertEquals(2, subdata.length);
+		assertEquals(data[0], subdata[0]);
+		assertEquals("BdE2", subdata[1]);
+	}
+
+	public void testInsert_Sub2() throws Exception {
+
+		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
+		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
+
+		TableHelper ivSub2Table = new TableHelper(dbHelper, "IV_SUB2");
+		ivSub2Table.setColumns("ID", "SUB2_NAME", "SUB2_ATTR");
+
+		IvSub2 sub2 = context.newObject(IvSub2.class);
+		sub2.setName("XyZX");
+		sub2.getObjectContext().commitChanges();
+
+		assertEquals(1, ivRootTable.getRowCount());
+		assertEquals(1, ivSub2Table.getRowCount());
+
+		Object[] data = ivRootTable.select();
+		assertEquals(3, data.length);
+		assertTrue(data[0] instanceof Number);
+		assertTrue(((Number) data[0]).intValue() > 0);
+		assertEquals("XyZX", data[1]);
+		assertEquals("IvSub2", data[2]);
+
+		Object[] subdata = ivSub2Table.select();
+		assertEquals(3, subdata.length);
+		assertEquals(data[0], subdata[0]);
+		assertNull(subdata[1]);
+		assertNull(subdata[2]);
+
+		ivSub2Table.deleteAll();
+		ivRootTable.deleteAll();
+
+		IvSub2 sub21 = context.newObject(IvSub2.class);
+		sub21.setName("XyZXY");
+		sub21.setSub2Name("BdE2");
+		sub21.setSub2Attr("aTtR");
+		sub21.getObjectContext().commitChanges();
+
+		data = ivRootTable.select();
+		assertEquals(3, data.length);
+		assertTrue(data[0] instanceof Number);
+		assertTrue(((Number) data[0]).intValue() > 0);
+		assertEquals("XyZXY", data[1]);
+		assertEquals("IvSub2", data[2]);
+
+		subdata = ivSub2Table.select();
+		assertEquals(3, subdata.length);
+		assertEquals(data[0], subdata[0]);
+		assertEquals("BdE2", subdata[1]);
+		assertEquals("aTtR", subdata[2]);
+
+		sub21.setSub2Attr("BUuT");
+		sub21.getObjectContext().commitChanges();
+
+		subdata = ivSub2Table.select();
+		assertEquals(3, subdata.length);
+		assertEquals(data[0], subdata[0]);
+		assertEquals("BdE2", subdata[1]);
+		assertEquals("BUuT", subdata[2]);
+
+		sub21.getObjectContext().deleteObjects(sub21);
+		sub21.getObjectContext().commitChanges();
+
+		assertEquals(0, ivRootTable.getRowCount());
+		assertEquals(0, ivSub2Table.getRowCount());
+	}
+
+	public void testInsert_Sub1Sub1() throws Exception {
+
+		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
+		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
+
+		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
+		ivSub1Table.setColumns("ID", "SUB1_NAME");
+
+		TableHelper ivSub1Sub1Table = new TableHelper(dbHelper, "IV_SUB1_SUB1");
+		ivSub1Sub1Table.setColumns("ID", "SUB1_SUB1_NAME");
+
+		IvSub1Sub1 sub1Sub1 = context.newObject(IvSub1Sub1.class);
+		sub1Sub1.setName("XyZN");
+		sub1Sub1.setSub1Name("mDA");
+		sub1Sub1.setSub1Sub1Name("3DQa");
+		sub1Sub1.getObjectContext().commitChanges();
+
+		assertEquals(1, ivRootTable.getRowCount());
+		assertEquals(1, ivSub1Table.getRowCount());
+		assertEquals(1, ivSub1Sub1Table.getRowCount());
+
+		Object[] data = ivRootTable.select();
+		assertEquals(3, data.length);
+		assertTrue(data[0] instanceof Number);
+		assertTrue(((Number) data[0]).intValue() > 0);
+		assertEquals("XyZN", data[1]);
+		assertEquals("IvSub1Sub1", data[2]);
+
+		Object[] subdata = ivSub1Table.select();
+		assertEquals(2, subdata.length);
+		assertEquals(data[0], subdata[0]);
+		assertEquals("mDA", subdata[1]);
+
+		Object[] subsubdata = ivSub1Sub1Table.select();
+		assertEquals(2, subsubdata.length);
+		assertEquals(data[0], subsubdata[0]);
+		assertEquals("3DQa", subsubdata[1]);
+	}
+
+	public void testSelectQuery_SuperSub() throws Exception {
+
+		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
+		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(
+				Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
+
+		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
+		ivSub1Table.setColumns("ID", "SUB1_NAME");
+
+		// insert
+		ivRootTable.insert(1, "xROOT", null);
+		ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
+		ivSub1Table.insert(2, "xSUB1");
+
+		SelectQuery query = new SelectQuery(IvRoot.class);
+		List<IvRoot> results = context.performQuery(query);
+
+		assertEquals(2, results.size());
+
+		// since we don't have ordering, need to analyze results in an order
+		// agnostic
+		// fashion
+		Map<String, IvRoot> resultTypes = new HashMap<String, IvRoot>();
+
+		for (IvRoot result : results) {
+			resultTypes.put(result.getClass().getName(), result);
+		}
+
+		assertEquals(2, resultTypes.size());
+
+		IvRoot root = resultTypes.get(IvRoot.class.getName());
+		assertNotNull(root);
+		assertEquals("xROOT", root.getName());
+		assertNull(root.getDiscriminator());
+
+		IvSub1 sub1 = (IvSub1) resultTypes.get(IvSub1.class.getName());
+		assertNotNull(sub1);
+		assertEquals("xSUB1_ROOT", sub1.getName());
+		assertEquals("IvSub1", sub1.getDiscriminator());
+	}
+
+	public void testSelectQuery_DeepAndWide() throws Exception {
+
+		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
+		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(
+				Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
+
+		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
+		ivSub1Table.setColumns("ID", "SUB1_NAME");
+
+		TableHelper ivSub2Table = new TableHelper(dbHelper, "IV_SUB2");
+		ivSub2Table.setColumns("ID", "SUB2_NAME");
+
+		TableHelper ivSub1Sub1Table = new TableHelper(dbHelper, "IV_SUB1_SUB1");
+		ivSub1Sub1Table.setColumns("ID", "SUB1_SUB1_NAME");
+
+		// insert
+		ivRootTable.insert(1, "xROOT", null);
+
+		ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
+		ivSub1Table.insert(2, "xSUB1");
+
+		ivRootTable.insert(3, "xSUB1_SUB1_ROOT", "IvSub1Sub1");
+		ivSub1Table.insert(3, "xSUB1_SUB1_SUBROOT");
+		ivSub1Sub1Table.insert(3, "xSUB1_SUB1");
+
+		ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
+		ivSub2Table.insert(4, "xSUB2");
+
+		SelectQuery query = new SelectQuery(IvRoot.class);
+		List<IvRoot> results = context.performQuery(query);
+
+		assertEquals(4, results.size());
+
+		// since we don't have ordering, need to analyze results in an order
+		// agnostic
+		// fashion
+		Map<String, IvRoot> resultTypes = new HashMap<String, IvRoot>();
+
+		for (IvRoot result : results) {
+			resultTypes.put(result.getClass().getName(), result);
+		}
+
+		assertEquals(4, resultTypes.size());
+
+		IvRoot root = resultTypes.get(IvRoot.class.getName());
+		assertNotNull(root);
+		assertEquals("xROOT", root.getName());
+		assertNull(root.getDiscriminator());
+
+		IvSub1 sub1 = (IvSub1) resultTypes.get(IvSub1.class.getName());
+		assertNotNull(sub1);
+		assertEquals("xSUB1_ROOT", sub1.getName());
+		assertEquals("IvSub1", sub1.getDiscriminator());
+
+		IvSub1Sub1 sub1Sub1 = (IvSub1Sub1) resultTypes.get(IvSub1Sub1.class
+				.getName());
+		assertNotNull(sub1Sub1);
+		assertEquals("xSUB1_SUB1_ROOT", sub1Sub1.getName());
+		assertEquals("IvSub1Sub1", sub1Sub1.getDiscriminator());
+		assertEquals("xSUB1_SUB1_SUBROOT", sub1Sub1.getSub1Name());
+		assertEquals("xSUB1_SUB1", sub1Sub1.getSub1Sub1Name());
+
+		IvSub2 sub2 = (IvSub2) resultTypes.get(IvSub2.class.getName());
+		assertNotNull(sub2);
+		assertEquals("xROOT_SUB2", sub2.getName());
+		assertEquals("IvSub2", sub2.getDiscriminator());
+		assertEquals("xSUB2", sub2.getSub2Name());
+	}
+
+	public void testSelectQuery_MiddleLeaf() throws Exception {
+
+		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
+		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(
+				Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
+
+		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
+		ivSub1Table.setColumns("ID", "SUB1_NAME");
+
+		TableHelper ivSub2Table = new TableHelper(dbHelper, "IV_SUB2");
+		ivSub2Table.setColumns("ID", "SUB2_NAME");
+
+		TableHelper ivSub1Sub1Table = new TableHelper(dbHelper, "IV_SUB1_SUB1");
+		ivSub1Sub1Table.setColumns("ID", "SUB1_SUB1_NAME");
+
+		// insert
+		ivRootTable.insert(1, "xROOT", null);
+
+		ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
+		ivSub1Table.insert(2, "xSUB1");
+
+		ivRootTable.insert(3, "xSUB1_SUB1_ROOT", "IvSub1Sub1");
+		ivSub1Table.insert(3, "xSUB1_SUB1_SUBROOT");
+		ivSub1Sub1Table.insert(3, "xSUB1_SUB1");
+
+		ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
+		ivSub2Table.insert(4, "xSUB2");
+
+		SelectQuery query = new SelectQuery(IvSub1.class);
+		List<IvRoot> results = context.performQuery(query);
+
+		assertEquals(2, results.size());
+
+		// since we don't have ordering, need to analyze results in an order
+		// agnostic
+		// fashion
+		Map<String, IvRoot> resultTypes = new HashMap<String, IvRoot>();
+
+		for (IvRoot result : results) {
+			resultTypes.put(result.getClass().getName(), result);
+		}
+
+		assertEquals(2, resultTypes.size());
+
+		IvSub1 sub1 = (IvSub1) resultTypes.get(IvSub1.class.getName());
+		assertNotNull(sub1);
+		assertEquals("xSUB1_ROOT", sub1.getName());
+		assertEquals("IvSub1", sub1.getDiscriminator());
+
+		IvSub1Sub1 sub1Sub1 = (IvSub1Sub1) resultTypes.get(IvSub1Sub1.class
+				.getName());
+		assertNotNull(sub1Sub1);
+		assertEquals("xSUB1_SUB1_ROOT", sub1Sub1.getName());
+		assertEquals("IvSub1Sub1", sub1Sub1.getDiscriminator());
+		assertEquals("xSUB1_SUB1_SUBROOT", sub1Sub1.getSub1Name());
+		assertEquals("xSUB1_SUB1", sub1Sub1.getSub1Sub1Name());
+	}
+
+	public void testDelete_Mix() throws Exception {
+
+		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
+		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(
+				Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
+
+		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
+		ivSub1Table.setColumns("ID", "SUB1_NAME");
+
+		TableHelper ivSub2Table = new TableHelper(dbHelper, "IV_SUB2");
+		ivSub2Table.setColumns("ID", "SUB2_NAME");
+
+		TableHelper ivSub1Sub1Table = new TableHelper(dbHelper, "IV_SUB1_SUB1");
+		ivSub1Sub1Table.setColumns("ID", "SUB1_SUB1_NAME");
+
+		// insert
+		ivRootTable.insert(1, "xROOT", null);
+
+		ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
+		ivSub1Table.insert(2, "xSUB1");
+
+		ivRootTable.insert(3, "xSUB1_SUB1_ROOT", "IvSub1Sub1");
+		ivSub1Table.insert(3, "xSUB1_SUB1_SUBROOT");
+		ivSub1Sub1Table.insert(3, "xSUB1_SUB1");
+
+		ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
+		ivSub2Table.insert(4, "xSUB2");
+
+		SelectQuery query = new SelectQuery(IvRoot.class);
+
+		List<IvRoot> results = context.performQuery(query);
+
+		assertEquals(4, results.size());
+		Map<String, IvRoot> resultTypes = new HashMap<String, IvRoot>();
+
+		for (IvRoot result : results) {
+			resultTypes.put(result.getClass().getName(), result);
+		}
+
+		assertEquals(4, resultTypes.size());
+
+		IvRoot root = resultTypes.get(IvRoot.class.getName());
+		context.deleteObjects(root);
+
+		IvSub1 sub1 = (IvSub1) resultTypes.get(IvSub1.class.getName());
+		context.deleteObjects(sub1);
+
+		context.commitChanges();
+
+		assertEquals(2, ivRootTable.getRowCount());
+		assertEquals(1, ivSub1Table.getRowCount());
+		assertEquals(1, ivSub1Sub1Table.getRowCount());
+		assertEquals(1, ivSub2Table.getRowCount());
+
+		results = context.performQuery(query);
+		assertEquals(2, results.size());
+	}
+
+	public void testSelectQuery_AttributeOverrides() throws Exception {
+
+		TableHelper iv1RootTable = new TableHelper(dbHelper, "IV1_ROOT");
+		iv1RootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(
+				Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
+
+		TableHelper iv1Sub1Table = new TableHelper(dbHelper, "IV1_SUB1");
+		iv1Sub1Table.setColumns("ID", "SUB1_NAME");
+
+		// insert
+		iv1RootTable.insert(1, "xROOT", null);
+		iv1RootTable.insert(2, "xSUB1_ROOT", "Iv1Sub1");
+		iv1Sub1Table.insert(2, "xSUB1");
+
+		SelectQuery query = new SelectQuery(Iv1Root.class);
+		List<Iv1Root> results = context.performQuery(query);
+
+		assertEquals(2, results.size());
+
+		// since we don't have ordering, need to analyze results in an order
+		// agnostic
+		// fashion
+		Map<String, Iv1Root> resultTypes = new HashMap<String, Iv1Root>();
+
+		for (Iv1Root result : results) {
+			resultTypes.put(result.getClass().getName(), result);
+		}
+
+		assertEquals(2, resultTypes.size());
+
+		Iv1Root root = resultTypes.get(Iv1Root.class.getName());
+		assertNotNull(root);
+		assertEquals("xROOT", root.getName());
+		assertNull(root.getDiscriminator());
+
+		Iv1Sub1 sub1 = (Iv1Sub1) resultTypes.get(Iv1Sub1.class.getName());
+		assertNotNull(sub1);
+		assertEquals("xSUB1", sub1.getName());
+	}
+
+	public void testInsertWithRelationship() throws SQLException {
+		TableHelper xTable = new TableHelper(dbHelper, "IV2_X");
+		TableHelper rootTable = new TableHelper(dbHelper, "IV2_ROOT");
+		TableHelper sub1Table = new TableHelper(dbHelper, "IV2_SUB1");
+
+		assertEquals(0, xTable.getRowCount());
+		assertEquals(0, rootTable.getRowCount());
+		assertEquals(0, sub1Table.getRowCount());
+
+		Iv2Sub1 root = context.newObject(Iv2Sub1.class);
+		Iv2X x = context.newObject(Iv2X.class);
+		root.setX(x);
+
+		context.commitChanges();
+
+		assertEquals(1, xTable.getRowCount());
+		assertEquals(1, rootTable.getRowCount());
+		assertEquals(1, sub1Table.getRowCount());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceTest.java
deleted file mode 100644
index 83265f9..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceTest.java
+++ /dev/null
@@ -1,528 +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.sql.SQLException;
-import java.sql.Types;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.inheritance.vertical.Iv1Root;
-import org.apache.cayenne.testdo.inheritance.vertical.Iv1Sub1;
-import org.apache.cayenne.testdo.inheritance.vertical.Iv2Sub1;
-import org.apache.cayenne.testdo.inheritance.vertical.Iv2X;
-import org.apache.cayenne.testdo.inheritance.vertical.IvRoot;
-import org.apache.cayenne.testdo.inheritance.vertical.IvSub1;
-import org.apache.cayenne.testdo.inheritance.vertical.IvSub1Sub1;
-import org.apache.cayenne.testdo.inheritance.vertical.IvSub2;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.INHERTITANCE_VERTICAL_PROJECT)
-public class VerticalInheritanceTest extends ServerCase {
-
-	@Inject
-	protected ObjectContext context;
-
-	@Inject
-	protected DBHelper dbHelper;
-
-	@Override
-	protected void setUpAfterInjection() throws Exception {
-
-		dbHelper.deleteAll("IV_SUB1_SUB1");
-		dbHelper.deleteAll("IV_SUB1");
-		dbHelper.deleteAll("IV_SUB2");
-		dbHelper.deleteAll("IV_ROOT");
-
-		dbHelper.deleteAll("IV1_SUB1");
-		dbHelper.deleteAll("IV1_ROOT");
-
-		dbHelper.deleteAll("IV2_SUB1");
-		dbHelper.deleteAll("IV2_ROOT");
-		dbHelper.deleteAll("IV2_X");
-	}
-
-	public void testInsert_Root() throws Exception {
-
-		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
-		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
-
-		assertEquals(0, ivRootTable.getRowCount());
-
-		IvRoot root = context.newObject(IvRoot.class);
-		root.setName("XyZ");
-		root.getObjectContext().commitChanges();
-
-		assertEquals(1, ivRootTable.getRowCount());
-
-		Object[] rootData = ivRootTable.select();
-		assertEquals(3, rootData.length);
-		assertTrue(rootData[0] instanceof Number);
-		assertTrue(((Number) rootData[0]).intValue() > 0);
-		assertEquals("XyZ", rootData[1]);
-		assertNull(rootData[2]);
-	}
-
-	public void testInsert_Sub1() throws Exception {
-
-		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
-		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
-
-		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
-		ivSub1Table.setColumns("ID", "SUB1_NAME");
-
-		IvSub1 sub1 = context.newObject(IvSub1.class);
-		sub1.setName("XyZX");
-		sub1.getObjectContext().commitChanges();
-
-		assertEquals(1, ivRootTable.getRowCount());
-		assertEquals(1, ivSub1Table.getRowCount());
-
-		Object[] data = ivRootTable.select();
-		assertEquals(3, data.length);
-		assertTrue(data[0] instanceof Number);
-		assertTrue(((Number) data[0]).intValue() > 0);
-		assertEquals("XyZX", data[1]);
-		assertEquals("IvSub1", data[2]);
-
-		Object[] subdata = ivSub1Table.select();
-		assertEquals(2, subdata.length);
-		assertEquals(data[0], subdata[0]);
-		assertNull(subdata[1]);
-
-		ivSub1Table.deleteAll();
-		ivRootTable.deleteAll();
-
-		IvSub1 sub11 = context.newObject(IvSub1.class);
-		sub11.setName("XyZXY");
-		sub11.setSub1Name("BdE2");
-		sub11.getObjectContext().commitChanges();
-
-		data = ivRootTable.select();
-		assertEquals(3, data.length);
-		assertTrue(data[0] instanceof Number);
-		assertTrue(((Number) data[0]).intValue() > 0);
-		assertEquals("XyZXY", data[1]);
-		assertEquals("IvSub1", data[2]);
-
-		subdata = ivSub1Table.select();
-		assertEquals(2, subdata.length);
-		assertEquals(data[0], subdata[0]);
-		assertEquals("BdE2", subdata[1]);
-	}
-
-	public void testInsert_Sub2() throws Exception {
-
-		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
-		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
-
-		TableHelper ivSub2Table = new TableHelper(dbHelper, "IV_SUB2");
-		ivSub2Table.setColumns("ID", "SUB2_NAME", "SUB2_ATTR");
-
-		IvSub2 sub2 = context.newObject(IvSub2.class);
-		sub2.setName("XyZX");
-		sub2.getObjectContext().commitChanges();
-
-		assertEquals(1, ivRootTable.getRowCount());
-		assertEquals(1, ivSub2Table.getRowCount());
-
-		Object[] data = ivRootTable.select();
-		assertEquals(3, data.length);
-		assertTrue(data[0] instanceof Number);
-		assertTrue(((Number) data[0]).intValue() > 0);
-		assertEquals("XyZX", data[1]);
-		assertEquals("IvSub2", data[2]);
-
-		Object[] subdata = ivSub2Table.select();
-		assertEquals(3, subdata.length);
-		assertEquals(data[0], subdata[0]);
-		assertNull(subdata[1]);
-		assertNull(subdata[2]);
-
-		ivSub2Table.deleteAll();
-		ivRootTable.deleteAll();
-
-		IvSub2 sub21 = context.newObject(IvSub2.class);
-		sub21.setName("XyZXY");
-		sub21.setSub2Name("BdE2");
-		sub21.setSub2Attr("aTtR");
-		sub21.getObjectContext().commitChanges();
-
-		data = ivRootTable.select();
-		assertEquals(3, data.length);
-		assertTrue(data[0] instanceof Number);
-		assertTrue(((Number) data[0]).intValue() > 0);
-		assertEquals("XyZXY", data[1]);
-		assertEquals("IvSub2", data[2]);
-
-		subdata = ivSub2Table.select();
-		assertEquals(3, subdata.length);
-		assertEquals(data[0], subdata[0]);
-		assertEquals("BdE2", subdata[1]);
-		assertEquals("aTtR", subdata[2]);
-
-		sub21.setSub2Attr("BUuT");
-		sub21.getObjectContext().commitChanges();
-
-		subdata = ivSub2Table.select();
-		assertEquals(3, subdata.length);
-		assertEquals(data[0], subdata[0]);
-		assertEquals("BdE2", subdata[1]);
-		assertEquals("BUuT", subdata[2]);
-
-		sub21.getObjectContext().deleteObjects(sub21);
-		sub21.getObjectContext().commitChanges();
-
-		assertEquals(0, ivRootTable.getRowCount());
-		assertEquals(0, ivSub2Table.getRowCount());
-	}
-
-	public void testInsert_Sub1Sub1() throws Exception {
-
-		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
-		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
-
-		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
-		ivSub1Table.setColumns("ID", "SUB1_NAME");
-
-		TableHelper ivSub1Sub1Table = new TableHelper(dbHelper, "IV_SUB1_SUB1");
-		ivSub1Sub1Table.setColumns("ID", "SUB1_SUB1_NAME");
-
-		IvSub1Sub1 sub1Sub1 = context.newObject(IvSub1Sub1.class);
-		sub1Sub1.setName("XyZN");
-		sub1Sub1.setSub1Name("mDA");
-		sub1Sub1.setSub1Sub1Name("3DQa");
-		sub1Sub1.getObjectContext().commitChanges();
-
-		assertEquals(1, ivRootTable.getRowCount());
-		assertEquals(1, ivSub1Table.getRowCount());
-		assertEquals(1, ivSub1Sub1Table.getRowCount());
-
-		Object[] data = ivRootTable.select();
-		assertEquals(3, data.length);
-		assertTrue(data[0] instanceof Number);
-		assertTrue(((Number) data[0]).intValue() > 0);
-		assertEquals("XyZN", data[1]);
-		assertEquals("IvSub1Sub1", data[2]);
-
-		Object[] subdata = ivSub1Table.select();
-		assertEquals(2, subdata.length);
-		assertEquals(data[0], subdata[0]);
-		assertEquals("mDA", subdata[1]);
-
-		Object[] subsubdata = ivSub1Sub1Table.select();
-		assertEquals(2, subsubdata.length);
-		assertEquals(data[0], subsubdata[0]);
-		assertEquals("3DQa", subsubdata[1]);
-	}
-
-	public void testSelectQuery_SuperSub() throws Exception {
-
-		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
-		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(
-				Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
-
-		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
-		ivSub1Table.setColumns("ID", "SUB1_NAME");
-
-		// insert
-		ivRootTable.insert(1, "xROOT", null);
-		ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
-		ivSub1Table.insert(2, "xSUB1");
-
-		SelectQuery query = new SelectQuery(IvRoot.class);
-		List<IvRoot> results = context.performQuery(query);
-
-		assertEquals(2, results.size());
-
-		// since we don't have ordering, need to analyze results in an order
-		// agnostic
-		// fashion
-		Map<String, IvRoot> resultTypes = new HashMap<String, IvRoot>();
-
-		for (IvRoot result : results) {
-			resultTypes.put(result.getClass().getName(), result);
-		}
-
-		assertEquals(2, resultTypes.size());
-
-		IvRoot root = resultTypes.get(IvRoot.class.getName());
-		assertNotNull(root);
-		assertEquals("xROOT", root.getName());
-		assertNull(root.getDiscriminator());
-
-		IvSub1 sub1 = (IvSub1) resultTypes.get(IvSub1.class.getName());
-		assertNotNull(sub1);
-		assertEquals("xSUB1_ROOT", sub1.getName());
-		assertEquals("IvSub1", sub1.getDiscriminator());
-	}
-
-	public void testSelectQuery_DeepAndWide() throws Exception {
-
-		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
-		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(
-				Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
-
-		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
-		ivSub1Table.setColumns("ID", "SUB1_NAME");
-
-		TableHelper ivSub2Table = new TableHelper(dbHelper, "IV_SUB2");
-		ivSub2Table.setColumns("ID", "SUB2_NAME");
-
-		TableHelper ivSub1Sub1Table = new TableHelper(dbHelper, "IV_SUB1_SUB1");
-		ivSub1Sub1Table.setColumns("ID", "SUB1_SUB1_NAME");
-
-		// insert
-		ivRootTable.insert(1, "xROOT", null);
-
-		ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
-		ivSub1Table.insert(2, "xSUB1");
-
-		ivRootTable.insert(3, "xSUB1_SUB1_ROOT", "IvSub1Sub1");
-		ivSub1Table.insert(3, "xSUB1_SUB1_SUBROOT");
-		ivSub1Sub1Table.insert(3, "xSUB1_SUB1");
-
-		ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
-		ivSub2Table.insert(4, "xSUB2");
-
-		SelectQuery query = new SelectQuery(IvRoot.class);
-		List<IvRoot> results = context.performQuery(query);
-
-		assertEquals(4, results.size());
-
-		// since we don't have ordering, need to analyze results in an order
-		// agnostic
-		// fashion
-		Map<String, IvRoot> resultTypes = new HashMap<String, IvRoot>();
-
-		for (IvRoot result : results) {
-			resultTypes.put(result.getClass().getName(), result);
-		}
-
-		assertEquals(4, resultTypes.size());
-
-		IvRoot root = resultTypes.get(IvRoot.class.getName());
-		assertNotNull(root);
-		assertEquals("xROOT", root.getName());
-		assertNull(root.getDiscriminator());
-
-		IvSub1 sub1 = (IvSub1) resultTypes.get(IvSub1.class.getName());
-		assertNotNull(sub1);
-		assertEquals("xSUB1_ROOT", sub1.getName());
-		assertEquals("IvSub1", sub1.getDiscriminator());
-
-		IvSub1Sub1 sub1Sub1 = (IvSub1Sub1) resultTypes.get(IvSub1Sub1.class
-				.getName());
-		assertNotNull(sub1Sub1);
-		assertEquals("xSUB1_SUB1_ROOT", sub1Sub1.getName());
-		assertEquals("IvSub1Sub1", sub1Sub1.getDiscriminator());
-		assertEquals("xSUB1_SUB1_SUBROOT", sub1Sub1.getSub1Name());
-		assertEquals("xSUB1_SUB1", sub1Sub1.getSub1Sub1Name());
-
-		IvSub2 sub2 = (IvSub2) resultTypes.get(IvSub2.class.getName());
-		assertNotNull(sub2);
-		assertEquals("xROOT_SUB2", sub2.getName());
-		assertEquals("IvSub2", sub2.getDiscriminator());
-		assertEquals("xSUB2", sub2.getSub2Name());
-	}
-
-	public void testSelectQuery_MiddleLeaf() throws Exception {
-
-		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
-		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(
-				Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
-
-		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
-		ivSub1Table.setColumns("ID", "SUB1_NAME");
-
-		TableHelper ivSub2Table = new TableHelper(dbHelper, "IV_SUB2");
-		ivSub2Table.setColumns("ID", "SUB2_NAME");
-
-		TableHelper ivSub1Sub1Table = new TableHelper(dbHelper, "IV_SUB1_SUB1");
-		ivSub1Sub1Table.setColumns("ID", "SUB1_SUB1_NAME");
-
-		// insert
-		ivRootTable.insert(1, "xROOT", null);
-
-		ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
-		ivSub1Table.insert(2, "xSUB1");
-
-		ivRootTable.insert(3, "xSUB1_SUB1_ROOT", "IvSub1Sub1");
-		ivSub1Table.insert(3, "xSUB1_SUB1_SUBROOT");
-		ivSub1Sub1Table.insert(3, "xSUB1_SUB1");
-
-		ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
-		ivSub2Table.insert(4, "xSUB2");
-
-		SelectQuery query = new SelectQuery(IvSub1.class);
-		List<IvRoot> results = context.performQuery(query);
-
-		assertEquals(2, results.size());
-
-		// since we don't have ordering, need to analyze results in an order
-		// agnostic
-		// fashion
-		Map<String, IvRoot> resultTypes = new HashMap<String, IvRoot>();
-
-		for (IvRoot result : results) {
-			resultTypes.put(result.getClass().getName(), result);
-		}
-
-		assertEquals(2, resultTypes.size());
-
-		IvSub1 sub1 = (IvSub1) resultTypes.get(IvSub1.class.getName());
-		assertNotNull(sub1);
-		assertEquals("xSUB1_ROOT", sub1.getName());
-		assertEquals("IvSub1", sub1.getDiscriminator());
-
-		IvSub1Sub1 sub1Sub1 = (IvSub1Sub1) resultTypes.get(IvSub1Sub1.class
-				.getName());
-		assertNotNull(sub1Sub1);
-		assertEquals("xSUB1_SUB1_ROOT", sub1Sub1.getName());
-		assertEquals("IvSub1Sub1", sub1Sub1.getDiscriminator());
-		assertEquals("xSUB1_SUB1_SUBROOT", sub1Sub1.getSub1Name());
-		assertEquals("xSUB1_SUB1", sub1Sub1.getSub1Sub1Name());
-	}
-
-	public void testDelete_Mix() throws Exception {
-
-		TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
-		ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(
-				Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
-
-		TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
-		ivSub1Table.setColumns("ID", "SUB1_NAME");
-
-		TableHelper ivSub2Table = new TableHelper(dbHelper, "IV_SUB2");
-		ivSub2Table.setColumns("ID", "SUB2_NAME");
-
-		TableHelper ivSub1Sub1Table = new TableHelper(dbHelper, "IV_SUB1_SUB1");
-		ivSub1Sub1Table.setColumns("ID", "SUB1_SUB1_NAME");
-
-		// insert
-		ivRootTable.insert(1, "xROOT", null);
-
-		ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
-		ivSub1Table.insert(2, "xSUB1");
-
-		ivRootTable.insert(3, "xSUB1_SUB1_ROOT", "IvSub1Sub1");
-		ivSub1Table.insert(3, "xSUB1_SUB1_SUBROOT");
-		ivSub1Sub1Table.insert(3, "xSUB1_SUB1");
-
-		ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
-		ivSub2Table.insert(4, "xSUB2");
-
-		SelectQuery query = new SelectQuery(IvRoot.class);
-
-		List<IvRoot> results = context.performQuery(query);
-
-		assertEquals(4, results.size());
-		Map<String, IvRoot> resultTypes = new HashMap<String, IvRoot>();
-
-		for (IvRoot result : results) {
-			resultTypes.put(result.getClass().getName(), result);
-		}
-
-		assertEquals(4, resultTypes.size());
-
-		IvRoot root = resultTypes.get(IvRoot.class.getName());
-		context.deleteObjects(root);
-
-		IvSub1 sub1 = (IvSub1) resultTypes.get(IvSub1.class.getName());
-		context.deleteObjects(sub1);
-
-		context.commitChanges();
-
-		assertEquals(2, ivRootTable.getRowCount());
-		assertEquals(1, ivSub1Table.getRowCount());
-		assertEquals(1, ivSub1Sub1Table.getRowCount());
-		assertEquals(1, ivSub2Table.getRowCount());
-
-		results = context.performQuery(query);
-		assertEquals(2, results.size());
-	}
-
-	public void testSelectQuery_AttributeOverrides() throws Exception {
-
-		TableHelper iv1RootTable = new TableHelper(dbHelper, "IV1_ROOT");
-		iv1RootTable.setColumns("ID", "NAME", "DISCRIMINATOR").setColumnTypes(
-				Types.INTEGER, Types.VARCHAR, Types.VARCHAR);
-
-		TableHelper iv1Sub1Table = new TableHelper(dbHelper, "IV1_SUB1");
-		iv1Sub1Table.setColumns("ID", "SUB1_NAME");
-
-		// insert
-		iv1RootTable.insert(1, "xROOT", null);
-		iv1RootTable.insert(2, "xSUB1_ROOT", "Iv1Sub1");
-		iv1Sub1Table.insert(2, "xSUB1");
-
-		SelectQuery query = new SelectQuery(Iv1Root.class);
-		List<Iv1Root> results = context.performQuery(query);
-
-		assertEquals(2, results.size());
-
-		// since we don't have ordering, need to analyze results in an order
-		// agnostic
-		// fashion
-		Map<String, Iv1Root> resultTypes = new HashMap<String, Iv1Root>();
-
-		for (Iv1Root result : results) {
-			resultTypes.put(result.getClass().getName(), result);
-		}
-
-		assertEquals(2, resultTypes.size());
-
-		Iv1Root root = resultTypes.get(Iv1Root.class.getName());
-		assertNotNull(root);
-		assertEquals("xROOT", root.getName());
-		assertNull(root.getDiscriminator());
-
-		Iv1Sub1 sub1 = (Iv1Sub1) resultTypes.get(Iv1Sub1.class.getName());
-		assertNotNull(sub1);
-		assertEquals("xSUB1", sub1.getName());
-	}
-
-	public void testInsertWithRelationship() throws SQLException {
-		TableHelper xTable = new TableHelper(dbHelper, "IV2_X");
-		TableHelper rootTable = new TableHelper(dbHelper, "IV2_ROOT");
-		TableHelper sub1Table = new TableHelper(dbHelper, "IV2_SUB1");
-
-		assertEquals(0, xTable.getRowCount());
-		assertEquals(0, rootTable.getRowCount());
-		assertEquals(0, sub1Table.getRowCount());
-
-		Iv2Sub1 root = context.newObject(Iv2Sub1.class);
-		Iv2X x = context.newObject(Iv2X.class);
-		root.setX(x);
-
-		context.commitChanges();
-
-		assertEquals(1, xTable.getRowCount());
-		assertEquals(1, rootTable.getRowCount());
-		assertEquals(1, sub1Table.getRowCount());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyIT.java
new file mode 100644
index 0000000..fd8b118
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyIT.java
@@ -0,0 +1,346 @@
+/*****************************************************************
+ *   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.dbsync;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.MockOperationObserver;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.log.JdbcEventLogger;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.query.Query;
+import org.apache.cayenne.query.SQLTemplate;
+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.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+@UseServerRuntime(ServerCase.DEFAULT_PROJECT)
+public class SchemaUpdateStrategyIT extends ServerCase {
+
+    @Inject
+    private DataNode node;
+
+    @Inject
+    private DbAdapter adapter;
+    
+    @Inject
+    private ServerCaseDataSourceFactory dataSourceFactory;
+    
+    @Inject
+    private JdbcEventLogger jdbcEventLogger;
+
+    public void testDBGeneratorStrategy() throws Exception {
+
+        String template = "SELECT #result('id' 'int') FROM SUS1";
+        SQLTemplate query = new SQLTemplate(Object.class, template);
+
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
+        DataNode dataNode = createDataNode(map);
+        int sizeDB = getNameTablesInDB(dataNode).size();
+        MockOperationObserver observer = new MockOperationObserver();
+        try {
+
+            generateDBWithDBGeneratorStrategy(dataNode, query, observer);
+            int sizeDB2 = getNameTablesInDB(dataNode).size();
+            assertEquals(2, sizeDB2 - sizeDB);
+            dataNode.performQueries(Collections.singletonList((Query) query), observer);
+            int sizeDB3 = getNameTablesInDB(dataNode).size();
+            assertEquals(sizeDB2, sizeDB3);
+        }
+        finally {
+            DataNode dataNode2 = createDataNode(map);
+            dataNode2.setSchemaUpdateStrategy((SchemaUpdateStrategy) Class.forName(
+                    dataNode2.getSchemaUpdateStrategyName()).newInstance());
+            dropTables(map, dataNode2, observer);
+        }
+        assertEquals(getNameTablesInDB(dataNode).size(), sizeDB);
+    }
+
+    public void testThrowOnPartialStrategyTableNoExist() throws Exception {
+
+        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
+        SQLTemplate query = new SQLTemplate(Object.class, template);
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
+        MockOperationObserver observer = new MockOperationObserver();
+        DataNode dataNode = createDataNode(map);
+
+        setStrategy(ThrowOnPartialSchemaStrategy.class.getName(), dataNode);
+
+        try {
+            dataNode.performQueries(Collections.singletonList((Query) query), observer);
+        }
+        catch (CayenneRuntimeException e) {
+            assertNotNull(e);
+        }
+
+        try {
+            dataNode.performQueries(Collections.singletonList((Query) query), observer);
+        }
+        catch (CayenneRuntimeException e) {
+            assertNotNull(e);
+        }
+    }
+
+    public void testThrowOnPartialStrategyTableExist() throws Exception {
+        tableExistfForThrowOnPartialAndMixStrategy(ThrowOnPartialSchemaStrategy.class
+                .getName());
+    }
+
+    public void testThrowOnPartialStrategyWithOneTable() throws Exception {
+        withOneTableForThrowOnPartialAndMixStrategy(ThrowOnPartialSchemaStrategy.class
+                .getName());
+    }
+
+    public void testMixedStrategyTableNoExist() throws Exception {
+
+        String template = "SELECT #result('id' 'int') FROM SUS1";
+        SQLTemplate query = new SQLTemplate(Object.class, template);
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
+        DataNode dataNode = createDataNode(map);
+        int sizeDB = getNameTablesInDB(dataNode).size();
+        MockOperationObserver observer = new MockOperationObserver();
+
+        setStrategy(ThrowOnPartialOrCreateSchemaStrategy.class.getName(), dataNode);
+
+        try {
+            dataNode.performQueries(Collections.singletonList((Query) query), observer);
+            Map<String, Boolean> nameTables = getNameTablesInDB(dataNode);
+            assertTrue(nameTables.get("sus1") != null || nameTables.get("SUS1") != null);
+            int sizeDB2 = getNameTablesInDB(dataNode).size();
+            assertEquals(2, sizeDB2 - sizeDB);
+            dataNode.performQueries(Collections.singletonList((Query) query), observer);
+            int sizeDB3 = getNameTablesInDB(dataNode).size();
+            assertEquals(sizeDB2, sizeDB3);
+        }
+        finally {
+            DataNode dataNode2 = createDataNode(map);
+            dataNode2.setSchemaUpdateStrategy((SchemaUpdateStrategy) Class.forName(
+                    dataNode2.getSchemaUpdateStrategyName()).newInstance());
+            dropTables(map, dataNode2, observer);
+        }
+        assertEquals(getNameTablesInDB(dataNode).size(), sizeDB);
+
+    }
+
+    public void testMixedStrategyTableExist() throws Exception {
+        tableExistfForThrowOnPartialAndMixStrategy(ThrowOnPartialOrCreateSchemaStrategy.class
+                .getName());
+    }
+
+    public void testMixedStrategyWithOneTable() throws Exception {
+        withOneTableForThrowOnPartialAndMixStrategy(ThrowOnPartialOrCreateSchemaStrategy.class
+                .getName());
+    };
+
+    public void testNoStandartSchema() {
+        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
+        SQLTemplate query = new SQLTemplate(Object.class, template);
+        MockOperationObserver observer = new MockOperationObserver();
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
+        DataNode dataNode = createDataNode(map);
+
+        setStrategy(TstSchemaUpdateStrategy.class.getName(), dataNode);
+
+        dataNode.performQueries(Collections.singletonList((Query) query), observer);
+        assertTrue(dataNode.getSchemaUpdateStrategy() instanceof TstSchemaUpdateStrategy);
+    }
+
+    private void withOneTableForThrowOnPartialAndMixStrategy(String strategy) {
+        DbEntity entity = null;
+        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
+        SQLTemplate query = new SQLTemplate(Object.class, template);
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
+        MockOperationObserver observer = new MockOperationObserver();
+        DataNode dataNode = createDataNode(map);
+
+        DataNode dataNode2 = createDataNode(map);
+
+        try {
+
+            int sizeDB = getNameTablesInDB(dataNode).size();
+            entity = createOneTable(dataNode);
+            int sizeDB2 = getNameTablesInDB(dataNode).size();
+            assertEquals(1, sizeDB2 - sizeDB);
+            setStrategy(strategy, dataNode2);
+            dataNode2.performQueries(Collections.singletonList((Query) query), observer);
+
+        }
+        catch (CayenneRuntimeException e) {
+            assertNotNull(e);
+        }
+        try {
+            dataNode2.performQueries(Collections.singletonList((Query) query), observer);
+        }
+        catch (CayenneRuntimeException e) {
+            assertNotNull(e);
+        }
+        finally {
+
+            if (entity != null) {
+
+                Collection<String> template2 = dataNode.getAdapter().dropTableStatements(
+                        entity);
+                Iterator<String> it = template2.iterator();
+                List<Query> list = new ArrayList<Query>();
+                while (it.hasNext()) {
+                    SQLTemplate q = new SQLTemplate(Object.class, it.next());
+                    list.add(q);
+                }
+                dataNode.performQueries(list, observer);
+            }
+        }
+    }
+
+    private void tableExistfForThrowOnPartialAndMixStrategy(String strategy)
+            throws Exception {
+
+        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
+        SQLTemplate query = new SQLTemplate(Object.class, template);
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
+        MockOperationObserver observer = new MockOperationObserver();
+        DataNode dataNode = createDataNode(map);
+        int sizeDB = getNameTablesInDB(dataNode).size();
+        generateDBWithDBGeneratorStrategy(dataNode, query, observer);
+        int sizeDB2 = getNameTablesInDB(dataNode).size();
+        assertEquals(2, sizeDB2 - sizeDB);
+        try {
+            DataNode dataNode2 = createDataNode(map);
+            setStrategy(strategy, dataNode2);
+            dataNode2.performQueries(Collections.singletonList((Query) query), observer);
+        }
+        finally {
+            dropTables(map, dataNode, observer);
+        }
+
+    }
+
+    private DbEntity createOneTable(DataNode dataNode) {
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
+        Collection<DbEntity> ent = map.getDbEntities();
+        DbEntity entity = ent.iterator().next();
+        String template = dataNode.getAdapter().createTable(entity);
+
+        SQLTemplate query = new SQLTemplate(Object.class, template);
+        MockOperationObserver observer = new MockOperationObserver();
+
+        setStrategy(null, dataNode);
+
+        dataNode.performQueries(Collections.singletonList((Query) query), observer);
+        return entity;
+    }
+
+    private DataNode createDataNode(DataMap map) {
+        Collection<DataMap> colection = new ArrayList<DataMap>();
+        colection.add(map);
+        DataNode dataNode = new DataNode();
+        dataNode.setJdbcEventLogger(jdbcEventLogger);
+        dataNode.setDataMaps(colection);
+        dataNode.setAdapter(adapter);
+        dataNode.setDataSource(dataSourceFactory.getSharedDataSource());
+        dataNode.setDataSourceFactory(node.getDataSourceFactory());
+        dataNode.setSchemaUpdateStrategyName(node.getSchemaUpdateStrategyName());
+        dataNode.setRowReaderFactory(node.getRowReaderFactory());
+        dataNode.setBatchTranslatorFactory(node.getBatchTranslatorFactory());
+        dataNode.setEntityResolver(new EntityResolver(colection));
+        return dataNode;
+    }
+
+    private void generateDBWithDBGeneratorStrategy(
+            DataNode dataNode,
+            SQLTemplate query,
+            MockOperationObserver observer) {
+
+        setStrategy(CreateIfNoSchemaStrategy.class.getName(), dataNode);
+
+        dataNode.performQueries(Collections.singletonList((Query) query), observer);
+        Map<String, Boolean> nameTables = getNameTablesInDB(dataNode);
+        assertTrue(nameTables.get("sus1") != null || nameTables.get("SUS1") != null);
+
+    }
+
+    private void setStrategy(String name, DataNode dataNode) {
+        dataNode.setSchemaUpdateStrategyName(name);
+        try {
+            dataNode.setSchemaUpdateStrategy((SchemaUpdateStrategy) Class.forName(
+                    dataNode.getSchemaUpdateStrategyName()).newInstance());
+        }
+        catch (Exception e) {
+            throw new CayenneRuntimeException(e);
+        }
+    }
+
+    private void dropTables(DataMap map, DataNode dataNode, MockOperationObserver observer) {
+        Collection<DbEntity> ent = map.getDbEntities();
+        Iterator<DbEntity> iterator = ent.iterator();
+        while (iterator.hasNext()) {
+            Collection<String> collectionDrop = dataNode
+                    .getAdapter()
+                    .dropTableStatements(iterator.next());
+            for (String s : collectionDrop) {
+                SQLTemplate queryDrop = new SQLTemplate(Object.class, s);
+                dataNode.performQueries(
+                        Collections.singletonList((Query) queryDrop),
+                        observer);
+            }
+        }
+    }
+
+    private Map<String, Boolean> getNameTablesInDB(DataNode dataNode) {
+        String tableLabel = dataNode.getAdapter().tableTypeForTable();
+        Connection con = null;
+        Map<String, Boolean> nameTables = new HashMap<String, Boolean>();
+        try {
+            con = dataNode.getDataSource().getConnection();
+            ResultSet rs = con.getMetaData().getTables(null, null, "%", new String[] {
+                tableLabel
+            });
+            while (rs.next()) {
+                String name = rs.getString("TABLE_NAME");
+                nameTables.put(name, false);
+            }
+            rs.close();
+        }
+        catch (SQLException e) {
+            throw new CayenneRuntimeException(e);
+        }
+        finally {
+            try {
+                con.close();
+            }
+            catch (SQLException e) {
+                throw new CayenneRuntimeException(e);
+            }
+        }
+        return nameTables;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
deleted file mode 100644
index 1697cca..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
+++ /dev/null
@@ -1,346 +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.dbsync;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.MockOperationObserver;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.log.JdbcEventLogger;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.query.Query;
-import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.DEFAULT_PROJECT)
-public class SchemaUpdateStrategyTest extends ServerCase {
-
-    @Inject
-    private DataNode node;
-
-    @Inject
-    private DbAdapter adapter;
-    
-    @Inject
-    private ServerCaseDataSourceFactory dataSourceFactory;
-    
-    @Inject
-    private JdbcEventLogger jdbcEventLogger;
-
-    public void testDBGeneratorStrategy() throws Exception {
-
-        String template = "SELECT #result('id' 'int') FROM SUS1";
-        SQLTemplate query = new SQLTemplate(Object.class, template);
-
-        DataMap map = node.getEntityResolver().getDataMap("sus-map");
-        DataNode dataNode = createDataNode(map);
-        int sizeDB = getNameTablesInDB(dataNode).size();
-        MockOperationObserver observer = new MockOperationObserver();
-        try {
-
-            generateDBWithDBGeneratorStrategy(dataNode, query, observer);
-            int sizeDB2 = getNameTablesInDB(dataNode).size();
-            assertEquals(2, sizeDB2 - sizeDB);
-            dataNode.performQueries(Collections.singletonList((Query) query), observer);
-            int sizeDB3 = getNameTablesInDB(dataNode).size();
-            assertEquals(sizeDB2, sizeDB3);
-        }
-        finally {
-            DataNode dataNode2 = createDataNode(map);
-            dataNode2.setSchemaUpdateStrategy((SchemaUpdateStrategy) Class.forName(
-                    dataNode2.getSchemaUpdateStrategyName()).newInstance());
-            dropTables(map, dataNode2, observer);
-        }
-        assertEquals(getNameTablesInDB(dataNode).size(), sizeDB);
-    }
-
-    public void testThrowOnPartialStrategyTableNoExist() throws Exception {
-
-        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = new SQLTemplate(Object.class, template);
-        DataMap map = node.getEntityResolver().getDataMap("sus-map");
-        MockOperationObserver observer = new MockOperationObserver();
-        DataNode dataNode = createDataNode(map);
-
-        setStrategy(ThrowOnPartialSchemaStrategy.class.getName(), dataNode);
-
-        try {
-            dataNode.performQueries(Collections.singletonList((Query) query), observer);
-        }
-        catch (CayenneRuntimeException e) {
-            assertNotNull(e);
-        }
-
-        try {
-            dataNode.performQueries(Collections.singletonList((Query) query), observer);
-        }
-        catch (CayenneRuntimeException e) {
-            assertNotNull(e);
-        }
-    }
-
-    public void testThrowOnPartialStrategyTableExist() throws Exception {
-        tableExistfForThrowOnPartialAndMixStrategy(ThrowOnPartialSchemaStrategy.class
-                .getName());
-    }
-
-    public void testThrowOnPartialStrategyWithOneTable() throws Exception {
-        withOneTableForThrowOnPartialAndMixStrategy(ThrowOnPartialSchemaStrategy.class
-                .getName());
-    }
-
-    public void testMixedStrategyTableNoExist() throws Exception {
-
-        String template = "SELECT #result('id' 'int') FROM SUS1";
-        SQLTemplate query = new SQLTemplate(Object.class, template);
-        DataMap map = node.getEntityResolver().getDataMap("sus-map");
-        DataNode dataNode = createDataNode(map);
-        int sizeDB = getNameTablesInDB(dataNode).size();
-        MockOperationObserver observer = new MockOperationObserver();
-
-        setStrategy(ThrowOnPartialOrCreateSchemaStrategy.class.getName(), dataNode);
-
-        try {
-            dataNode.performQueries(Collections.singletonList((Query) query), observer);
-            Map<String, Boolean> nameTables = getNameTablesInDB(dataNode);
-            assertTrue(nameTables.get("sus1") != null || nameTables.get("SUS1") != null);
-            int sizeDB2 = getNameTablesInDB(dataNode).size();
-            assertEquals(2, sizeDB2 - sizeDB);
-            dataNode.performQueries(Collections.singletonList((Query) query), observer);
-            int sizeDB3 = getNameTablesInDB(dataNode).size();
-            assertEquals(sizeDB2, sizeDB3);
-        }
-        finally {
-            DataNode dataNode2 = createDataNode(map);
-            dataNode2.setSchemaUpdateStrategy((SchemaUpdateStrategy) Class.forName(
-                    dataNode2.getSchemaUpdateStrategyName()).newInstance());
-            dropTables(map, dataNode2, observer);
-        }
-        assertEquals(getNameTablesInDB(dataNode).size(), sizeDB);
-
-    }
-
-    public void testMixedStrategyTableExist() throws Exception {
-        tableExistfForThrowOnPartialAndMixStrategy(ThrowOnPartialOrCreateSchemaStrategy.class
-                .getName());
-    }
-
-    public void testMixedStrategyWithOneTable() throws Exception {
-        withOneTableForThrowOnPartialAndMixStrategy(ThrowOnPartialOrCreateSchemaStrategy.class
-                .getName());
-    };
-
-    public void testNoStandartSchema() {
-        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = new SQLTemplate(Object.class, template);
-        MockOperationObserver observer = new MockOperationObserver();
-        DataMap map = node.getEntityResolver().getDataMap("sus-map");
-        DataNode dataNode = createDataNode(map);
-
-        setStrategy(TstSchemaUpdateStrategy.class.getName(), dataNode);
-
-        dataNode.performQueries(Collections.singletonList((Query) query), observer);
-        assertTrue(dataNode.getSchemaUpdateStrategy() instanceof TstSchemaUpdateStrategy);
-    }
-
-    private void withOneTableForThrowOnPartialAndMixStrategy(String strategy) {
-        DbEntity entity = null;
-        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = new SQLTemplate(Object.class, template);
-        DataMap map = node.getEntityResolver().getDataMap("sus-map");
-        MockOperationObserver observer = new MockOperationObserver();
-        DataNode dataNode = createDataNode(map);
-
-        DataNode dataNode2 = createDataNode(map);
-
-        try {
-
-            int sizeDB = getNameTablesInDB(dataNode).size();
-            entity = createOneTable(dataNode);
-            int sizeDB2 = getNameTablesInDB(dataNode).size();
-            assertEquals(1, sizeDB2 - sizeDB);
-            setStrategy(strategy, dataNode2);
-            dataNode2.performQueries(Collections.singletonList((Query) query), observer);
-
-        }
-        catch (CayenneRuntimeException e) {
-            assertNotNull(e);
-        }
-        try {
-            dataNode2.performQueries(Collections.singletonList((Query) query), observer);
-        }
-        catch (CayenneRuntimeException e) {
-            assertNotNull(e);
-        }
-        finally {
-
-            if (entity != null) {
-
-                Collection<String> template2 = dataNode.getAdapter().dropTableStatements(
-                        entity);
-                Iterator<String> it = template2.iterator();
-                List<Query> list = new ArrayList<Query>();
-                while (it.hasNext()) {
-                    SQLTemplate q = new SQLTemplate(Object.class, it.next());
-                    list.add(q);
-                }
-                dataNode.performQueries(list, observer);
-            }
-        }
-    }
-
-    private void tableExistfForThrowOnPartialAndMixStrategy(String strategy)
-            throws Exception {
-
-        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = new SQLTemplate(Object.class, template);
-        DataMap map = node.getEntityResolver().getDataMap("sus-map");
-        MockOperationObserver observer = new MockOperationObserver();
-        DataNode dataNode = createDataNode(map);
-        int sizeDB = getNameTablesInDB(dataNode).size();
-        generateDBWithDBGeneratorStrategy(dataNode, query, observer);
-        int sizeDB2 = getNameTablesInDB(dataNode).size();
-        assertEquals(2, sizeDB2 - sizeDB);
-        try {
-            DataNode dataNode2 = createDataNode(map);
-            setStrategy(strategy, dataNode2);
-            dataNode2.performQueries(Collections.singletonList((Query) query), observer);
-        }
-        finally {
-            dropTables(map, dataNode, observer);
-        }
-
-    }
-
-    private DbEntity createOneTable(DataNode dataNode) {
-        DataMap map = node.getEntityResolver().getDataMap("sus-map");
-        Collection<DbEntity> ent = map.getDbEntities();
-        DbEntity entity = ent.iterator().next();
-        String template = dataNode.getAdapter().createTable(entity);
-
-        SQLTemplate query = new SQLTemplate(Object.class, template);
-        MockOperationObserver observer = new MockOperationObserver();
-
-        setStrategy(null, dataNode);
-
-        dataNode.performQueries(Collections.singletonList((Query) query), observer);
-        return entity;
-    }
-
-    private DataNode createDataNode(DataMap map) {
-        Collection<DataMap> colection = new ArrayList<DataMap>();
-        colection.add(map);
-        DataNode dataNode = new DataNode();
-        dataNode.setJdbcEventLogger(jdbcEventLogger);
-        dataNode.setDataMaps(colection);
-        dataNode.setAdapter(adapter);
-        dataNode.setDataSource(dataSourceFactory.getSharedDataSource());
-        dataNode.setDataSourceFactory(node.getDataSourceFactory());
-        dataNode.setSchemaUpdateStrategyName(node.getSchemaUpdateStrategyName());
-        dataNode.setRowReaderFactory(node.getRowReaderFactory());
-        dataNode.setBatchTranslatorFactory(node.getBatchTranslatorFactory());
-        dataNode.setEntityResolver(new EntityResolver(colection));
-        return dataNode;
-    }
-
-    private void generateDBWithDBGeneratorStrategy(
-            DataNode dataNode,
-            SQLTemplate query,
-            MockOperationObserver observer) {
-
-        setStrategy(CreateIfNoSchemaStrategy.class.getName(), dataNode);
-
-        dataNode.performQueries(Collections.singletonList((Query) query), observer);
-        Map<String, Boolean> nameTables = getNameTablesInDB(dataNode);
-        assertTrue(nameTables.get("sus1") != null || nameTables.get("SUS1") != null);
-
-    }
-
-    private void setStrategy(String name, DataNode dataNode) {
-        dataNode.setSchemaUpdateStrategyName(name);
-        try {
-            dataNode.setSchemaUpdateStrategy((SchemaUpdateStrategy) Class.forName(
-                    dataNode.getSchemaUpdateStrategyName()).newInstance());
-        }
-        catch (Exception e) {
-            throw new CayenneRuntimeException(e);
-        }
-    }
-
-    private void dropTables(DataMap map, DataNode dataNode, MockOperationObserver observer) {
-        Collection<DbEntity> ent = map.getDbEntities();
-        Iterator<DbEntity> iterator = ent.iterator();
-        while (iterator.hasNext()) {
-            Collection<String> collectionDrop = dataNode
-                    .getAdapter()
-                    .dropTableStatements(iterator.next());
-            for (String s : collectionDrop) {
-                SQLTemplate queryDrop = new SQLTemplate(Object.class, s);
-                dataNode.performQueries(
-                        Collections.singletonList((Query) queryDrop),
-                        observer);
-            }
-        }
-    }
-
-    private Map<String, Boolean> getNameTablesInDB(DataNode dataNode) {
-        String tableLabel = dataNode.getAdapter().tableTypeForTable();
-        Connection con = null;
-        Map<String, Boolean> nameTables = new HashMap<String, Boolean>();
-        try {
-            con = dataNode.getDataSource().getConnection();
-            ResultSet rs = con.getMetaData().getTables(null, null, "%", new String[] {
-                tableLabel
-            });
-            while (rs.next()) {
-                String name = rs.getString("TABLE_NAME");
-                nameTables.put(name, false);
-            }
-            rs.close();
-        }
-        catch (SQLException e) {
-            throw new CayenneRuntimeException(e);
-        }
-        finally {
-            try {
-                con.close();
-            }
-            catch (SQLException e) {
-                throw new CayenneRuntimeException(e);
-            }
-        }
-        return nameTables;
-    }
-}


Mime
View raw message