You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2016/09/30 14:23:53 UTC
[7/9] cayenne git commit: CAY-2118 cdbimport: drop support for the
old style of table filtering
CAY-2118 cdbimport: drop support for the old style of table filtering
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/ab6c204f
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/ab6c204f
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/ab6c204f
Branch: refs/heads/master
Commit: ab6c204f3f7cfca715e4eba58a20d9f95e375fc6
Parents: f3d7374
Author: Andrus Adamchik <an...@objectstyle.com>
Authored: Fri Sep 30 15:10:47 2016 +0300
Committer: Andrus Adamchik <an...@objectstyle.com>
Committed: Fri Sep 30 15:36:19 2016 +0300
----------------------------------------------------------------------
.../cayenne/test/resource/ResourceUtil.java | 10 +-
.../DefaultReverseEngineeringLoaderTest.java | 420 +++++++++----------
.../org/apache/cayenne/tools/AntTableType.java | 35 ++
.../apache/cayenne/tools/DbImporterTask.java | 19 +-
.../cayenne/tools/DbImporterTaskTest.java | 385 ++++++++---------
.../tools/build-include-table.map.xml-result | 37 ++
.../cayenne/tools/build-include-table.xml | 34 ++
.../cayenne/tools/build-include-table.xml.sql | 38 ++
.../tools/build-skip-primary-key-loading.xml | 3 +-
.../tools/build-skip-relationships-loading.xml | 6 +-
.../dbimport/build-include-table.map.xml-result | 37 --
.../tools/dbimport/build-include-table.xml | 34 --
.../tools/dbimport/build-include-table.xml.sql | 38 --
13 files changed, 573 insertions(+), 523 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/resource/ResourceUtil.java
----------------------------------------------------------------------
diff --git a/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/resource/ResourceUtil.java b/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/resource/ResourceUtil.java
index 0b5c20a..a8e70a5 100644
--- a/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/resource/ResourceUtil.java
+++ b/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/resource/ResourceUtil.java
@@ -18,8 +18,6 @@
****************************************************************/
package org.apache.cayenne.test.resource;
-import static org.junit.Assert.assertNotNull;
-
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
@@ -30,6 +28,8 @@ import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import static org.junit.Assert.assertNotNull;
+
public class ResourceUtil {
/**
@@ -82,6 +82,12 @@ public class ResourceUtil {
}
public static boolean copyResourceToFile(URL from, File to) {
+
+ File dir = to.getParentFile();
+ if(dir != null) {
+ dir.mkdirs();
+ }
+
int bufSize = 8 * 1024;
try (BufferedInputStream urlin = new BufferedInputStream(from.openConnection().getInputStream(), bufSize);) {
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoaderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoaderTest.java b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoaderTest.java
index 4dcc690..c478db7 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoaderTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoaderTest.java
@@ -19,222 +19,222 @@
package org.apache.cayenne.dbimport;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.apache.cayenne.resource.URLResource;
+import org.junit.Test;
import java.net.MalformedURLException;
import java.util.Iterator;
-import org.apache.cayenne.resource.URLResource;
-import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public class DefaultReverseEngineeringLoaderTest {
- @Test
- public void testLoadCatalog() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-catalog.xml").getURL().openStream());
-
- assertCatalog(engineering);
- }
-
- public static void assertCatalog(ReverseEngineering engineering) {
- Iterator<Catalog> catalogs = engineering.getCatalogs().iterator();
- assertEquals("catalog-name-01", catalogs.next().getName());
- assertEquals("catalog-name-02", catalogs.next().getName());
-
- assertCatalog(catalogs);
- }
-
- public static void assertCatalog(Iterator<Catalog> catalogs) {
- Catalog catalog = catalogs.next();
- assertEquals("catalog-name-03", catalog.getName());
-
- Iterator<IncludeTable> includeTables = catalog.getIncludeTables().iterator();
- assertEquals("includeTable-01", includeTables.next().getPattern());
- assertEquals("includeTable-02", includeTables.next().getPattern());
-
- IncludeTable includeTable = includeTables.next();
- assertEquals("includeTable-03", includeTable.getPattern());
- assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern());
- assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern());
-
- Iterator<ExcludeTable> excludeTables = catalog.getExcludeTables().iterator();
- assertEquals("excludeTable-01", excludeTables.next().getPattern());
- assertEquals("excludeTable-02", excludeTables.next().getPattern());
- assertEquals("excludeTable-03", excludeTables.next().getPattern());
-
- Iterator<ExcludeColumn> excludeColumns = catalog.getExcludeColumns().iterator();
- assertEquals("excludeColumn-01", excludeColumns.next().getPattern());
- assertEquals("excludeColumn-02", excludeColumns.next().getPattern());
- assertEquals("excludeColumn-03", excludeColumns.next().getPattern());
- Iterator<IncludeColumn> includeColumns = catalog.getIncludeColumns().iterator();
- assertEquals("includeColumn-01", includeColumns.next().getPattern());
- assertEquals("includeColumn-02", includeColumns.next().getPattern());
- assertEquals("includeColumn-03", includeColumns.next().getPattern());
-
- Iterator<ExcludeProcedure> excludeProcedures = catalog.getExcludeProcedures().iterator();
- assertEquals("excludeProcedure-01", excludeProcedures.next().getPattern());
- assertEquals("excludeProcedure-02", excludeProcedures.next().getPattern());
- assertEquals("excludeProcedure-03", excludeProcedures.next().getPattern());
- Iterator<IncludeProcedure> includeProcedures = catalog.getIncludeProcedures().iterator();
- assertEquals("includeProcedure-01", includeProcedures.next().getPattern());
- assertEquals("includeProcedure-02", includeProcedures.next().getPattern());
- assertEquals("includeProcedure-03", includeProcedures.next().getPattern());
- }
-
- @Test
- public void testLoadSchema() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-schema.xml").getURL().openStream());
-
- assertSchema(engineering);
- }
-
- public static void assertSchema(ReverseEngineering engineering) {
- Iterator<Schema> schemas = engineering.getSchemas().iterator();
- assertEquals("schema-name-01", schemas.next().getName());
- assertEquals("schema-name-02", schemas.next().getName());
-
- Schema schema = schemas.next();
- assertEquals("schema-name-03", schema.getName());
-
- assertSchemaContent(schema);
- }
-
- public static void assertSchemaContent(Schema schema) {
- Iterator<IncludeTable> includeTables = schema.getIncludeTables().iterator();
- assertEquals("includeTable-01", includeTables.next().getPattern());
- assertEquals("includeTable-02", includeTables.next().getPattern());
-
- IncludeTable includeTable = includeTables.next();
- assertEquals("includeTable-03", includeTable.getPattern());
- assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern());
- assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern());
-
- Iterator<ExcludeTable> excludeTables = schema.getExcludeTables().iterator();
- assertEquals("excludeTable-01", excludeTables.next().getPattern());
- assertEquals("excludeTable-02", excludeTables.next().getPattern());
- assertEquals("excludeTable-03", excludeTables.next().getPattern());
-
- Iterator<ExcludeColumn> excludeColumns = schema.getExcludeColumns().iterator();
- assertEquals("excludeColumn-01", excludeColumns.next().getPattern());
- assertEquals("excludeColumn-02", excludeColumns.next().getPattern());
- assertEquals("excludeColumn-03", excludeColumns.next().getPattern());
- Iterator<IncludeColumn> includeColumns = schema.getIncludeColumns().iterator();
- assertEquals("includeColumn-01", includeColumns.next().getPattern());
- assertEquals("includeColumn-02", includeColumns.next().getPattern());
- assertEquals("includeColumn-03", includeColumns.next().getPattern());
-
- Iterator<ExcludeProcedure> excludeProcedures = schema.getExcludeProcedures().iterator();
- assertEquals("excludeProcedure-01", excludeProcedures.next().getPattern());
- assertEquals("excludeProcedure-02", excludeProcedures.next().getPattern());
- assertEquals("excludeProcedure-03", excludeProcedures.next().getPattern());
- Iterator<IncludeProcedure> includeProcedures = schema.getIncludeProcedures().iterator();
- assertEquals("includeProcedure-01", includeProcedures.next().getPattern());
- assertEquals("includeProcedure-02", includeProcedures.next().getPattern());
- assertEquals("includeProcedure-03", includeProcedures.next().getPattern());
- }
-
- @Test
- public void testLoadCatalogAndSchema() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-catalog-and-schema.xml").getURL().openStream());
-
- assertCatalogAndSchema(engineering);
- }
-
- public static void assertCatalogAndSchema(ReverseEngineering engineering) {
- Catalog catalog = engineering.getCatalogs().iterator().next();
- assertEquals("catalog-name", catalog.getName());
-
- Schema schema = catalog.getSchemas().iterator().next();
- assertEquals("schema-name", schema.getName());
-
- assertSchemaContent(schema);
- }
-
- @Test
- public void testLoadFlat() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-flat.xml").getURL().openStream());
-
- assertFlat(engineering);
- }
-
- public static void assertFlat(ReverseEngineering engineering) {
- Iterator<IncludeTable> includeTables = engineering.getIncludeTables().iterator();
- assertEquals("includeTable-01", includeTables.next().getPattern());
- assertEquals("includeTable-02", includeTables.next().getPattern());
-
- IncludeTable includeTable = includeTables.next();
- assertEquals("includeTable-03", includeTable.getPattern());
- assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern());
- assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern());
-
- Iterator<ExcludeTable> excludeTables = engineering.getExcludeTables().iterator();
- assertEquals("excludeTable-01", excludeTables.next().getPattern());
- assertEquals("excludeTable-02", excludeTables.next().getPattern());
- assertEquals("excludeTable-03", excludeTables.next().getPattern());
-
- Iterator<ExcludeColumn> excludeColumns = engineering.getExcludeColumns().iterator();
- assertEquals("excludeColumn-01", excludeColumns.next().getPattern());
- assertEquals("excludeColumn-02", excludeColumns.next().getPattern());
- assertEquals("excludeColumn-03", excludeColumns.next().getPattern());
- Iterator<IncludeColumn> includeColumns = engineering.getIncludeColumns().iterator();
- assertEquals("includeColumn-01", includeColumns.next().getPattern());
- assertEquals("includeColumn-02", includeColumns.next().getPattern());
- assertEquals("includeColumn-03", includeColumns.next().getPattern());
-
- Iterator<ExcludeProcedure> excludeProcedures = engineering.getExcludeProcedures().iterator();
- assertEquals("excludeProcedure-01", excludeProcedures.next().getPattern());
- assertEquals("excludeProcedure-02", excludeProcedures.next().getPattern());
- assertEquals("excludeProcedure-03", excludeProcedures.next().getPattern());
- Iterator<IncludeProcedure> includeProcedures = engineering.getIncludeProcedures().iterator();
- assertEquals("includeProcedure-01", includeProcedures.next().getPattern());
- assertEquals("includeProcedure-02", includeProcedures.next().getPattern());
- assertEquals("includeProcedure-03", includeProcedures.next().getPattern());
- }
-
- @Test
- public void testSkipRelationships() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-skipRelationshipsLoading.xml").getURL().openStream());
-
- assertSkipRelationshipsLoading(engineering);
- }
-
- public static void assertSkipRelationshipsLoading(ReverseEngineering engineering) {
- assertTrue(engineering.getSkipRelationshipsLoading());
- }
-
- @Test
- public void testSkipPrimaryKeyLoading() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-skipPrimaryKeyLoading.xml").getURL().openStream());
-
- assertSkipPrimaryKeyLoading(engineering);
- }
-
- public static void assertSkipPrimaryKeyLoading(ReverseEngineering engineering) {
- assertTrue(engineering.getSkipPrimaryKeyLoading());
- }
-
- @Test
- public void testTableTypes() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-tableTypes.xml").getURL().openStream());
-
- assertTableTypes(engineering);
- }
-
- public static void assertTableTypes(ReverseEngineering engineering) {
- assertArrayEquals(engineering.getTableTypes(), new String[] { "type1", "type2", "type3" });
- }
-
- protected URLResource getResource(String file) throws MalformedURLException {
- return new URLResource(getClass().getResource(file));
- }
+ public static void assertCatalog(ReverseEngineering engineering) {
+ Iterator<Catalog> catalogs = engineering.getCatalogs().iterator();
+ assertEquals("catalog-name-01", catalogs.next().getName());
+ assertEquals("catalog-name-02", catalogs.next().getName());
+
+ assertCatalog(catalogs);
+ }
+
+ public static void assertCatalog(Iterator<Catalog> catalogs) {
+ Catalog catalog = catalogs.next();
+ assertEquals("catalog-name-03", catalog.getName());
+
+ Iterator<IncludeTable> includeTables = catalog.getIncludeTables().iterator();
+ assertEquals("includeTable-01", includeTables.next().getPattern());
+ assertEquals("includeTable-02", includeTables.next().getPattern());
+
+ IncludeTable includeTable = includeTables.next();
+ assertEquals("includeTable-03", includeTable.getPattern());
+ assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern());
+ assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern());
+
+ Iterator<ExcludeTable> excludeTables = catalog.getExcludeTables().iterator();
+ assertEquals("excludeTable-01", excludeTables.next().getPattern());
+ assertEquals("excludeTable-02", excludeTables.next().getPattern());
+ assertEquals("excludeTable-03", excludeTables.next().getPattern());
+
+ Iterator<ExcludeColumn> excludeColumns = catalog.getExcludeColumns().iterator();
+ assertEquals("excludeColumn-01", excludeColumns.next().getPattern());
+ assertEquals("excludeColumn-02", excludeColumns.next().getPattern());
+ assertEquals("excludeColumn-03", excludeColumns.next().getPattern());
+ Iterator<IncludeColumn> includeColumns = catalog.getIncludeColumns().iterator();
+ assertEquals("includeColumn-01", includeColumns.next().getPattern());
+ assertEquals("includeColumn-02", includeColumns.next().getPattern());
+ assertEquals("includeColumn-03", includeColumns.next().getPattern());
+
+ Iterator<ExcludeProcedure> excludeProcedures = catalog.getExcludeProcedures().iterator();
+ assertEquals("excludeProcedure-01", excludeProcedures.next().getPattern());
+ assertEquals("excludeProcedure-02", excludeProcedures.next().getPattern());
+ assertEquals("excludeProcedure-03", excludeProcedures.next().getPattern());
+ Iterator<IncludeProcedure> includeProcedures = catalog.getIncludeProcedures().iterator();
+ assertEquals("includeProcedure-01", includeProcedures.next().getPattern());
+ assertEquals("includeProcedure-02", includeProcedures.next().getPattern());
+ assertEquals("includeProcedure-03", includeProcedures.next().getPattern());
+ }
+
+ public static void assertSchema(ReverseEngineering engineering) {
+ Iterator<Schema> schemas = engineering.getSchemas().iterator();
+ assertEquals("schema-name-01", schemas.next().getName());
+ assertEquals("schema-name-02", schemas.next().getName());
+
+ Schema schema = schemas.next();
+ assertEquals("schema-name-03", schema.getName());
+
+ assertSchemaContent(schema);
+ }
+
+ public static void assertSchemaContent(Schema schema) {
+ Iterator<IncludeTable> includeTables = schema.getIncludeTables().iterator();
+ assertEquals("includeTable-01", includeTables.next().getPattern());
+ assertEquals("includeTable-02", includeTables.next().getPattern());
+
+ IncludeTable includeTable = includeTables.next();
+ assertEquals("includeTable-03", includeTable.getPattern());
+ assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern());
+ assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern());
+
+ Iterator<ExcludeTable> excludeTables = schema.getExcludeTables().iterator();
+ assertEquals("excludeTable-01", excludeTables.next().getPattern());
+ assertEquals("excludeTable-02", excludeTables.next().getPattern());
+ assertEquals("excludeTable-03", excludeTables.next().getPattern());
+
+ Iterator<ExcludeColumn> excludeColumns = schema.getExcludeColumns().iterator();
+ assertEquals("excludeColumn-01", excludeColumns.next().getPattern());
+ assertEquals("excludeColumn-02", excludeColumns.next().getPattern());
+ assertEquals("excludeColumn-03", excludeColumns.next().getPattern());
+ Iterator<IncludeColumn> includeColumns = schema.getIncludeColumns().iterator();
+ assertEquals("includeColumn-01", includeColumns.next().getPattern());
+ assertEquals("includeColumn-02", includeColumns.next().getPattern());
+ assertEquals("includeColumn-03", includeColumns.next().getPattern());
+
+ Iterator<ExcludeProcedure> excludeProcedures = schema.getExcludeProcedures().iterator();
+ assertEquals("excludeProcedure-01", excludeProcedures.next().getPattern());
+ assertEquals("excludeProcedure-02", excludeProcedures.next().getPattern());
+ assertEquals("excludeProcedure-03", excludeProcedures.next().getPattern());
+ Iterator<IncludeProcedure> includeProcedures = schema.getIncludeProcedures().iterator();
+ assertEquals("includeProcedure-01", includeProcedures.next().getPattern());
+ assertEquals("includeProcedure-02", includeProcedures.next().getPattern());
+ assertEquals("includeProcedure-03", includeProcedures.next().getPattern());
+ }
+
+ public static void assertCatalogAndSchema(ReverseEngineering engineering) {
+ Catalog catalog = engineering.getCatalogs().iterator().next();
+ assertEquals("catalog-name", catalog.getName());
+
+ Schema schema = catalog.getSchemas().iterator().next();
+ assertEquals("schema-name", schema.getName());
+
+ assertSchemaContent(schema);
+ }
+
+ public static void assertFlat(ReverseEngineering engineering) {
+ Iterator<IncludeTable> includeTables = engineering.getIncludeTables().iterator();
+ assertEquals("includeTable-01", includeTables.next().getPattern());
+ assertEquals("includeTable-02", includeTables.next().getPattern());
+
+ IncludeTable includeTable = includeTables.next();
+ assertEquals("includeTable-03", includeTable.getPattern());
+ assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern());
+ assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern());
+
+ Iterator<ExcludeTable> excludeTables = engineering.getExcludeTables().iterator();
+ assertEquals("excludeTable-01", excludeTables.next().getPattern());
+ assertEquals("excludeTable-02", excludeTables.next().getPattern());
+ assertEquals("excludeTable-03", excludeTables.next().getPattern());
+
+ Iterator<ExcludeColumn> excludeColumns = engineering.getExcludeColumns().iterator();
+ assertEquals("excludeColumn-01", excludeColumns.next().getPattern());
+ assertEquals("excludeColumn-02", excludeColumns.next().getPattern());
+ assertEquals("excludeColumn-03", excludeColumns.next().getPattern());
+ Iterator<IncludeColumn> includeColumns = engineering.getIncludeColumns().iterator();
+ assertEquals("includeColumn-01", includeColumns.next().getPattern());
+ assertEquals("includeColumn-02", includeColumns.next().getPattern());
+ assertEquals("includeColumn-03", includeColumns.next().getPattern());
+
+ Iterator<ExcludeProcedure> excludeProcedures = engineering.getExcludeProcedures().iterator();
+ assertEquals("excludeProcedure-01", excludeProcedures.next().getPattern());
+ assertEquals("excludeProcedure-02", excludeProcedures.next().getPattern());
+ assertEquals("excludeProcedure-03", excludeProcedures.next().getPattern());
+ Iterator<IncludeProcedure> includeProcedures = engineering.getIncludeProcedures().iterator();
+ assertEquals("includeProcedure-01", includeProcedures.next().getPattern());
+ assertEquals("includeProcedure-02", includeProcedures.next().getPattern());
+ assertEquals("includeProcedure-03", includeProcedures.next().getPattern());
+ }
+
+ public static void assertSkipRelationshipsLoading(ReverseEngineering engineering) {
+ assertTrue(engineering.getSkipRelationshipsLoading());
+ }
+
+ public static void assertSkipPrimaryKeyLoading(ReverseEngineering engineering) {
+ assertTrue(engineering.getSkipPrimaryKeyLoading());
+ }
+
+ public static void assertTableTypes(ReverseEngineering engineering) {
+ assertArrayEquals(new String[]{"type1", "type2", "type3"}, engineering.getTableTypes());
+ }
+
+ @Test
+ public void testLoadCatalog() throws Exception {
+ ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
+ .load(getResource("reverseEngineering-catalog.xml").getURL().openStream());
+
+ assertCatalog(engineering);
+ }
+
+ @Test
+ public void testLoadSchema() throws Exception {
+ ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
+ .load(getResource("reverseEngineering-schema.xml").getURL().openStream());
+
+ assertSchema(engineering);
+ }
+
+ @Test
+ public void testLoadCatalogAndSchema() throws Exception {
+ ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
+ .load(getResource("reverseEngineering-catalog-and-schema.xml").getURL().openStream());
+
+ assertCatalogAndSchema(engineering);
+ }
+
+ @Test
+ public void testLoadFlat() throws Exception {
+ ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
+ .load(getResource("reverseEngineering-flat.xml").getURL().openStream());
+
+ assertFlat(engineering);
+ }
+
+ @Test
+ public void testSkipRelationships() throws Exception {
+ ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
+ .load(getResource("reverseEngineering-skipRelationshipsLoading.xml").getURL().openStream());
+
+ assertSkipRelationshipsLoading(engineering);
+ }
+
+ @Test
+ public void testSkipPrimaryKeyLoading() throws Exception {
+ ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
+ .load(getResource("reverseEngineering-skipPrimaryKeyLoading.xml").getURL().openStream());
+
+ assertSkipPrimaryKeyLoading(engineering);
+ }
+
+ @Test
+ public void testTableTypes() throws Exception {
+ ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
+ .load(getResource("reverseEngineering-tableTypes.xml").getURL().openStream());
+
+ assertTableTypes(engineering);
+ }
+
+ protected URLResource getResource(String file) throws MalformedURLException {
+ return new URLResource(getClass().getResource(file));
+ }
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java
new file mode 100644
index 0000000..d195f9a
--- /dev/null
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java
@@ -0,0 +1,35 @@
+/*
+ * 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.tools;
+
+public class AntTableType {
+ private String name;
+
+ public void addText(String string) {
+ setName(string);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
index 5954b9f..48498a6 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
@@ -74,46 +74,57 @@ public class DbImporterTask extends Task {
}
public void addIncludeColumn(IncludeColumn includeColumn) {
+ isReverseEngineeringDefined = true;
reverseEngineering.addIncludeColumn(includeColumn);
}
public void addExcludeColumn(ExcludeColumn excludeColumn) {
+ isReverseEngineeringDefined = true;
reverseEngineering.addExcludeColumn(excludeColumn);
}
public void addIncludeTable(IncludeTable includeTable) {
+ isReverseEngineeringDefined = true;
reverseEngineering.addIncludeTable(includeTable);
}
public void addExcludeTable(ExcludeTable excludeTable) {
+ isReverseEngineeringDefined = true;
reverseEngineering.addExcludeTable(excludeTable);
}
public void addIncludeProcedure(IncludeProcedure includeProcedure) {
+ isReverseEngineeringDefined = true;
reverseEngineering.addIncludeProcedure(includeProcedure);
}
public void addExcludeProcedure(ExcludeProcedure excludeProcedure) {
+ isReverseEngineeringDefined = true;
reverseEngineering.addExcludeProcedure(excludeProcedure);
}
- public void addSkipRelationshipsLoading(boolean skipRelationshipsLoading) {
+ public void setSkipRelationshipsLoading(boolean skipRelationshipsLoading) {
+ isReverseEngineeringDefined = true;
reverseEngineering.setSkipRelationshipsLoading(skipRelationshipsLoading);
}
- public void addSkipPrimaryKeyLoading(boolean skipPrimaryKeyLoading) {
+ public void setSkipPrimaryKeyLoading(boolean skipPrimaryKeyLoading) {
+ isReverseEngineeringDefined = true;
reverseEngineering.setSkipPrimaryKeyLoading(skipPrimaryKeyLoading);
}
- public void addTableType(String type) {
- reverseEngineering.addTableType(type);
+ public void addConfiguredTableType(AntTableType type) {
+ isReverseEngineeringDefined = true;
+ reverseEngineering.addTableType(type.getName());
}
public void addConfiguredSchema(Schema schema) {
+ isReverseEngineeringDefined = true;
reverseEngineering.addSchema(schema);
}
public void addCatalog(Catalog catalog) {
+ isReverseEngineeringDefined = true;
reverseEngineering.addCatalog(catalog);
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
index c597036..8806080 100644
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
+++ b/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
@@ -18,23 +18,6 @@
****************************************************************/
package org.apache.cayenne.tools;
-import static org.apache.cayenne.dbimport.DefaultReverseEngineeringLoaderTest.*;
-import static org.apache.commons.lang.StringUtils.isBlank;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-
import org.apache.cayenne.test.file.FileUtil;
import org.apache.cayenne.test.jdbc.SQLReader;
import org.apache.cayenne.test.resource.ResourceUtil;
@@ -50,184 +33,202 @@ import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Test;
import org.xml.sax.SAXException;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+
+import static org.apache.cayenne.dbimport.DefaultReverseEngineeringLoaderTest.assertCatalog;
+import static org.apache.cayenne.dbimport.DefaultReverseEngineeringLoaderTest.assertCatalogAndSchema;
+import static org.apache.cayenne.dbimport.DefaultReverseEngineeringLoaderTest.assertFlat;
+import static org.apache.cayenne.dbimport.DefaultReverseEngineeringLoaderTest.assertSchema;
+import static org.apache.cayenne.dbimport.DefaultReverseEngineeringLoaderTest.assertSkipRelationshipsLoading;
+import static org.apache.cayenne.dbimport.DefaultReverseEngineeringLoaderTest.assertTableTypes;
+import static org.apache.commons.lang.StringUtils.isBlank;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
// TODO: we are only testing on Derby. We may need to dynamically switch between DBs
// based on "cayenneTestConnection", like we do in cayenne-server, etc.
public class DbImporterTaskTest {
- static {
- XMLUnit.setIgnoreWhitespace(true);
- }
-
- @Test
- public void testLoadCatalog() throws Exception {
- assertCatalog(getCdbImport("build-catalog.xml").getReverseEngineering());
- }
-
- @Test
- public void testLoadSchema() throws Exception {
- assertSchema(getCdbImport("build-schema.xml").getReverseEngineering());
- }
-
- @Test
- public void testLoadCatalogAndSchema() throws Exception {
- assertCatalogAndSchema(getCdbImport("build-catalog-and-schema.xml").getReverseEngineering());
- }
-
- @Test
- public void testLoadFlat() throws Exception {
- assertFlat(getCdbImport("build-flat.xml").getReverseEngineering());
- }
-
- @Test
- public void testSkipRelationshipsLoading() throws Exception {
- assertSkipRelationshipsLoading(getCdbImport("build-skip-relationships-loading.xml").getReverseEngineering());
- }
-
- @Test
- public void testTableTypes() throws Exception {
- assertTableTypes(getCdbImport("build-table-types.xml").getReverseEngineering());
- }
-
- @Test
- public void testIncludeTable() throws Exception {
- test("build-include-table.xml");
- }
-
- private DbImporterTask getCdbImport(String buildFile) {
- Project project = new Project();
-
- File map = distDir(buildFile);
- ResourceUtil.copyResourceToFile(getPackagePath() + "/" + buildFile, map);
- ProjectHelper.configureProject(project, map);
-
- UnknownElement task = (UnknownElement) project.getTargets().get("dist").getTasks()[0];
- task.maybeConfigure();
-
- return (DbImporterTask) task.getRealThing();
- }
-
- private static File distDir(String name) {
- File distDir = new File(FileUtil.baseTestDirectory(), "cdbImport");
- File file = new File(distDir, name);
- distDir = file.getParentFile();
- // prepare destination directory
- if (!distDir.exists()) {
- assertTrue(distDir.mkdirs());
- }
- return file;
- }
-
- private String getPackagePath() {
- return getClass().getPackage().getName().replace('.', '/');
- }
-
- private void test(String name) throws Exception {
- DbImporterTask cdbImport = getCdbImport("dbimport/" + name);
- File mapFile = cdbImport.getMap();
- URL mapUrl = this.getClass().getResource("dbimport/" + mapFile.getName());
- if (mapUrl != null && new File(mapUrl.toURI()).exists()) {
- ResourceUtil.copyResourceToFile(mapUrl, mapFile);
- }
-
- URL mapUrlRes = this.getClass().getResource("dbimport/" + mapFile.getName() + "-result");
- if (mapUrlRes != null && new File(mapUrlRes.toURI()).exists()) {
- ResourceUtil
- .copyResourceToFile(mapUrlRes, new File(mapFile.getParentFile(), mapFile.getName() + "-result"));
- }
-
- File mapFileCopy = distDir("copy-" + mapFile.getName());
- if (mapFile.exists()) {
- FileUtils.getFileUtils().copyFile(mapFile, mapFileCopy);
- cdbImport.setMap(mapFileCopy);
- } else {
- mapFileCopy = mapFile;
- }
-
- prepareDatabase(name, cdbImport.toParameters());
-
- try {
- cdbImport.execute();
- verifyResult(mapFile, mapFileCopy);
- } finally {
- cleanDb(cdbImport.toParameters());
- }
- }
-
- private void cleanDb(DbImportConfiguration dbImportConfiguration) throws ClassNotFoundException,
- IllegalAccessException, InstantiationException, SQLException {
- Class.forName(dbImportConfiguration.getDriver()).newInstance();
- // Get a connection
- Connection connection = DriverManager.getConnection(dbImportConfiguration.getUrl());
- Statement stmt = connection.createStatement();
-
- ResultSet tables = connection.getMetaData().getTables(null, null, null, new String[] { "TABLE" });
- while (tables.next()) {
- String schema = tables.getString("TABLE_SCHEM");
- System.out.println("DROP TABLE " + (isBlank(schema) ? "" : schema + ".") + tables.getString("TABLE_NAME"));
- stmt.execute("DROP TABLE " + (isBlank(schema) ? "" : schema + ".") + tables.getString("TABLE_NAME"));
- }
-
- ResultSet schemas = connection.getMetaData().getSchemas();
- while (schemas.next()) {
- String schem = schemas.getString("TABLE_SCHEM");
- if (schem.startsWith("SCHEMA")) {
- System.out.println("DROP SCHEMA " + schem);
- stmt.execute("DROP SCHEMA " + schem + " RESTRICT");
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- private void verifyResult(File map, File mapFileCopy) {
- try {
- FileReader control = new FileReader(map.getAbsolutePath() + "-result");
- FileReader test = new FileReader(mapFileCopy);
-
- DetailedDiff diff = new DetailedDiff(new Diff(control, test));
- if (!diff.similar()) {
- for (Difference d : ((List<Difference>) diff.getAllDifferences())) {
-
- System.out.println("-------------------------------------------");
- System.out.println(d.getTestNodeDetail().getNode());
- System.out.println(d.getControlNodeDetail().getValue());
- }
- fail(diff.toString());
- }
-
- } catch (SAXException e) {
- e.printStackTrace();
- fail();
- } catch (IOException e) {
- e.printStackTrace();
- fail();
- }
- }
-
- private void prepareDatabase(String sqlFile, DbImportConfiguration dbImportConfiguration) throws Exception {
-
- URL sqlUrl = ResourceUtil.getResource(getClass(), "dbimport/" + sqlFile + ".sql");
- assertNotNull(sqlUrl);
-
- Class.forName(dbImportConfiguration.getDriver()).newInstance();
-
- try (Connection c = DriverManager.getConnection(dbImportConfiguration.getUrl());) {
-
- // TODO: move parsing SQL files to a common utility (DBHelper?) .
- // ALso see UnitDbApater.executeDDL - this should use the same
- // utility
-
- try (Statement stmt = c.createStatement();) {
- for (String sql : SQLReader.statements(sqlUrl, ";")) {
-
- // skip comments
- if (sql.startsWith("-- ")) {
- continue;
- }
-
- stmt.execute(sql);
- }
- }
- }
- }
+ static {
+ XMLUnit.setIgnoreWhitespace(true);
+ }
+
+ private static File distDir(String name) {
+ File distDir = new File(FileUtil.baseTestDirectory(), "cdbImport");
+ File file = new File(distDir, name);
+ distDir = file.getParentFile();
+ // prepare destination directory
+ if (!distDir.exists()) {
+ assertTrue(distDir.mkdirs());
+ }
+ return file;
+ }
+
+ @Test
+ public void testLoadCatalog() throws Exception {
+ assertCatalog(getCdbImport("build-catalog.xml").getReverseEngineering());
+ }
+
+ @Test
+ public void testLoadSchema() throws Exception {
+ assertSchema(getCdbImport("build-schema.xml").getReverseEngineering());
+ }
+
+ @Test
+ public void testLoadCatalogAndSchema() throws Exception {
+ assertCatalogAndSchema(getCdbImport("build-catalog-and-schema.xml").getReverseEngineering());
+ }
+
+ @Test
+ public void testLoadFlat() throws Exception {
+ assertFlat(getCdbImport("build-flat.xml").getReverseEngineering());
+ }
+
+ @Test
+ public void testSkipRelationshipsLoading() throws Exception {
+ assertSkipRelationshipsLoading(getCdbImport("build-skip-relationships-loading.xml").getReverseEngineering());
+ }
+
+ @Test
+ public void testTableTypes() throws Exception {
+ assertTableTypes(getCdbImport("build-table-types.xml").getReverseEngineering());
+ }
+
+ @Test
+ public void testIncludeTable() throws Exception {
+ test("build-include-table.xml");
+ }
+
+ private DbImporterTask getCdbImport(String buildFile) {
+ Project project = new Project();
+
+ File map = distDir(buildFile);
+ ResourceUtil.copyResourceToFile(getPackagePath() + "/" + buildFile, map);
+ ProjectHelper.configureProject(project, map);
+
+ UnknownElement task = (UnknownElement) project.getTargets().get("dist").getTasks()[0];
+ task.maybeConfigure();
+
+ return (DbImporterTask) task.getRealThing();
+ }
+
+ private String getPackagePath() {
+ return getClass().getPackage().getName().replace('.', '/');
+ }
+
+ private void test(String name) throws Exception {
+ DbImporterTask cdbImport = getCdbImport(name);
+ File mapFile = cdbImport.getMap();
+
+ URL mapUrlRes = this.getClass().getResource(mapFile.getName() + "-result");
+ assertTrue(mapUrlRes != null && new File(mapUrlRes.toURI()).exists());
+ assertTrue(ResourceUtil
+ .copyResourceToFile(mapUrlRes, new File(mapFile.getParentFile(), mapFile.getName() + "-result")));
+
+
+ File mapFileCopy = distDir("copy-" + mapFile.getName());
+ if (mapFile.exists()) {
+ FileUtils.getFileUtils().copyFile(mapFile, mapFileCopy);
+ cdbImport.setMap(mapFileCopy);
+ } else {
+ mapFileCopy = mapFile;
+ }
+
+ prepareDatabase(name, cdbImport.toParameters());
+
+ try {
+ cdbImport.execute();
+ verifyResult(mapFile, mapFileCopy);
+ } finally {
+ cleanDb(cdbImport.toParameters());
+ }
+ }
+
+ private void cleanDb(DbImportConfiguration dbImportConfiguration) throws ClassNotFoundException,
+ IllegalAccessException, InstantiationException, SQLException {
+ Class.forName(dbImportConfiguration.getDriver()).newInstance();
+ // Get a connection
+ Connection connection = DriverManager.getConnection(dbImportConfiguration.getUrl());
+ Statement stmt = connection.createStatement();
+
+ ResultSet tables = connection.getMetaData().getTables(null, null, null, new String[]{"TABLE"});
+ while (tables.next()) {
+ String schema = tables.getString("TABLE_SCHEM");
+ System.out.println("DROP TABLE " + (isBlank(schema) ? "" : schema + ".") + tables.getString("TABLE_NAME"));
+ stmt.execute("DROP TABLE " + (isBlank(schema) ? "" : schema + ".") + tables.getString("TABLE_NAME"));
+ }
+
+ ResultSet schemas = connection.getMetaData().getSchemas();
+ while (schemas.next()) {
+ String schem = schemas.getString("TABLE_SCHEM");
+ if (schem.startsWith("SCHEMA")) {
+ System.out.println("DROP SCHEMA " + schem);
+ stmt.execute("DROP SCHEMA " + schem + " RESTRICT");
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void verifyResult(File map, File mapFileCopy) {
+ try {
+ FileReader control = new FileReader(map.getAbsolutePath() + "-result");
+ FileReader test = new FileReader(mapFileCopy);
+
+ DetailedDiff diff = new DetailedDiff(new Diff(control, test));
+ if (!diff.similar()) {
+ for (Difference d : ((List<Difference>) diff.getAllDifferences())) {
+
+ System.out.println("-------------------------------------------");
+ System.out.println(d.getTestNodeDetail().getNode());
+ System.out.println(d.getControlNodeDetail().getValue());
+ }
+ fail(diff.toString());
+ }
+
+ } catch (SAXException e) {
+ e.printStackTrace();
+ fail();
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ private void prepareDatabase(String sqlFile, DbImportConfiguration dbImportConfiguration) throws Exception {
+
+ URL sqlUrl = ResourceUtil.getResource(getClass(), sqlFile + ".sql");
+ assertNotNull(sqlUrl);
+
+ Class.forName(dbImportConfiguration.getDriver()).newInstance();
+
+ try (Connection c = DriverManager.getConnection(dbImportConfiguration.getUrl());) {
+
+ // TODO: move parsing SQL files to a common utility (DBHelper?) .
+ // ALso see UnitDbApater.executeDDL - this should use the same
+ // utility
+
+ try (Statement stmt = c.createStatement();) {
+ for (String sql : SQLReader.statements(sqlUrl, ";")) {
+
+ // skip comments
+ if (sql.startsWith("-- ")) {
+ continue;
+ }
+
+ stmt.execute(sql);
+ }
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
new file mode 100644
index 0000000..760ce23
--- /dev/null
+++ b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<data-map xmlns="http://cayenne.apache.org/schema/8/modelMap"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://cayenne.apache.org/schema/8/modelMap http://cayenne.apache.org/schema/8/modelMap.xsd"
+ project-version="8">
+ <db-entity name="PARENT" schema="APP">
+ <db-attribute name="COL2" type="CHAR" length="25"/>
+ <db-attribute name="COL3" type="DECIMAL" length="10" scale="2"/>
+ <db-attribute name="COL4" type="VARCHAR" length="25"/>
+ <db-attribute name="COL5" type="DATE" length="10"/>
+ <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
+ </db-entity>
+ <obj-entity name="Parent" className="Parent" dbEntityName="PARENT">
+ <obj-attribute name="col2" type="java.lang.String" db-attribute-path="COL2"/>
+ <obj-attribute name="col3" type="java.math.BigDecimal" db-attribute-path="COL3"/>
+ <obj-attribute name="col4" type="java.lang.String" db-attribute-path="COL4"/>
+ <obj-attribute name="col5" type="java.util.Date" db-attribute-path="COL5"/>
+ </obj-entity>
+</data-map>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
new file mode 100644
index 0000000..befa01b
--- /dev/null
+++ b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
@@ -0,0 +1,34 @@
+<!--
+ ~ 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.
+ -->
+
+<project name="MyProject" default="dist" basedir="../">
+
+ <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+ classpath="${basedir}"/>
+
+ <target name="dist">
+ <cdbimport map="build-include-table.map.xml"
+ driver="org.apache.derby.jdbc.EmbeddedDriver"
+ url="jdbc:derby:memory:DbImporterMojoTest;create=true">
+ <includeTable>Parent</includeTable>
+ </cdbimport>
+ </target>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
new file mode 100644
index 0000000..e392d08
--- /dev/null
+++ b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
@@ -0,0 +1,38 @@
+-- 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.
+
+
+CREATE TABLE Parent (
+ id INTEGER NOT NULL,
+ COL2 CHAR(25),
+ COL3 DECIMAL(10,2),
+ COL4 VARCHAR(25),
+ COL5 DATE,
+
+ PRIMARY KEY (id),
+ UNIQUE (COL3)
+);
+
+CREATE TABLE Child (
+ id INTEGER NOT NULL,
+ Parent_id CHAR(25),
+ COL3 DECIMAL(10,2),
+ COL4 VARCHAR(25),
+ COL5 DATE,
+
+ PRIMARY KEY (id)
+);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
index bd12051..396b603 100644
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
+++ b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
@@ -27,8 +27,7 @@
adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:hsql://localhost/bookmarker"
- username="sa">
- <skipPrimaryKeyLoading>true</skipPrimaryKeyLoading>
+ username="sa" skipPrimaryKeyLoading="true">
</cdbimport>
</target>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
index 8a3ee50..b2c801b 100644
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
+++ b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
@@ -27,10 +27,8 @@
adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:hsql://localhost/bookmarker"
- username="sa">
-
- <skipRelationshipsLoading>true</skipRelationshipsLoading>
- </cdbimport>
+ username="sa"
+ skipRelationshipsLoading="true"/>
</target>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.map.xml-result
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.map.xml-result b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.map.xml-result
deleted file mode 100644
index 760ce23..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.map.xml-result
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- 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.
--->
-<data-map xmlns="http://cayenne.apache.org/schema/8/modelMap"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://cayenne.apache.org/schema/8/modelMap http://cayenne.apache.org/schema/8/modelMap.xsd"
- project-version="8">
- <db-entity name="PARENT" schema="APP">
- <db-attribute name="COL2" type="CHAR" length="25"/>
- <db-attribute name="COL3" type="DECIMAL" length="10" scale="2"/>
- <db-attribute name="COL4" type="VARCHAR" length="25"/>
- <db-attribute name="COL5" type="DATE" length="10"/>
- <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
- </db-entity>
- <obj-entity name="Parent" className="Parent" dbEntityName="PARENT">
- <obj-attribute name="col2" type="java.lang.String" db-attribute-path="COL2"/>
- <obj-attribute name="col3" type="java.math.BigDecimal" db-attribute-path="COL3"/>
- <obj-attribute name="col4" type="java.lang.String" db-attribute-path="COL4"/>
- <obj-attribute name="col5" type="java.util.Date" db-attribute-path="COL5"/>
- </obj-entity>
-</data-map>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.xml
deleted file mode 100644
index a100fcd..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.xml
+++ /dev/null
@@ -1,34 +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.
- -->
-
-<project name="MyProject" default="dist" basedir="../">
-
- <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
- classpath="${basedir}"/>
-
- <target name="dist">
- <cdbimport map="dbimport/build-include-table.map.xml"
- driver="org.apache.derby.jdbc.EmbeddedDriver"
- url="jdbc:derby:memory:DbImporterMojoTest;create=true">
- <includeTable>Parent</includeTable>
- </cdbimport>
- </target>
-
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab6c204f/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.xml.sql
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.xml.sql b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.xml.sql
deleted file mode 100644
index e392d08..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/build-include-table.xml.sql
+++ /dev/null
@@ -1,38 +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.
-
-
-CREATE TABLE Parent (
- id INTEGER NOT NULL,
- COL2 CHAR(25),
- COL3 DECIMAL(10,2),
- COL4 VARCHAR(25),
- COL5 DATE,
-
- PRIMARY KEY (id),
- UNIQUE (COL3)
-);
-
-CREATE TABLE Child (
- id INTEGER NOT NULL,
- Parent_id CHAR(25),
- COL3 DECIMAL(10,2),
- COL4 VARCHAR(25),
- COL5 DATE,
-
- PRIMARY KEY (id)
-);
\ No newline at end of file