http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/dbimport/FiltersConfigBuilderTest.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/dbimport/FiltersConfigBuilderTest.java
 
b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/FiltersConfigBuilderTest.java
deleted file mode 100644
index 9a94618..0000000
--- 
a/cayenne-server/src/test/java/org/apache/cayenne/dbimport/FiltersConfigBuilderTest.java
+++ /dev/null
@@ -1,382 +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.dbimport;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class FiltersConfigBuilderTest {
-
-    @Test
-    public void testCompact_01() {
-        ReverseEngineering engineering = new ReverseEngineering();
-        engineering.addIncludeTable(new IncludeTable("table1"));
-        engineering.addIncludeTable(new IncludeTable("table2"));
-        engineering.addIncludeTable(new IncludeTable("table3"));
-
-        engineering.addIncludeColumn(new IncludeColumn("includeColumn"));
-
-        FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
-        builder.compact();
-        assertEquals(
-                "ReverseEngineering: \n" +
-                "  Catalog: null\n" +
-                "    Schema: null\n" +
-                "      IncludeTable: table1\n" +
-                "        IncludeColumn: includeColumn\n" +
-                "      IncludeTable: table2\n" +
-                "        IncludeColumn: includeColumn\n" +
-                "      IncludeTable: table3\n" +
-                "        IncludeColumn: includeColumn\n", 
engineering.toString());
-    }
-
-    @Test
-    public void testCompact_02() {
-        ReverseEngineering engineering = new ReverseEngineering();
-        engineering.addCatalog(new Catalog("catalogName"));
-        engineering.addSchema(new Schema("schemaName01"));
-        engineering.addSchema(new Schema("schemaName02"));
-
-        engineering.addIncludeTable(new IncludeTable("table1"));
-        engineering.addExcludeTable(new ExcludeTable("table2"));
-
-        engineering.addIncludeColumn(new IncludeColumn("includeColumn"));
-
-        FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
-        builder.compact();
-        assertEquals(
-                "ReverseEngineering: \n" +
-                "  Catalog: catalogName\n" +
-                "    Schema: schemaName01\n" +
-                "      IncludeTable: table1\n" +
-                "        IncludeColumn: includeColumn\n" +
-                "      ExcludeTable: table2\n" +
-                "    Schema: schemaName02\n" +
-                "      IncludeTable: table1\n" +
-                "        IncludeColumn: includeColumn\n" +
-                "      ExcludeTable: table2\n", engineering.toString());
-    }
-
-    @Test
-    public void testCompact_03() {
-        ReverseEngineering engineering = new ReverseEngineering();
-        engineering.addCatalog(new Catalog("APP1"));
-        engineering.addCatalog(new Catalog("APP2"));
-
-        engineering.addExcludeTable(new ExcludeTable("SYS_.*"));
-        engineering.addExcludeColumn(new ExcludeColumn("calculated_.*"));
-
-        FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
-        builder.compact();
-        assertEquals(
-                "ReverseEngineering: \n" +
-                "  Catalog: APP1\n" +
-                "    Schema: null\n" +
-                "      IncludeTable: null\n" +
-                "        ExcludeColumn: calculated_.*\n" +
-                "      ExcludeTable: SYS_.*\n" +
-                "  Catalog: APP2\n" +
-                "    Schema: null\n" +
-                "      IncludeTable: null\n" +
-                "        ExcludeColumn: calculated_.*\n" +
-                "      ExcludeTable: SYS_.*\n", engineering.toString());
-    }
-
-    @Test
-    public void testCompact_04() {
-        ReverseEngineering engineering = new ReverseEngineering();
-        engineering.addSchema(new Schema("s"));
-
-        FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
-        builder.compact();
-        assertEquals(
-                "ReverseEngineering: \n" +
-                "  Catalog: null\n" +
-                "    Schema: s\n" +
-                "      IncludeTable: null\n", engineering.toString());
-    }
-
-    @Test
-    public void testCompact_full() {
-        ReverseEngineering engineering = new ReverseEngineering();
-        Catalog cat01 = new Catalog("cat_01");
-
-        Schema sch01 = new Schema("sch_01");
-
-        sch01.addIncludeTable(includeTable("t1", "c11", "c12"));
-        sch01.addExcludeTable(new ExcludeTable("t2"));
-        sch01.addIncludeProcedure(new IncludeProcedure("p1"));
-        sch01.addExcludeProcedure(new ExcludeProcedure("p2"));
-        sch01.addIncludeColumn(new IncludeColumn("c_x1"));
-        sch01.addExcludeColumn(new ExcludeColumn("c_x2"));
-
-        cat01.addSchema(sch01);
-
-        cat01.addIncludeTable(includeTable("t3", "c31", "c32"));
-        cat01.addExcludeTable(new ExcludeTable("t4"));
-        cat01.addIncludeProcedure(new IncludeProcedure("p3"));
-        cat01.addExcludeProcedure(new ExcludeProcedure("p4"));
-        cat01.addIncludeColumn(new IncludeColumn("c_xx1"));
-        cat01.addExcludeColumn(new ExcludeColumn("c_xx2"));
-
-        engineering.addCatalog(cat01);
-
-        Schema sch02 = new Schema("sch_02");
-
-        sch02.addIncludeTable(includeTable("t5", "c51", "c52"));
-        sch02.addExcludeTable(new ExcludeTable("t6"));
-        sch02.addIncludeProcedure(new IncludeProcedure("p5"));
-        sch02.addExcludeProcedure(new ExcludeProcedure("p6"));
-        sch02.addIncludeColumn(new IncludeColumn("c2_x1"));
-        sch02.addExcludeColumn(new ExcludeColumn("c2_x2"));
-
-        engineering.addSchema(sch02);
-
-        engineering.addIncludeTable(includeTable("t7", "c71", "c72"));
-        engineering.addExcludeTable(new ExcludeTable("t8"));
-        engineering.addIncludeProcedure(new IncludeProcedure("p7"));
-        engineering.addExcludeProcedure(new ExcludeProcedure("p8"));
-        engineering.addIncludeColumn(new IncludeColumn("c_xxx1"));
-        engineering.addExcludeColumn(new ExcludeColumn("c_xxx2"));
-
-        FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
-        assertEquals("Original ReverseEngineering should be",
-                "ReverseEngineering: \n" +
-                "  Catalog: cat_01\n" +
-                "    Schema: sch_01\n" +
-                "      IncludeTable: t1\n" +
-                "        IncludeColumn: c11\n" +
-                "        ExcludeColumn: c12\n" +
-                "      ExcludeTable: t2\n" +
-                "      IncludeColumn: c_x1\n" +
-                "      ExcludeColumn: c_x2\n" +
-                "      IncludeProcedure: p1\n" +
-                "      ExcludeProcedure: p2\n" +
-                "    IncludeTable: t3\n" +
-                "      IncludeColumn: c31\n" +
-                "      ExcludeColumn: c32\n" +
-                "    ExcludeTable: t4\n" +
-                "    IncludeColumn: c_xx1\n" +
-                "    ExcludeColumn: c_xx2\n" +
-                "    IncludeProcedure: p3\n" +
-                "    ExcludeProcedure: p4\n" +
-                "  Schema: sch_02\n" +
-                "    IncludeTable: t5\n" +
-                "      IncludeColumn: c51\n" +
-                "      ExcludeColumn: c52\n" +
-                "    ExcludeTable: t6\n" +
-                "    IncludeColumn: c2_x1\n" +
-                "    ExcludeColumn: c2_x2\n" +
-                "    IncludeProcedure: p5\n" +
-                "    ExcludeProcedure: p6\n" +
-                "  IncludeTable: t7\n" +
-                "    IncludeColumn: c71\n" +
-                "    ExcludeColumn: c72\n" +
-                "  ExcludeTable: t8\n" +
-                "  IncludeColumn: c_xxx1\n" +
-                "  ExcludeColumn: c_xxx2\n" +
-                "  IncludeProcedure: p7\n" +
-                "  ExcludeProcedure: p8\n", engineering.toString());
-
-
-        builder.compact();
-        assertEquals(
-                "ReverseEngineering: \n" +
-                        "  Catalog: cat_01\n" +
-                        "    Schema: sch_01\n" +
-                        "      IncludeTable: t1\n" +
-                        "        IncludeColumn: c11\n" +
-                        "        IncludeColumn: c_xxx1\n" +
-                        "        IncludeColumn: c_xx1\n" +
-                        "        IncludeColumn: c_x1\n" +
-                        "        ExcludeColumn: c12\n" +
-                        "        ExcludeColumn: c_xxx2\n" +
-                        "        ExcludeColumn: c_xx2\n" +
-                        "        ExcludeColumn: c_x2\n" +
-                        "      IncludeTable: t7\n" +
-                        "        IncludeColumn: c71\n" +
-                        "        IncludeColumn: c_xxx1\n" +
-                        "        ExcludeColumn: c72\n" +
-                        "        ExcludeColumn: c_xxx2\n" +
-                        "      IncludeTable: t3\n" +
-                        "        IncludeColumn: c31\n" +
-                        "        IncludeColumn: c_xxx1\n" +
-                        "        IncludeColumn: c_xx1\n" +
-                        "        ExcludeColumn: c32\n" +
-                        "        ExcludeColumn: c_xxx2\n" +
-                        "        ExcludeColumn: c_xx2\n" +
-                        "      ExcludeTable: t2\n" +
-                        "      ExcludeTable: t8\n" +
-                        "      ExcludeTable: t4\n" +
-                        "      IncludeProcedure: p1\n" +
-                        "      IncludeProcedure: p7\n" +
-                        "      IncludeProcedure: p3\n" +
-                        "      ExcludeProcedure: p2\n" +
-                        "      ExcludeProcedure: p8\n" +
-                        "      ExcludeProcedure: p4\n" +
-                        "    Schema: sch_02\n" +
-                        "      IncludeTable: t5\n" +
-                        "        IncludeColumn: c51\n" +
-                        "        IncludeColumn: c_xxx1\n" +
-                        "        IncludeColumn: c2_x1\n" +
-                        "        ExcludeColumn: c52\n" +
-                        "        ExcludeColumn: c_xxx2\n" +
-                        "        ExcludeColumn: c2_x2\n" +
-                        "      IncludeTable: t7\n" +
-                        "        IncludeColumn: c71\n" +
-                        "        IncludeColumn: c_xxx1\n" +
-                        "        ExcludeColumn: c72\n" +
-                        "        ExcludeColumn: c_xxx2\n" +
-                        "      ExcludeTable: t6\n" +
-                        "      ExcludeTable: t8\n" +
-                        "      IncludeProcedure: p5\n" +
-                        "      IncludeProcedure: p7\n" +
-                        "      ExcludeProcedure: p6\n" +
-                        "      ExcludeProcedure: p8\n", 
engineering.toString());
-    }
-
-    protected IncludeTable includeTable(String name, String incCol, String 
excCol) {
-        IncludeTable incTable01 = new IncludeTable(name);
-        incTable01.addIncludeColumn(new IncludeColumn(incCol));
-        incTable01.addExcludeColumn(new ExcludeColumn(excCol));
-        return incTable01;
-    }
-
-    /*@Test
-    public void testEmptyDbEntitiesFilters() throws Exception {
-        ReverseEngineering engineering = new ReverseEngineering();
-        FiltersConfig executions = new 
FiltersConfigBuilder(engineering).filtersConfig();
-
-        assertEquals("If nothing was configured we have to import everything. 
Filter %/%/% true/true/true",
-                new FiltersConfig(eFilters(path(), TRUE, TRUE, NULL)),
-                executions);
-    }
-
-    @Test
-    public void testOnlyOneCatalogDbEntitiesFilters() throws Exception {
-        ReverseEngineering engineering = new ReverseEngineering();
-        engineering.addCatalog(new Catalog("catalog_01"));
-        FiltersConfig executions = new 
FiltersConfigBuilder(engineering).filtersConfig();
-
-
-        assertEquals(new FiltersConfig(eFilters(path("catalog_01", null), 
TRUE, TRUE, NULL)),
-                executions);
-    }
-
-    @Test
-    public void testCatalogDbEntitiesFilters() throws Exception {
-        ReverseEngineering engineering = new ReverseEngineering();
-        engineering.addCatalog(new Catalog("catalog_01"));
-        engineering.addCatalog(new Catalog("catalog_02").schema(new 
Schema("schema_01")));
-        engineering.addCatalog(new Catalog("catalog_02").schema(new 
Schema("schema_02")));
-        engineering.addCatalog(new Catalog("catalog_02").schema(new 
Schema("schema_03")));
-        engineering.addCatalog(new Catalog("catalog_03").schema(new 
Schema("schema_01")));
-        engineering.addCatalog(new Catalog("catalog_03").schema(new 
Schema("schema_01")));
-        engineering.addCatalog(new Catalog("catalog_03").schema(new 
Schema("schema_01")));
-        engineering.addCatalog(new Catalog("catalog_03").schema(new 
Schema("schema_01")));
-        FiltersConfig executions = new 
FiltersConfigBuilder(engineering).filtersConfig();
-
-
-        assertEquals(new FiltersConfig(
-                        eFilters(path("catalog_01", null), TRUE, TRUE, NULL),
-                        eFilters(path("catalog_02", "schema_01"), TRUE, TRUE, 
NULL),
-                        eFilters(path("catalog_02", "schema_02"), TRUE, TRUE, 
NULL),
-                        eFilters(path("catalog_02", "schema_03"), TRUE, TRUE, 
NULL),
-                        eFilters(path("catalog_03", "schema_01"), TRUE, TRUE, 
NULL)
-                ),
-                executions);
-    }
-
-    @Test
-    public void testSchemaDbEntitiesFilters() throws Exception {
-        ReverseEngineering engineering = new ReverseEngineering();
-        engineering.addSchema(new Schema("schema_01"));
-        engineering.addSchema(new Schema("schema_02"));
-        engineering.addSchema(new Schema("schema_03"));
-        FiltersConfig executions = new 
FiltersConfigBuilder(engineering).filtersConfig();
-
-
-        assertEquals(new FiltersConfig(
-                        eFilters(path(null, "schema_01"), TRUE, TRUE, NULL),
-                        eFilters(path(null, "schema_02"), TRUE, TRUE, NULL),
-                        eFilters(path(null, "schema_03"), TRUE, TRUE, NULL)
-                ),
-                executions);
-    }
-
-    @Test
-    public void testFiltersDbEntitiesFilters() throws Exception {
-        ReverseEngineering engineering = new ReverseEngineering();
-        engineering.addIncludeTable(new IncludeTable("IncludeTable"));
-        engineering.addIncludeColumn(new IncludeColumn("IncludeColumn"));
-        engineering.addIncludeProcedure(new 
IncludeProcedure("IncludeProcedure"));
-        engineering.addExcludeTable(new ExcludeTable("ExcludeTable"));
-        engineering.addExcludeColumn(new ExcludeColumn("ExcludeColumn"));
-        engineering.addExcludeProcedure(new 
ExcludeProcedure("ExcludeProcedure"));
-
-        FiltersConfig executions = new 
FiltersConfigBuilder(engineering).filtersConfig();
-
-        assertEquals(new FiltersConfig(
-                        eFilters(path(),
-                            list(include("IncludeTable"), 
exclude("ExcludeTable")),
-                            list(include("IncludeColumn"), 
exclude("ExcludeColumn")),
-                            list(include("IncludeProcedure"), 
exclude("ExcludeProcedure"))),
-                        eFilters(path(null, null, "IncludeTable"), NULL, TRUE, 
NULL)
-                ),
-                executions);
-    }
-
-    @Test
-    public void testComplexConfiguration() throws Exception {
-        IncludeTable table = new IncludeTable("table");
-        table.addIncludeColumn(new IncludeColumn("column"));
-
-        Schema schema = new Schema("schema");
-        schema.addIncludeTable(table);
-
-        Catalog catalog = new Catalog("catalog");
-        catalog.addSchema(schema);
-
-        ReverseEngineering engineering = new ReverseEngineering();
-        engineering.addCatalog(catalog);
-
-        FiltersConfig executions = new 
FiltersConfigBuilder(engineering).filtersConfig();
-
-        assertEquals(new FiltersConfig(
-                        eFilters(path("catalog", "schema"), include("table"), 
NULL, NULL),
-                        eFilters(path("catalog", "schema", "table"), NULL, 
include("column"), NULL)
-                        ),
-                executions);
-    }
-
-    @Test
-    public void testAddNull() throws Exception {
-        FiltersConfigBuilder builder = new FiltersConfigBuilder(new 
ReverseEngineering());
-        DbPath path = new DbPath();
-        builder.add(new EntityFilters(path, NULL, NULL, NULL));
-        builder.add(new EntityFilters(path, NULL, NULL, NULL));
-        builder.add(new EntityFilters(path, NULL, NULL, NULL));
-        builder.add(new EntityFilters(path, NULL, NULL, NULL));
-
-        EntityFilters filter = builder.filtersConfig().filter(path);
-        assertFalse(filter.isEmpty());
-    }*/
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/AddColumnToModelIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/AddColumnToModelIT.java 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/AddColumnToModelIT.java
deleted file mode 100644
index db60769..0000000
--- 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/AddColumnToModelIT.java
+++ /dev/null
@@ -1,98 +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.merge;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Types;
-import java.util.List;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.junit.Test;
-
-public class AddColumnToModelIT extends MergeCase {
-
-    @Test
-    public void testAddColumn() throws Exception {
-        dropTableIfPresent("NEW_TABLE");
-        assertTokensAndExecute(0, 0);
-
-        DbEntity dbEntity = new DbEntity("NEW_TABLE");
-
-        DbAttribute column1 = new DbAttribute("ID", Types.INTEGER, dbEntity);
-        column1.setMandatory(true);
-        column1.setPrimaryKey(true);
-        dbEntity.addAttribute(column1);
-
-        DbAttribute column2 = new DbAttribute("NAME", Types.VARCHAR, dbEntity);
-        column2.setMaxLength(10);
-        column2.setMandatory(false);
-        dbEntity.addAttribute(column2);
-
-        map.addDbEntity(dbEntity);
-
-        assertTokensAndExecute(1, 0);
-        assertTokensAndExecute(0, 0);
-
-        ObjEntity objEntity = new ObjEntity("NewTable");
-        objEntity.setDbEntity(dbEntity);
-        ObjAttribute oatr1 = new ObjAttribute("name");
-        oatr1.setDbAttributePath(column2.getName());
-        oatr1.setType("java.lang.String");
-        objEntity.addAttribute(oatr1);
-        map.addObjEntity(objEntity);
-
-        // remove name column
-        objEntity.removeAttribute(oatr1.getName());
-        dbEntity.removeAttribute(column2.getName());
-        assertNull(objEntity.getAttribute(oatr1.getName()));
-        assertEquals(0, objEntity.getAttributes().size());
-        assertNull(dbEntity.getAttribute(column2.getName()));
-
-        List<MergerToken> tokens = createMergeTokens();
-        assertEquals(1, tokens.size());
-        MergerToken token = tokens.get(0);
-        if (token.getDirection().isToDb()) {
-            token = token.createReverse(mergerFactory());
-        }
-        assertTrue(token instanceof AddColumnToModel);
-        execute(token);
-        assertEquals(1, objEntity.getAttributes().size());
-        assertEquals("java.lang.String", objEntity.getAttributes().iterator()
-                .next().getType());
-
-        // clear up
-        map.removeObjEntity(objEntity.getName(), true);
-        map.removeDbEntity(dbEntity.getName(), true);
-        resolver.refreshMappingCache();
-        assertNull(map.getObjEntity(objEntity.getName()));
-        assertNull(map.getDbEntity(dbEntity.getName()));
-        assertFalse(map.getDbEntities().contains(dbEntity));
-
-        assertTokensAndExecute(1, 0);
-        assertTokensAndExecute(0, 0);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/CreateTableToModelIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/CreateTableToModelIT.java
 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/CreateTableToModelIT.java
deleted file mode 100644
index 3d14c1d..0000000
--- 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/CreateTableToModelIT.java
+++ /dev/null
@@ -1,97 +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.merge;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Types;
-import java.util.List;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.ObjEntity;
-import org.junit.Test;
-
-public class CreateTableToModelIT extends MergeCase {
-
-       @Test
-       public void testAddTable() throws Exception {
-               dropTableIfPresent("NEW_TABLE");
-               assertTokensAndExecute(0, 0);
-
-               DbEntity dbEntity = new DbEntity("NEW_TABLE");
-
-               DbAttribute column1 = new DbAttribute("ID", Types.INTEGER, 
dbEntity);
-               column1.setMandatory(true);
-               column1.setPrimaryKey(true);
-               dbEntity.addAttribute(column1);
-
-               DbAttribute column2 = new DbAttribute("NAME", Types.VARCHAR, 
dbEntity);
-               column2.setMaxLength(10);
-               column2.setMandatory(false);
-               dbEntity.addAttribute(column2);
-
-               // for the new entity to the db
-               execute(mergerFactory().createCreateTableToDb(dbEntity));
-
-               List<MergerToken> tokens = createMergeTokens();
-               assertEquals(1, tokens.size());
-               MergerToken token = tokens.get(0);
-               if (token.getDirection().isToDb()) {
-                       token = token.createReverse(mergerFactory());
-               }
-               assertTrue(token.getClass().getName(), token instanceof 
CreateTableToModel);
-
-               execute(token);
-
-               ObjEntity objEntity = null;
-               for (ObjEntity candidate : map.getObjEntities()) {
-                       if 
(dbEntity.getName().equalsIgnoreCase(candidate.getDbEntityName())) {
-                               objEntity = candidate;
-                               break;
-                       }
-               }
-               assertNotNull(objEntity);
-
-               assertEquals(objEntity.getClassName(), map.getDefaultPackage() 
+ "." + objEntity.getName());
-               assertEquals(objEntity.getSuperClassName(), 
map.getDefaultSuperclass());
-               assertEquals(objEntity.getClientClassName(), 
map.getDefaultClientPackage() + "." + objEntity.getName());
-               assertEquals(objEntity.getClientSuperClassName(), 
map.getDefaultClientSuperclass());
-
-               assertEquals(1, objEntity.getAttributes().size());
-               assertEquals("java.lang.String", 
objEntity.getAttributes().iterator().next().getType());
-
-               // clear up
-               // fix psql case issue
-               map.removeDbEntity(objEntity.getDbEntity().getName(), true);
-               map.removeObjEntity(objEntity.getName(), true);
-               map.removeDbEntity(dbEntity.getName(), true);
-               resolver.refreshMappingCache();
-               assertNull(map.getObjEntity(objEntity.getName()));
-               assertNull(map.getDbEntity(dbEntity.getName()));
-               assertFalse(map.getDbEntities().contains(dbEntity));
-
-               assertTokensAndExecute(1, 0);
-               assertTokensAndExecute(0, 0);
-       }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/DbMergerTest.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/DbMergerTest.java 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/DbMergerTest.java
deleted file mode 100644
index 894129d..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/merge/DbMergerTest.java
+++ /dev/null
@@ -1,261 +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.merge;
-
-import org.apache.cayenne.access.loader.DbLoaderConfiguration;
-import org.apache.cayenne.dba.hsqldb.HSQLMergerFactory;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.merge.builders.DbEntityBuilder;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.apache.cayenne.merge.builders.ObjectMother.dataMap;
-import static org.apache.cayenne.merge.builders.ObjectMother.dbAttr;
-import static org.apache.cayenne.merge.builders.ObjectMother.dbEntity;
-import static org.junit.Assert.assertEquals;
-
-public class DbMergerTest {
-
-    @Test
-    public void testEmptyDataMap() throws Exception {
-        assertEquals(0, dbMerger().createMergeTokens(new 
ArrayList<DbEntity>(0),
-                new ArrayList<DbEntity>(0), new 
DbLoaderConfiguration()).size());
-    }
-
-    @Test
-    public void testAddTable() throws Exception {
-        DbEntityBuilder dbEntity =
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt()
-        );
-        DataMap existing = dataMap().with(dbEntity).build();
-
-        List<MergerToken> tokens = 
dbMerger().createMergeTokens(existing.getDbEntities(),
-                new ArrayList<DbEntity>(0), new DbLoaderConfiguration());
-
-        assertEquals(1, tokens.size());
-        
assertEquals(factory().createCreateTableToDb(dbEntity.build()).getTokenValue(),
-                     tokens.get(0).getTokenValue());
-    }
-
-    @Test
-    public void testRemoveTable() throws Exception {
-        DataMap db = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt()
-        )).build();
-
-        List<MergerToken> tokens = dbMerger().createMergeTokens(new 
ArrayList<DbEntity>(0),
-                db.getDbEntities(), new DbLoaderConfiguration());
-
-        assertEquals(1, tokens.size());
-        
assertEquals(factory().createDropTableToDb(db.getDbEntity("table1")).getTokenValue(),
-                     tokens.get(0).getTokenValue());
-    }
-
-    @Test
-    public void testAddColumn() throws Exception {
-        DataMap existing = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt(),
-                dbAttr("attr02").typeInt()
-        )).build();
-
-        DataMap db = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt()
-        )).build();
-
-        List<MergerToken> tokens = 
dbMerger().createMergeTokens(existing.getDbEntities(),
-                db.getDbEntities(), new DbLoaderConfiguration());
-
-        assertEquals(1, tokens.size());
-
-        DbEntity entity = existing.getDbEntity("table1");
-        assertEquals(factory().createAddColumnToDb(entity, 
entity.getAttribute("attr02")).getTokenValue(),
-                     tokens.get(0).getTokenValue());
-    }
-
-    @Test
-    public void testAddRelationship() throws Exception {
-        DataMap existing = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt(),
-                dbAttr("attr02").typeInt()),
-
-            dbEntity("table2").attributes(
-                dbAttr("attr01").typeInt().primaryKey(),
-                dbAttr("attr02").typeInt())
-        ).join("rel", "table1.attr01", "table2.attr01")
-         .build();
-
-        DataMap db = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt(),
-                dbAttr("attr02").typeInt()),
-
-            dbEntity("table2").attributes(
-                dbAttr("attr01").typeInt().primaryKey(),
-                dbAttr("attr02").typeInt())
-        )//.join("table1.attr01", "table2.attr01")
-         .build();
-
-
-        List<MergerToken> tokens = 
dbMerger().createMergeTokens(existing.getDbEntities(),
-                db.getDbEntities(), new DbLoaderConfiguration());
-
-        assertEquals(1, tokens.size());
-
-        DbEntity entity = existing.getDbEntity("table1");
-        assertEquals(factory().createAddRelationshipToDb(entity, 
entity.getRelationship("rel")).getTokenValue(),
-                     tokens.get(0).getTokenValue());
-    }
-
-    @Test
-    public void testAddRelationship1() throws Exception {
-        DataMap existing = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt(),
-                dbAttr("attr02").typeInt()),
-
-            dbEntity("table2").attributes(
-                dbAttr("attr01").typeInt().primaryKey(),
-                dbAttr("attr02").typeInt().primaryKey(),
-                dbAttr("attr03").typeInt().primaryKey())
-        ).join("rel", "table1.attr01", "table2.attr01")
-         .join("rel1", "table1.attr01", "table2.attr03")
-         .build();
-
-        DataMap db = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt(),
-                dbAttr("attr02").typeInt()),
-
-            dbEntity("table2").attributes(
-                dbAttr("attr01").typeInt().primaryKey(),
-                dbAttr("attr02").typeInt().primaryKey(),
-                dbAttr("attr03").typeInt().primaryKey())
-        ).join("rel", "table1.attr01", "table2.attr02")
-         .join("rel1", "table1.attr01", "table2.attr03")
-         .build();
-
-
-        List<MergerToken> tokens = 
dbMerger().createMergeTokens(existing.getDbEntities(),
-                db.getDbEntities(), new DbLoaderConfiguration());
-
-        assertEquals(2, tokens.size());
-
-        DbEntity entity = existing.getDbEntity("table1");
-        assertEquals(factory().createDropRelationshipToDb(entity, 
entity.getRelationship("rel")).getTokenValue(),
-                     tokens.get(0).getTokenValue());
-
-        entity = db.getDbEntity("table1");
-        assertEquals(factory().createAddRelationshipToDb(entity, 
entity.getRelationship("rel")).getTokenValue(),
-                     tokens.get(0).getTokenValue());
-    }
-
-    @Test
-    public void testRemoveRelationship() throws Exception {
-        DataMap existing = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt(),
-                dbAttr("attr02").typeInt()),
-
-            dbEntity("table2").attributes(
-                dbAttr("attr01").typeInt().primaryKey(),
-                dbAttr("attr02").typeInt())
-        )
-         .build();
-
-        DataMap db = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt(),
-                dbAttr("attr02").typeInt()),
-
-            dbEntity("table2").attributes(
-                dbAttr("attr01").typeInt().primaryKey(),
-                dbAttr("attr02").typeInt())
-        ).join("rel", "table1.attr01", "table2.attr01")
-         .build();
-
-
-        List<MergerToken> tokens = 
dbMerger().createMergeTokens(existing.getDbEntities(), db.getDbEntities(), new 
DbLoaderConfiguration());
-
-        assertEquals(1, tokens.size());
-
-        DbEntity entity = db.getDbEntity("table1");
-        assertEquals(factory().createDropRelationshipToDb(entity, 
entity.getRelationship("rel")).getTokenValue(),
-                     tokens.get(0).getTokenValue());
-    }
-
-    @Test
-    public void testRemoveColumn() throws Exception {
-        DataMap existing = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt()
-        )).build();
-
-        DataMap db = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt(),
-                dbAttr("attr02").typeInt()
-        )).build();
-
-        List<MergerToken> tokens = 
dbMerger().createMergeTokens(existing.getDbEntities(),
-                db.getDbEntities(), new DbLoaderConfiguration());
-
-        assertEquals(1, tokens.size());
-
-        DbEntity entity = db.getDbEntity("table1");
-        assertEquals(factory().createDropColumnToModel(entity, 
entity.getAttribute("attr02")).getTokenValue(),
-                     tokens.get(0).getTokenValue());
-    }
-
-    @Test
-    public void testNoChanges() throws Exception {
-        DataMap dataMap1 = dataMap().with(
-                dbEntity("table1").attributes(
-                        dbAttr("attr01").typeInt(),
-                        dbAttr("attr02").typeInt(),
-                        dbAttr("attr03").typeInt()
-                )).build();
-
-        DataMap dataMap2 = dataMap().with(
-            dbEntity("table1").attributes(
-                dbAttr("attr01").typeInt(),
-                dbAttr("attr02").typeInt(),
-                dbAttr("attr03").typeInt()
-        )).build();
-
-
-        assertEquals(0, dbMerger().createMergeTokens(dataMap1.getDbEntities(),
-                dataMap2.getDbEntities(), new DbLoaderConfiguration()).size());
-    }
-
-    private DbMerger dbMerger() {
-        return new DbMerger(factory());
-    }
-
-    private HSQLMergerFactory factory() {
-        return new HSQLMergerFactory();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/DropColumnToModelIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/DropColumnToModelIT.java
 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/DropColumnToModelIT.java
deleted file mode 100644
index 9005e79..0000000
--- 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/DropColumnToModelIT.java
+++ /dev/null
@@ -1,235 +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.merge;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.sql.Types;
-import java.util.List;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.junit.Test;
-
-public class DropColumnToModelIT extends MergeCase {
-
-       @Test
-       public void testSimpleColumn() throws Exception {
-               dropTableIfPresent("NEW_TABLE");
-
-               assertTokensAndExecute(0, 0);
-
-               DbEntity dbEntity = new DbEntity("NEW_TABLE");
-
-               DbAttribute column1 = new DbAttribute("ID", Types.INTEGER, 
dbEntity);
-               column1.setMandatory(true);
-               column1.setPrimaryKey(true);
-               dbEntity.addAttribute(column1);
-
-               DbAttribute column2 = new DbAttribute("NAME", Types.VARCHAR, 
dbEntity);
-               column2.setMaxLength(10);
-               column2.setMandatory(false);
-               dbEntity.addAttribute(column2);
-
-               map.addDbEntity(dbEntity);
-
-               assertTokensAndExecute(1, 0);
-               assertTokensAndExecute(0, 0);
-
-               ObjEntity objEntity = new ObjEntity("NewTable");
-               objEntity.setDbEntity(dbEntity);
-               ObjAttribute oatr1 = new ObjAttribute("name");
-               oatr1.setDbAttributePath(column2.getName());
-               oatr1.setType("java.lang.String");
-               objEntity.addAttribute(oatr1);
-               map.addObjEntity(objEntity);
-
-               // force drop name column in db
-               MergerToken token = 
mergerFactory().createDropColumnToDb(dbEntity, column2);
-               execute(token);
-
-               List<MergerToken> tokens = createMergeTokens();
-               assertEquals(1, tokens.size());
-               token = tokens.get(0);
-               if (token.getDirection().isToDb()) {
-                       token = token.createReverse(mergerFactory());
-               }
-               assertTrue(token instanceof DropColumnToModel);
-               execute(token);
-               assertNull(dbEntity.getAttribute(column2.getName()));
-               assertNull(objEntity.getAttribute(oatr1.getName()));
-
-               // clear up
-               map.removeObjEntity(objEntity.getName(), true);
-               map.removeDbEntity(dbEntity.getName(), true);
-               resolver.refreshMappingCache();
-               assertNull(map.getObjEntity(objEntity.getName()));
-               assertNull(map.getDbEntity(dbEntity.getName()));
-               assertFalse(map.getDbEntities().contains(dbEntity));
-
-               assertTokensAndExecute(1, 0);
-               assertTokensAndExecute(0, 0);
-       }
-
-       @Test
-       public void testRemoveFKColumnWithoutRelationshipInDb() throws 
Exception {
-               dropTableIfPresent("NEW_TABLE");
-               dropTableIfPresent("NEW_TABLE2");
-
-               assertTokensAndExecute(0, 0);
-
-               DbEntity dbEntity1 = new DbEntity("NEW_TABLE");
-
-               DbAttribute e1col1 = new DbAttribute("ID", Types.INTEGER, 
dbEntity1);
-               e1col1.setMandatory(true);
-               e1col1.setPrimaryKey(true);
-               dbEntity1.addAttribute(e1col1);
-
-               DbAttribute e1col2 = new DbAttribute("NAME", Types.VARCHAR, 
dbEntity1);
-               e1col2.setMaxLength(10);
-               e1col2.setMandatory(false);
-               dbEntity1.addAttribute(e1col2);
-
-               map.addDbEntity(dbEntity1);
-
-               DbEntity dbEntity2 = new DbEntity("NEW_TABLE2");
-               DbAttribute e2col1 = new DbAttribute("ID", Types.INTEGER, 
dbEntity2);
-               e2col1.setMandatory(true);
-               e2col1.setPrimaryKey(true);
-               dbEntity2.addAttribute(e2col1);
-               DbAttribute e2col2 = new DbAttribute("FK", Types.INTEGER, 
dbEntity2);
-               dbEntity2.addAttribute(e2col2);
-               DbAttribute e2col3 = new DbAttribute("NAME", Types.VARCHAR, 
dbEntity2);
-               e2col3.setMaxLength(10);
-               dbEntity2.addAttribute(e2col3);
-
-               map.addDbEntity(dbEntity2);
-
-               assertTokensAndExecute(2, 0);
-               assertTokensAndExecute(0, 0);
-
-               // force drop fk column in db
-               execute(mergerFactory().createDropColumnToDb(dbEntity2, 
e2col2));
-
-               // create db relationships, but do not sync them to db
-               DbRelationship rel1To2 = new DbRelationship("rel1To2");
-               rel1To2.setSourceEntity(dbEntity1);
-               rel1To2.setTargetEntityName(dbEntity2);
-               rel1To2.setToMany(true);
-               rel1To2.addJoin(new DbJoin(rel1To2, e1col1.getName(), 
e2col2.getName()));
-               dbEntity1.addRelationship(rel1To2);
-               DbRelationship rel2To1 = new DbRelationship("rel2To1");
-               rel2To1.setSourceEntity(dbEntity2);
-               rel2To1.setTargetEntityName(dbEntity1);
-               rel2To1.setToMany(false);
-               rel2To1.addJoin(new DbJoin(rel2To1, e2col2.getName(), 
e1col1.getName()));
-               dbEntity2.addRelationship(rel2To1);
-               assertSame(rel1To2, rel2To1.getReverseRelationship());
-               assertSame(rel2To1, rel1To2.getReverseRelationship());
-
-               // create ObjEntities
-               ObjEntity objEntity1 = new ObjEntity("NewTable");
-               objEntity1.setDbEntity(dbEntity1);
-               ObjAttribute oatr1 = new ObjAttribute("name");
-               oatr1.setDbAttributePath(e1col2.getName());
-               oatr1.setType("java.lang.String");
-               objEntity1.addAttribute(oatr1);
-               map.addObjEntity(objEntity1);
-               ObjEntity objEntity2 = new ObjEntity("NewTable2");
-               objEntity2.setDbEntity(dbEntity2);
-               ObjAttribute o2a1 = new ObjAttribute("name");
-               o2a1.setDbAttributePath(e2col3.getName());
-               o2a1.setType("java.lang.String");
-               objEntity2.addAttribute(o2a1);
-               map.addObjEntity(objEntity2);
-
-               // create ObjRelationships
-               assertEquals(0, objEntity1.getRelationships().size());
-               assertEquals(0, objEntity2.getRelationships().size());
-               ObjRelationship objRel1To2 = new ObjRelationship("objRel1To2");
-               objRel1To2.addDbRelationship(rel1To2);
-               objRel1To2.setSourceEntity(objEntity1);
-               objRel1To2.setTargetEntityName(objEntity2);
-               objEntity1.addRelationship(objRel1To2);
-               ObjRelationship objRel2To1 = new ObjRelationship("objRel2To1");
-               objRel2To1.addDbRelationship(rel2To1);
-               objRel2To1.setSourceEntity(objEntity2);
-               objRel2To1.setTargetEntityName(objEntity1);
-               objEntity2.addRelationship(objRel2To1);
-               assertEquals(1, objEntity1.getRelationships().size());
-               assertEquals(1, objEntity2.getRelationships().size());
-               assertSame(objRel1To2, objRel2To1.getReverseRelationship());
-               assertSame(objRel2To1, objRel1To2.getReverseRelationship());
-
-               // try do use the merger to remove the column and relationship 
in the
-               // model
-               List<MergerToken> tokens = createMergeTokens();
-               assertTokens(tokens, 2, 0);
-               // TODO: reversing the following two tokens should also reverse 
the
-               // order
-               MergerToken token0 = 
tokens.get(0).createReverse(mergerFactory());
-               MergerToken token1 = 
tokens.get(1).createReverse(mergerFactory());
-               if (!(token0 instanceof DropRelationshipToModel && token1 
instanceof DropColumnToModel || token1 instanceof DropRelationshipToModel
-                               && token0 instanceof DropColumnToModel)) {
-                       fail();
-               }
-               // do not execute DropRelationshipToModel, only 
DropColumnToModel.
-               if (token1 instanceof DropColumnToModel) {
-                       execute(token1);
-               } else {
-                       execute(token0);
-               }
-
-               // check after merging
-               assertNull(dbEntity2.getAttribute(e2col2.getName()));
-               assertEquals(0, dbEntity1.getRelationships().size());
-               assertEquals(0, dbEntity2.getRelationships().size());
-               assertEquals(0, objEntity1.getRelationships().size());
-               assertEquals(0, objEntity2.getRelationships().size());
-
-               // clear up
-
-               dbEntity1.removeRelationship(rel1To2.getName());
-               dbEntity2.removeRelationship(rel2To1.getName());
-               map.removeObjEntity(objEntity1.getName(), true);
-               map.removeDbEntity(dbEntity1.getName(), true);
-               map.removeObjEntity(objEntity2.getName(), true);
-               map.removeDbEntity(dbEntity2.getName(), true);
-               resolver.refreshMappingCache();
-               assertNull(map.getObjEntity(objEntity1.getName()));
-               assertNull(map.getDbEntity(dbEntity1.getName()));
-               assertNull(map.getObjEntity(objEntity2.getName()));
-               assertNull(map.getDbEntity(dbEntity2.getName()));
-               assertFalse(map.getDbEntities().contains(dbEntity1));
-               assertFalse(map.getDbEntities().contains(dbEntity2));
-
-               assertTokensAndExecute(2, 0);
-               assertTokensAndExecute(0, 0);
-       }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/DropRelationshipToModelIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/DropRelationshipToModelIT.java
 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/DropRelationshipToModelIT.java
deleted file mode 100644
index 4610fcd..0000000
--- 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/DropRelationshipToModelIT.java
+++ /dev/null
@@ -1,188 +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.merge;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-
-import java.sql.Types;
-import java.util.List;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.junit.Test;
-
-public class DropRelationshipToModelIT extends MergeCase {
-
-       @Test
-       public void testForeignKey() throws Exception {
-               dropTableIfPresent("NEW_TABLE");
-               dropTableIfPresent("NEW_TABLE2");
-
-               assertTokensAndExecute(0, 0);
-
-               DbEntity dbEntity1 = new DbEntity("NEW_TABLE");
-
-               DbAttribute e1col1 = new DbAttribute("ID", Types.INTEGER, 
dbEntity1);
-               e1col1.setMandatory(true);
-               e1col1.setPrimaryKey(true);
-               dbEntity1.addAttribute(e1col1);
-
-               DbAttribute e1col2 = new DbAttribute("NAME", Types.VARCHAR, 
dbEntity1);
-               e1col2.setMaxLength(10);
-               e1col2.setMandatory(false);
-               dbEntity1.addAttribute(e1col2);
-
-               map.addDbEntity(dbEntity1);
-
-               DbEntity dbEntity2 = new DbEntity("NEW_TABLE2");
-               DbAttribute e2col1 = new DbAttribute("ID", Types.INTEGER, 
dbEntity2);
-               e2col1.setMandatory(true);
-               e2col1.setPrimaryKey(true);
-               dbEntity2.addAttribute(e2col1);
-               DbAttribute e2col2 = new DbAttribute("FK", Types.INTEGER, 
dbEntity2);
-               dbEntity2.addAttribute(e2col2);
-               DbAttribute e2col3 = new DbAttribute("NAME", Types.VARCHAR, 
dbEntity2);
-               e2col3.setMaxLength(10);
-               dbEntity2.addAttribute(e2col3);
-
-               map.addDbEntity(dbEntity2);
-
-               // create db relationships
-               DbRelationship rel1To2 = new DbRelationship("rel1To2");
-               rel1To2.setSourceEntity(dbEntity1);
-               rel1To2.setTargetEntityName(dbEntity2);
-               rel1To2.setToMany(true);
-               rel1To2.addJoin(new DbJoin(rel1To2, e1col1.getName(), 
e2col2.getName()));
-               dbEntity1.addRelationship(rel1To2);
-               DbRelationship rel2To1 = new DbRelationship("rel2To1");
-               rel2To1.setSourceEntity(dbEntity2);
-               rel2To1.setTargetEntityName(dbEntity1);
-               rel2To1.setToMany(false);
-               rel2To1.addJoin(new DbJoin(rel2To1, e2col2.getName(), 
e1col1.getName()));
-               dbEntity2.addRelationship(rel2To1);
-               assertSame(rel1To2, rel2To1.getReverseRelationship());
-               assertSame(rel2To1, rel1To2.getReverseRelationship());
-
-               assertTokensAndExecute(4, 0);
-               assertTokensAndExecute(0, 0);
-
-               // create ObjEntities
-               ObjEntity objEntity1 = new ObjEntity("NewTable");
-               objEntity1.setDbEntity(dbEntity1);
-               ObjAttribute oatr1 = new ObjAttribute("name");
-               oatr1.setDbAttributePath(e1col2.getName());
-               oatr1.setType("java.lang.String");
-               objEntity1.addAttribute(oatr1);
-               map.addObjEntity(objEntity1);
-               ObjEntity objEntity2 = new ObjEntity("NewTable2");
-               objEntity2.setDbEntity(dbEntity2);
-               ObjAttribute o2a1 = new ObjAttribute("name");
-               o2a1.setDbAttributePath(e2col3.getName());
-               o2a1.setType("java.lang.String");
-               objEntity2.addAttribute(o2a1);
-               map.addObjEntity(objEntity2);
-
-               // create ObjRelationships
-               assertEquals(0, objEntity1.getRelationships().size());
-               assertEquals(0, objEntity2.getRelationships().size());
-               ObjRelationship objRel1To2 = new ObjRelationship("objRel1To2");
-               objRel1To2.addDbRelationship(rel1To2);
-               objRel1To2.setSourceEntity(objEntity1);
-               objRel1To2.setTargetEntityName(objEntity2);
-               objEntity1.addRelationship(objRel1To2);
-               ObjRelationship objRel2To1 = new ObjRelationship("objRel2To1");
-               objRel2To1.addDbRelationship(rel2To1);
-               objRel2To1.setSourceEntity(objEntity2);
-               objRel2To1.setTargetEntityName(objEntity1);
-               objEntity2.addRelationship(objRel2To1);
-               assertEquals(1, objEntity1.getRelationships().size());
-               assertEquals(1, objEntity2.getRelationships().size());
-               assertSame(objRel1To2, objRel2To1.getReverseRelationship());
-               assertSame(objRel2To1, objRel1To2.getReverseRelationship());
-
-        // remove relationship and fk from model, merge to db and read to model
-        dbEntity2.removeRelationship(rel2To1.getName());
-        dbEntity1.removeRelationship(rel1To2.getName());
-        dbEntity2.removeAttribute(e2col2.getName());
-        List<MergerToken> tokens = createMergeTokens();
-        /**
-         * Add Relationship NEW_TABLE->NEW_TABLE2 To Model
-         * Drop Relationship NEW_TABLE2->NEW_TABLE To DB
-         * Drop Column NEW_TABLE2.FK To DB
-         * */
-        assertTokens(tokens, 2, 1);
-        for (MergerToken token : tokens) {
-            if (token.getDirection().isToDb()) {
-                execute(token);
-            }
-        }
-        assertTokensAndExecute(0, 0);
-        dbEntity2.addRelationship(rel2To1);
-        dbEntity1.addRelationship(rel1To2);
-        dbEntity2.addAttribute(e2col2);
-
-               // try do use the merger to remove the relationship in the model
-               tokens = createMergeTokens();
-               assertTokens(tokens, 2, 0);
-               // TODO: reversing the following two tokens should also reverse 
the
-               // order
-               MergerToken token0 = 
tokens.get(0).createReverse(mergerFactory());
-               MergerToken token1 = 
tokens.get(1).createReverse(mergerFactory());
-               if (!(token0 instanceof DropRelationshipToModel && token1 
instanceof DropColumnToModel || token1 instanceof DropRelationshipToModel
-                               && token0 instanceof DropColumnToModel)) {
-                       fail();
-               }
-               execute(token0);
-               execute(token1);
-
-               // check after merging
-               assertNull(dbEntity2.getAttribute(e2col2.getName()));
-               assertEquals(0, dbEntity1.getRelationships().size());
-               assertEquals(0, dbEntity2.getRelationships().size());
-               assertEquals(0, objEntity1.getRelationships().size());
-               assertEquals(0, objEntity2.getRelationships().size());
-
-               // clear up
-               dbEntity1.removeRelationship(rel1To2.getName());
-               dbEntity2.removeRelationship(rel2To1.getName());
-               map.removeObjEntity(objEntity1.getName(), true);
-               map.removeDbEntity(dbEntity1.getName(), true);
-               map.removeObjEntity(objEntity2.getName(), true);
-               map.removeDbEntity(dbEntity2.getName(), true);
-               resolver.refreshMappingCache();
-               assertNull(map.getObjEntity(objEntity1.getName()));
-               assertNull(map.getDbEntity(dbEntity1.getName()));
-               assertNull(map.getObjEntity(objEntity2.getName()));
-               assertNull(map.getDbEntity(dbEntity2.getName()));
-               assertFalse(map.getDbEntities().contains(dbEntity1));
-               assertFalse(map.getDbEntities().contains(dbEntity2));
-
-               assertTokensAndExecute(2, 0);
-               assertTokensAndExecute(0, 0);
-       }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/DropTableToModelIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/DropTableToModelIT.java 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/DropTableToModelIT.java
deleted file mode 100644
index ddf5a49..0000000
--- 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/DropTableToModelIT.java
+++ /dev/null
@@ -1,94 +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.merge;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Types;
-import java.util.List;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.junit.Test;
-
-public class DropTableToModelIT extends MergeCase {
-
-       @Test
-       public void testDropTable() throws Exception {
-               dropTableIfPresent("NEW_TABLE");
-               assertTokensAndExecute(0, 0);
-
-               DbEntity dbEntity = new DbEntity("NEW_TABLE");
-
-               DbAttribute column1 = new DbAttribute("ID", Types.INTEGER, 
dbEntity);
-               column1.setMandatory(true);
-               column1.setPrimaryKey(true);
-               dbEntity.addAttribute(column1);
-
-               DbAttribute column2 = new DbAttribute("NAME", Types.VARCHAR, 
dbEntity);
-               column2.setMaxLength(10);
-               column2.setMandatory(false);
-               dbEntity.addAttribute(column2);
-
-               map.addDbEntity(dbEntity);
-
-               assertTokensAndExecute(1, 0);
-               assertTokensAndExecute(0, 0);
-
-               ObjEntity objEntity = new ObjEntity("NewTable");
-               objEntity.setDbEntity(dbEntity);
-               ObjAttribute oatr1 = new ObjAttribute("name");
-               oatr1.setDbAttributePath(column2.getName());
-               oatr1.setType("java.lang.String");
-               objEntity.addAttribute(oatr1);
-               map.addObjEntity(objEntity);
-
-               // force drop table in db
-               MergerToken token = 
mergerFactory().createDropTableToDb(dbEntity);
-               execute(token);
-
-               List<MergerToken> tokens = createMergeTokens();
-               assertEquals(1, tokens.size());
-               token = tokens.get(0);
-               if (token.getDirection().isToDb()) {
-                       token = token.createReverse(mergerFactory());
-               }
-               assertTrue(token instanceof DropTableToModel);
-               execute(token);
-               resolver.refreshMappingCache();
-               assertNull(map.getDbEntity(dbEntity.getName()));
-               assertNull(map.getObjEntity(objEntity.getName()));
-
-               // clear up
-               map.removeObjEntity(objEntity.getName(), true);
-               map.removeDbEntity(dbEntity.getName(), true);
-               resolver.refreshMappingCache();
-               assertNull(map.getObjEntity(objEntity.getName()));
-               assertNull(map.getDbEntity(dbEntity.getName()));
-               assertFalse(map.getDbEntities().contains(dbEntity));
-
-               assertTokensAndExecute(0, 0);
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/MergeCase.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/MergeCase.java 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/MergeCase.java
deleted file mode 100644
index dfbffa9..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/merge/MergeCase.java
+++ /dev/null
@@ -1,215 +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.merge;
-
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.loader.DbLoaderConfiguration;
-import org.apache.cayenne.access.loader.filters.FiltersConfig;
-import org.apache.cayenne.access.loader.filters.PatternFilter;
-import org.apache.cayenne.access.loader.filters.TableFilter;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.unit.UnitDbAdapter;
-import org.apache.cayenne.unit.di.server.CayenneProjects;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.Before;
-
-import java.sql.Connection;
-import java.sql.Statement;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-@UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
-public abstract class MergeCase extends ServerCase {
-
-       private Log logger = LogFactory.getLog(MergeCase.class);
-
-       @Inject
-       private DBHelper dbHelper;
-
-       @Inject
-       private ServerRuntime runtime;
-
-       @Inject
-       private UnitDbAdapter accessStackAdapter;
-
-       @Inject
-       private ServerCaseDataSourceFactory dataSourceFactory;
-
-       @Inject
-       protected EntityResolver resolver;
-
-       @Inject
-       protected DataNode node;
-
-       protected DataMap map;
-
-       @Override
-       public void cleanUpDB() throws Exception {
-               dbHelper.update("ARTGROUP").set("PARENT_GROUP_ID", null, 
Types.INTEGER).execute();
-               super.cleanUpDB();
-       }
-
-       @Before
-       public void setUp() throws Exception {
-
-               // this map can't be safely modified in this test, as it is 
reset by DI
-               // container
-               // on every test
-               map = runtime.getDataDomain().getDataMap("testmap");
-
-               filterDataMap();
-
-               List<MergerToken> tokens = createMergeTokens();
-               execute(tokens);
-
-               assertTokensAndExecute(0, 0);
-       }
-
-       protected DbMerger createMerger(MergerFactory mergerFactory) {
-               return createMerger(mergerFactory, null);
-       }
-
-       protected DbMerger createMerger(MergerFactory mergerFactory, 
ValueForNullProvider valueForNullProvider) {
-               return new DbMerger(mergerFactory, valueForNullProvider);
-       }
-
-       protected List<MergerToken> createMergeTokens() {
-               DbLoaderConfiguration loaderConfiguration = new 
DbLoaderConfiguration();
-               loaderConfiguration.setFiltersConfig(FiltersConfig.create(null, 
null,
-                               
TableFilter.include("ARTIST|GALLERY|PAINTING|NEW_TABLE2?"), 
PatternFilter.INCLUDE_NOTHING));
-
-               return 
createMerger(node.getAdapter().mergerFactory()).createMergeTokens(node.getDataSource(),
-                               node.getAdapter(), map, loaderConfiguration);
-       }
-
-       /**
-        * Remote binary pk {@link DbEntity} for {@link DbAdapter} not 
supporting
-        * that and so on.
-        */
-       private void filterDataMap() {
-               // copied from AbstractAccessStack.dbEntitiesInInsertOrder
-               boolean excludeBinPK = accessStackAdapter.supportsBinaryPK();
-
-               if (!excludeBinPK) {
-                       return;
-               }
-
-               List<DbEntity> entitiesToRemove = new ArrayList<DbEntity>();
-
-               for (DbEntity ent : map.getDbEntities()) {
-                       for (DbAttribute attr : ent.getAttributes()) {
-                               // check for BIN PK or FK to BIN Pk
-                               if (attr.getType() == Types.BINARY || 
attr.getType() == Types.VARBINARY
-                                               || attr.getType() == 
Types.LONGVARBINARY) {
-
-                                       if (attr.isPrimaryKey() || 
attr.isForeignKey()) {
-                                               entitiesToRemove.add(ent);
-                                               break;
-                                       }
-                               }
-                       }
-               }
-
-               for (DbEntity e : entitiesToRemove) {
-                       map.removeDbEntity(e.getName(), true);
-               }
-       }
-
-       protected void execute(List<MergerToken> tokens) {
-               MergerContext mergerContext = 
MergerContext.builder(map).dataNode(node).build();
-               for (MergerToken tok : tokens) {
-                       tok.execute(mergerContext);
-               }
-       }
-
-       protected void execute(MergerToken token) throws Exception {
-               MergerContext mergerContext = 
MergerContext.builder(map).dataNode(node).build();
-               token.execute(mergerContext);
-       }
-
-       private void executeSql(String sql) throws Exception {
-
-               try (Connection conn = 
dataSourceFactory.getSharedDataSource().getConnection();) {
-
-                       try (Statement st = conn.createStatement();) {
-                               st.execute(sql);
-                       }
-               }
-       }
-
-       protected void assertTokens(List<MergerToken> tokens, int expectedToDb, 
int expectedToModel) {
-               int actualToDb = 0;
-               int actualToModel = 0;
-               for (MergerToken token : tokens) {
-                       if (token.getDirection().isToDb()) {
-                               actualToDb++;
-                       } else if (token.getDirection().isToModel()) {
-                               actualToModel++;
-                       }
-               }
-
-               assertEquals("tokens to db", expectedToDb, actualToDb);
-               assertEquals("tokens to model", expectedToModel, actualToModel);
-       }
-
-       protected void assertTokensAndExecute(int expectedToDb, int 
expectedToModel) {
-               List<MergerToken> tokens = createMergeTokens();
-               assertTokens(tokens, expectedToDb, expectedToModel);
-               execute(tokens);
-       }
-
-       protected MergerFactory mergerFactory() {
-               return node.getAdapter().mergerFactory();
-       }
-
-       protected void dropTableIfPresent(String tableName) throws Exception {
-
-               // must have a dummy datamap for the dummy table for the 
downstream code
-               // to work
-               DataMap map = new DataMap("dummy");
-               map.setQuotingSQLIdentifiers(map.isQuotingSQLIdentifiers());
-               DbEntity entity = new DbEntity(tableName);
-               map.addDbEntity(entity);
-
-               AbstractToDbToken t = (AbstractToDbToken) 
mergerFactory().createDropTableToDb(entity);
-
-               for (String sql : t.createSql(node.getAdapter())) {
-
-                       try {
-                               executeSql(sql);
-                       } catch (Exception e) {
-                               logger.info("Exception dropping table " + 
tableName + ", probably abscent..");
-                       }
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/MergerFactoryIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/MergerFactoryIT.java 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/MergerFactoryIT.java
deleted file mode 100644
index 5c4c51b..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/merge/MergerFactoryIT.java
+++ /dev/null
@@ -1,310 +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.merge;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.sql.Types;
-
-import org.apache.cayenne.CayenneDataObject;
-import org.apache.cayenne.access.DataContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.junit.Test;
-
-public class MergerFactoryIT extends MergeCase {
-
-    @Inject
-    private DataContext context;
-
-    @Test
-    public void testAddAndDropColumnToDb() throws Exception {
-        DbEntity dbEntity = map.getDbEntity("PAINTING");
-        assertNotNull(dbEntity);
-
-        // create and add new column to model and db
-        DbAttribute column = new DbAttribute("NEWCOL1", Types.VARCHAR, 
dbEntity);
-
-        column.setMandatory(false);
-        column.setMaxLength(10);
-        dbEntity.addAttribute(column);
-        assertTokensAndExecute(1, 0);
-
-        // try merge once more to check that is was merged
-        assertTokensAndExecute(0, 0);
-
-        // remove it from model and db
-        dbEntity.removeAttribute(column.getName());
-        assertTokensAndExecute(1, 0);
-        assertTokensAndExecute(0, 0);
-    }
-
-    @Test
-    public void testChangeVarcharSizeToDb() throws Exception {
-        DbEntity dbEntity = map.getDbEntity("PAINTING");
-        assertNotNull(dbEntity);
-
-        // create and add new column to model and db
-        DbAttribute column = new DbAttribute("NEWCOL2", Types.VARCHAR, 
dbEntity);
-
-        column.setMandatory(false);
-        column.setMaxLength(10);
-        dbEntity.addAttribute(column);
-        assertTokensAndExecute(1, 0);
-
-        // check that is was merged
-        assertTokensAndExecute(0, 0);
-
-        // change size
-        column.setMaxLength(20);
-
-        // merge to db
-        assertTokensAndExecute(1, 0);
-
-        // check that is was merged
-        assertTokensAndExecute(0, 0);
-
-        // clean up
-        dbEntity.removeAttribute(column.getName());
-        assertTokensAndExecute(1, 0);
-        assertTokensAndExecute(0, 0);
-    }
-
-    @Test
-    public void testMultipleTokensToDb() throws Exception {
-        DbEntity dbEntity = map.getDbEntity("PAINTING");
-        assertNotNull(dbEntity);
-
-        DbAttribute column1 = new DbAttribute("NEWCOL3", Types.VARCHAR, 
dbEntity);
-        column1.setMandatory(false);
-        column1.setMaxLength(10);
-        dbEntity.addAttribute(column1);
-        DbAttribute column2 = new DbAttribute("NEWCOL4", Types.VARCHAR, 
dbEntity);
-        column2.setMandatory(false);
-        column2.setMaxLength(10);
-        dbEntity.addAttribute(column2);
-
-        assertTokensAndExecute(2, 0);
-
-        // check that is was merged
-        assertTokensAndExecute(0, 0);
-
-        // change size
-        column1.setMaxLength(20);
-        column2.setMaxLength(30);
-
-        // merge to db
-        assertTokensAndExecute(2, 0);
-
-        // check that is was merged
-        assertTokensAndExecute(0, 0);
-
-        // clean up
-        dbEntity.removeAttribute(column1.getName());
-        dbEntity.removeAttribute(column2.getName());
-        assertTokensAndExecute(2, 0);
-        assertTokensAndExecute(0, 0);
-    }
-
-    @Test
-    public void testAddTableToDb() throws Exception {
-        dropTableIfPresent("NEW_TABLE");
-
-        assertTokensAndExecute(0, 0);
-
-        DbEntity dbEntity = new DbEntity("NEW_TABLE");
-
-        DbAttribute column1 = new DbAttribute("ID", Types.INTEGER, dbEntity);
-        column1.setMandatory(true);
-        column1.setPrimaryKey(true);
-        dbEntity.addAttribute(column1);
-
-        DbAttribute column2 = new DbAttribute("NAME", Types.VARCHAR, dbEntity);
-        column2.setMaxLength(10);
-        column2.setMandatory(false);
-        dbEntity.addAttribute(column2);
-
-        map.addDbEntity(dbEntity);
-
-        assertTokensAndExecute(1, 0);
-        assertTokensAndExecute(0, 0);
-
-        ObjEntity objEntity = new ObjEntity("NewTable");
-        objEntity.setDbEntity(dbEntity);
-        ObjAttribute oatr1 = new ObjAttribute("name");
-        oatr1.setDbAttributePath(column2.getName());
-        oatr1.setType("java.lang.String");
-        objEntity.addAttribute(oatr1);
-        map.addObjEntity(objEntity);
-
-        for (int i = 0; i < 5; i++) {
-            CayenneDataObject dao = (CayenneDataObject) 
context.newObject(objEntity
-                    .getName());
-            dao.writeProperty(oatr1.getName(), "test " + i);
-        }
-        context.commitChanges();
-
-        // clear up
-        map.removeObjEntity(objEntity.getName(), true);
-        map.removeDbEntity(dbEntity.getName(), true);
-        resolver.refreshMappingCache();
-        assertNull(map.getObjEntity(objEntity.getName()));
-        assertNull(map.getDbEntity(dbEntity.getName()));
-        assertFalse(map.getDbEntities().contains(dbEntity));
-
-        assertTokensAndExecute(1, 0);
-        assertTokensAndExecute(0, 0);
-    }
-
-    @Test
-    public void testAddForeignKeyWithTable() throws Exception {
-        dropTableIfPresent("NEW_TABLE");
-
-        assertTokensAndExecute(0, 0);
-
-        DbEntity dbEntity = new DbEntity("NEW_TABLE");
-
-        attr(dbEntity, "ID", Types.INTEGER, true, true);
-        attr(dbEntity, "NAME", Types.VARCHAR, false, false).setMaxLength(10);
-        attr(dbEntity, "ARTIST_ID", Types.BIGINT, false, false);
-
-        map.addDbEntity(dbEntity);
-
-        DbEntity artistDbEntity = map.getDbEntity("ARTIST");
-        assertNotNull(artistDbEntity);
-
-        // relation from new_table to artist
-        DbRelationship r1 = new DbRelationship("toArtistR1");
-        r1.setSourceEntity(dbEntity);
-        r1.setTargetEntityName(artistDbEntity);
-        r1.setToMany(false);
-        r1.addJoin(new DbJoin(r1, "ARTIST_ID", "ARTIST_ID"));
-        dbEntity.addRelationship(r1);
-
-        // relation from artist to new_table
-        DbRelationship r2 = new DbRelationship("toNewTableR2");
-        r2.setSourceEntity(artistDbEntity);
-        r2.setTargetEntityName(dbEntity);
-        r2.setToMany(true);
-        r2.addJoin(new DbJoin(r2, "ARTIST_ID", "ARTIST_ID"));
-        artistDbEntity.addRelationship(r2);
-
-        assertTokensAndExecute(2, 0);
-        assertTokensAndExecute(0, 0);
-
-        // remove relationships
-        dbEntity.removeRelationship(r1.getName());
-        artistDbEntity.removeRelationship(r2.getName());
-        resolver.refreshMappingCache();
-        /*
-         * Db -Rel 'toArtistR1' - NEW_TABLE 1 -> 1 ARTIST"
-r2 =     * Db -Rel 'toNewTableR2' - ARTIST 1 -> * NEW_TABLE"
-         * */
-        assertTokensAndExecute(1, 1);
-        assertTokensAndExecute(0, 0);
-
-        // clear up
-        // map.removeObjEntity(objEntity.getName(), true);
-        map.removeDbEntity(dbEntity.getName(), true);
-        resolver.refreshMappingCache();
-        // assertNull(map.getObjEntity(objEntity.getName()));
-        assertNull(map.getDbEntity(dbEntity.getName()));
-        assertFalse(map.getDbEntities().contains(dbEntity));
-
-        assertTokensAndExecute(1, 0);
-        assertTokensAndExecute(0, 0);
-    }
-
-    @Test
-    public void testAddForeignKeyAfterTable() throws Exception {
-        dropTableIfPresent("NEW_TABLE");
-
-        assertTokensAndExecute(0, 0);
-
-        DbEntity dbEntity = new DbEntity("NEW_TABLE");
-        attr(dbEntity, "ID", Types.INTEGER, true, true);
-        attr(dbEntity, "NAME", Types.VARCHAR, false, false).setMaxLength(10);
-        attr(dbEntity, "ARTIST_ID", Types.BIGINT, false, false);
-
-        map.addDbEntity(dbEntity);
-
-        DbEntity artistDbEntity = map.getDbEntity("ARTIST");
-        assertNotNull(artistDbEntity);
-
-        assertTokensAndExecute(1, 0);
-        assertTokensAndExecute(0, 0);
-
-        // relation from new_table to artist
-        DbRelationship r1 = new DbRelationship("toArtistR1");
-        r1.setSourceEntity(dbEntity);
-        r1.setTargetEntityName(artistDbEntity);
-        r1.setToMany(false);
-        r1.addJoin(new DbJoin(r1, "ARTIST_ID", "ARTIST_ID"));
-        dbEntity.addRelationship(r1);
-
-        // relation from artist to new_table
-        DbRelationship r2 = new DbRelationship("toNewTableR2");
-        r2.setSourceEntity(artistDbEntity);
-        r2.setTargetEntityName(dbEntity);
-        r2.setToMany(true);
-        r2.addJoin(new DbJoin(r2, "ARTIST_ID", "ARTIST_ID"));
-        artistDbEntity.addRelationship(r2);
-
-        assertTokensAndExecute(1, 0);
-        assertTokensAndExecute(0, 0);
-
-        // remove relationships
-        dbEntity.removeRelationship(r1.getName());
-        artistDbEntity.removeRelationship(r2.getName());
-        resolver.refreshMappingCache();
-        /*
-        * Add Relationship ARTIST->NEW_TABLE To Model
-        * Drop Relationship NEW_TABLE->ARTIST To DB
-        * */
-        assertTokensAndExecute(1, 1);
-        assertTokensAndExecute(0, 0);
-
-        // clear up
-        // map.removeObjEntity(objEntity.getName(), true);
-        map.removeDbEntity(dbEntity.getName(), true);
-        resolver.refreshMappingCache();
-        // assertNull(map.getObjEntity(objEntity.getName()));
-        assertNull(map.getDbEntity(dbEntity.getName()));
-        assertFalse(map.getDbEntities().contains(dbEntity));
-
-        assertTokensAndExecute(1, 0);
-        assertTokensAndExecute(0, 0);
-    }
-
-    private static DbAttribute attr(DbEntity dbEntity, String name, int type, 
boolean mandatory, boolean primaryKey) {
-        DbAttribute column1 = new DbAttribute(name, type, dbEntity);
-        column1.setMandatory(mandatory);
-        column1.setPrimaryKey(primaryKey);
-
-        dbEntity.addAttribute(column1);
-        return column1;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/SetAllowNullToDbIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/SetAllowNullToDbIT.java 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/SetAllowNullToDbIT.java
deleted file mode 100644
index 580b38a..0000000
--- 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/SetAllowNullToDbIT.java
+++ /dev/null
@@ -1,66 +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.merge;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.sql.Types;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.junit.Test;
-
-public class SetAllowNullToDbIT extends MergeCase {
-
-       @Test
-       public void test() throws Exception {
-               DbEntity dbEntity = map.getDbEntity("PAINTING");
-               assertNotNull(dbEntity);
-
-               // create and add new column to model and db
-               DbAttribute column = new DbAttribute("NEWCOL2", Types.VARCHAR, 
dbEntity);
-
-               try {
-
-                       column.setMandatory(true);
-                       column.setMaxLength(10);
-                       dbEntity.addAttribute(column);
-                       assertTokensAndExecute(2, 0);
-
-                       // check that is was merged
-                       assertTokensAndExecute(0, 0);
-
-                       // set null
-                       column.setMandatory(false);
-
-                       // merge to db
-                       assertTokensAndExecute(1, 0);
-
-                       // check that is was merged
-                       assertTokensAndExecute(0, 0);
-
-                       // clean up
-               } finally {
-                       dbEntity.removeAttribute(column.getName());
-                       assertTokensAndExecute(1, 0);
-                       assertTokensAndExecute(0, 0);
-               }
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/SetNotNullToDbIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/SetNotNullToDbIT.java 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/SetNotNullToDbIT.java
deleted file mode 100644
index f78c77f..0000000
--- 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/SetNotNullToDbIT.java
+++ /dev/null
@@ -1,62 +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.merge;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.sql.Types;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.junit.Test;
-
-public class SetNotNullToDbIT extends MergeCase {
-
-       @Test
-       public void test() throws Exception {
-               DbEntity dbEntity = map.getDbEntity("PAINTING");
-               assertNotNull(dbEntity);
-
-               // create and add new column to model and db
-               DbAttribute column = new DbAttribute("NEWCOL2", Types.VARCHAR, 
dbEntity);
-
-               column.setMandatory(false);
-               column.setMaxLength(10);
-               dbEntity.addAttribute(column);
-               assertTokensAndExecute(1, 0);
-
-               // check that is was merged
-               assertTokensAndExecute(0, 0);
-
-               // set not null
-               column.setMandatory(true);
-
-               // merge to db
-               assertTokensAndExecute(1, 0);
-
-               // check that is was merged
-               assertTokensAndExecute(0, 0);
-
-               // clean up
-               dbEntity.removeAttribute(column.getName());
-               assertTokensAndExecute(1, 0);
-               assertTokensAndExecute(0, 0);
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2f7b1d53/cayenne-server/src/test/java/org/apache/cayenne/merge/SetPrimaryKeyToDbIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/SetPrimaryKeyToDbIT.java
 
b/cayenne-server/src/test/java/org/apache/cayenne/merge/SetPrimaryKeyToDbIT.java
deleted file mode 100644
index 3003b07..0000000
--- 
a/cayenne-server/src/test/java/org/apache/cayenne/merge/SetPrimaryKeyToDbIT.java
+++ /dev/null
@@ -1,58 +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.merge;
-
-import java.sql.Types;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.junit.Test;
-
-public class SetPrimaryKeyToDbIT extends MergeCase {
-
-       @Test
-       public void test() throws Exception {
-               dropTableIfPresent("NEW_TABLE");
-               assertTokensAndExecute(0, 0);
-
-               DbEntity dbEntity1 = new DbEntity("NEW_TABLE");
-
-               DbAttribute e1col1 = new DbAttribute("ID1", Types.INTEGER, 
dbEntity1);
-               e1col1.setMandatory(true);
-               e1col1.setPrimaryKey(true);
-               dbEntity1.addAttribute(e1col1);
-               map.addDbEntity(dbEntity1);
-
-               assertTokensAndExecute(1, 0);
-               assertTokensAndExecute(0, 0);
-
-               DbAttribute e1col2 = new DbAttribute("ID2", Types.INTEGER, 
dbEntity1);
-               e1col2.setMandatory(true);
-               dbEntity1.addAttribute(e1col2);
-
-               assertTokensAndExecute(2, 0);
-               assertTokensAndExecute(0, 0);
-
-               e1col1.setPrimaryKey(false);
-               e1col2.setPrimaryKey(true);
-
-               assertTokensAndExecute(1, 0);
-               assertTokensAndExecute(0, 0);
-       }
-}

Reply via email to