cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: CAY-1946 CDbimport improvements
Date Mon, 01 Dec 2014 14:37:12 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 2c06db649 -> 1ab1caa9f


CAY-1946 CDbimport improvements

    fixing DataMap initialization sequence to solve defaultPackage issue
    test for default package


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/1ab1caa9
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/1ab1caa9
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/1ab1caa9

Branch: refs/heads/master
Commit: 1ab1caa9fd999ccc1abbffb3b1d42bc3e61573a2
Parents: 2c06db6
Author: aadamchik <aadamchik@apache.org>
Authored: Mon Dec 1 17:26:59 2014 +0300
Committer: aadamchik <aadamchik@apache.org>
Committed: Mon Dec 1 17:26:59 2014 +0300

----------------------------------------------------------------------
 .../org/apache/cayenne/access/DbLoader.java     | 66 +++++++-------------
 .../access/loader/DbLoaderConfiguration.java    |  2 +-
 .../java/org/apache/cayenne/merge/DbMerger.java | 28 ++++-----
 .../cayenne/tools/dbimport/DbImportAction.java  | 27 ++++----
 .../tools/dbimport/DbImportActionTest.java      | 58 ++++++++++-------
 .../modeler/dialog/db/DbLoaderHelper.java       |  8 +--
 .../apache/cayenne/tools/DbImporterMojo.java    | 15 ++---
 .../tools/DbImporterMojoConfigurationTest.java  | 16 +++--
 .../cayenne/tools/DbImporterMojoTest.java       |  4 ++
 .../tools/config/pom-default-package.xml        | 36 +++++++++++
 .../tools/dbimport/testDefaultPackage-pom.xml   | 42 +++++++++++++
 .../dbimport/testDefaultPackage.map.xml-result  | 52 +++++++++++++++
 .../tools/dbimport/testDefaultPackage.sql       | 40 ++++++++++++
 13 files changed, 280 insertions(+), 114 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java b/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
index 8e37da1..d759213 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
@@ -703,19 +703,15 @@ public class DbLoader {
      *             method that supports catalogs.
      */
     @Deprecated
-    public DataMap loadDataMapFromDB(String schemaPattern, String tablePattern, DataMap dataMap)
throws SQLException {
+	public DataMap loadDataMapFromDB(String schemaPattern, String tablePattern, DataMap dataMap)
throws SQLException {
 
-        String[] types = getDefaultTableTypes();
-        if (types.length == 0) {
-            throw new SQLException("No supported table types found.");
-        }
+		DbLoaderConfiguration configuration = new DbLoaderConfiguration();
+		configuration.setFiltersConfig(new FiltersConfig(new EntityFilters(new DbPath(null, schemaPattern),
+				include(tablePattern), TRUE, NULL)));
 
-        DbLoaderConfiguration configuration = new DbLoaderConfiguration();
-        configuration.setFiltersConfig(new FiltersConfig(new EntityFilters(
-                new DbPath(null, schemaPattern), include(tablePattern), TRUE, NULL)));
-        load(dataMap, configuration, types);
-        return dataMap;
-    }
+		load(dataMap, configuration);
+		return dataMap;
+	}
 
     /**
      * Performs database reverse engineering and generates DataMap object that
@@ -734,8 +730,9 @@ public class DbLoader {
         DbLoaderConfiguration config = new DbLoaderConfiguration();
         config.setFiltersConfig(new FiltersConfig(new EntityFilters(
                 new DbPath(null, schemaPattern), transformPatternToFilter(tablePattern),
TRUE, NULL)));
-
-        load(dataMap, config, tableTypes);
+        config.setTableTypes(tableTypes);
+        
+        load(dataMap, config);
         return dataMap;
     }
 
@@ -750,42 +747,27 @@ public class DbLoader {
     }
 
     /**
-     * Performs database reverse engineering to match the specified catalog,
-     * schema, table name and table type patterns and fills the specified
+     * Performs database reverse engineering based on the specified config 
+     * and fills the specified
      * DataMap object with DB and object mapping info.
-     * 
+     *
      * @since 4.0
      */
-    public void load(DataMap dataMap, DbLoaderConfiguration config, String... tableTypes)
throws SQLException {
-
-        List<DbEntity> entities = loadDbEntities(dataMap, config, getTables(config,
tableTypes));
-
-        if (entities != null) {
-            loadDbRelationships(dataMap, config, entities);
-            loadObjEntities(dataMap, config, entities);
+	public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException {
 
-            flattenManyToManyRelationships(dataMap);
-            fireObjEntitiesAddedEvents(dataMap);
-        }
-    }
-
-    /**
-     * Performs database reverse engineering to match the specified catalog,
-     * schema, table name and table type patterns and fills the specified
-     * DataMap object with DB and object mapping info.
-     *
-     * @since 3.2
-     */
-    public DataMap load(DbLoaderConfiguration config) throws SQLException {
+		String[] tableTypes = config.getTableTypes() == null ? this.getDefaultTableTypes() : config.getTableTypes();
+		List<DbEntity> entities = loadDbEntities(dataMap, config, getTables(config, tableTypes));
 
-        DataMap dataMap = new DataMap();
-        String[] tableTypes = config.getTableTypes() == null ? this.getDefaultTableTypes()
: config.getTableTypes();
+		if (entities != null) {
+			loadDbRelationships(dataMap, config, entities);
+			loadObjEntities(dataMap, config, entities);
 
-        load(dataMap, config, tableTypes);
-        loadProcedures(dataMap, config);
+			flattenManyToManyRelationships(dataMap);
+			fireObjEntitiesAddedEvents(dataMap);
+		}
 
-        return dataMap;
-    }
+		loadProcedures(dataMap, config);
+	}
 
     /**
      * Loads database stored procedures into the DataMap.

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/cayenne-server/src/main/java/org/apache/cayenne/access/loader/DbLoaderConfiguration.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/DbLoaderConfiguration.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/DbLoaderConfiguration.java
index 461c687..6c6a628 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/DbLoaderConfiguration.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/DbLoaderConfiguration.java
@@ -24,7 +24,7 @@ import org.apache.cayenne.access.loader.filters.FilterFactory;
 import org.apache.cayenne.access.loader.filters.FiltersConfig;
 
 /**
- * @since 3.2.
+ * @since 4.0
  */
 public class DbLoaderConfiguration {
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/cayenne-server/src/main/java/org/apache/cayenne/merge/DbMerger.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/merge/DbMerger.java b/cayenne-server/src/main/java/org/apache/cayenne/merge/DbMerger.java
index 31cb65c..f036511 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/merge/DbMerger.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/merge/DbMerger.java
@@ -18,12 +18,24 @@
  */
 package org.apache.cayenne.merge;
 
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import javax.sql.DataSource;
+
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.DbLoader;
 import org.apache.cayenne.access.loader.DbLoaderConfiguration;
 import org.apache.cayenne.access.loader.DefaultDbLoaderDelegate;
-import org.apache.cayenne.access.loader.NameFilter;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DataMap;
@@ -33,18 +45,6 @@ import org.apache.cayenne.map.DbJoin;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.DetectedDbEntity;
 
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
 /**
  * Traverse a {@link DataNode} and a {@link DataMap} and create a group of
  * {@link MergerToken}s to alter the {@link DataNode} data store to match the
@@ -153,7 +153,7 @@ public class DbMerger {
     private DataMap loadDataMapFromDb(DbLoader dbLoader, DbLoaderConfiguration config) {
         DataMap detectedDataMap = new DataMap();
         try {
-            dbLoader.load(detectedDataMap, config, (String[]) null);
+            dbLoader.load(detectedDataMap, config);
         } catch (SQLException e) {
             // TODO log
         }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportAction.java
b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportAction.java
index bb94fcd..8499b20 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportAction.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportAction.java
@@ -81,7 +81,7 @@ public class DbImportAction {
 
     public void execute(DbImportConfiguration config) throws Exception {
 
-        if (logger.isInfoEnabled()) {
+        if (logger.isDebugEnabled()) {
             logger.debug("DB connection: " + config.getDataSourceInfo());
         }
 
@@ -184,19 +184,18 @@ public class DbImportAction {
         projectSaver.save(project);
     }
 
-    private DataMap load(DbImportConfiguration config, DbAdapter adapter, Connection connection)
throws Exception {
-        DataMap dataMap = config.createDataMap();
-
-        try {
-            DbLoader loader = config.createLoader(adapter, connection, config.createLoaderDelegate());
+	private DataMap load(DbImportConfiguration config, DbAdapter adapter, Connection connection)
throws Exception {
+		DataMap dataMap = config.createDataMap();
 
-            dataMap = loader.load(config.getDbLoaderConfig());
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
+		try {
+			DbLoader loader = config.createLoader(adapter, connection, config.createLoaderDelegate());
+			loader.load(dataMap, config.getDbLoaderConfig());
+		} finally {
+			if (connection != null) {
+				connection.close();
+			}
+		}
 
-        return dataMap;
-    }
+		return dataMap;
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DbImportActionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DbImportActionTest.java
b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DbImportActionTest.java
index 72d1df4..a2fb0f1 100644
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DbImportActionTest.java
+++ b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DbImportActionTest.java
@@ -18,10 +18,36 @@
  */
 package org.apache.cayenne.tools.dbimport;
 
+import static org.apache.cayenne.merge.builders.ObjectMother.dbAttr;
+import static org.apache.cayenne.merge.builders.ObjectMother.dbEntity;
+import static org.apache.cayenne.merge.builders.ObjectMother.objAttr;
+import static org.apache.cayenne.merge.builders.ObjectMother.objEntity;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.stub;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DbLoader;
-import org.apache.cayenne.access.loader.DbLoaderConfiguration;
 import org.apache.cayenne.access.DbLoaderDelegate;
+import org.apache.cayenne.access.loader.DbLoaderConfiguration;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.configuration.server.DataSourceFactory;
 import org.apache.cayenne.configuration.server.DbAdapterFactory;
@@ -43,16 +69,6 @@ import org.apache.commons.logging.Log;
 import org.junit.Test;
 import org.xml.sax.InputSource;
 
-import javax.sql.DataSource;
-import java.io.File;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import static org.apache.cayenne.merge.builders.ObjectMother.*;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
 public class DbImportActionTest {
 
     public static final File FILE_STUB = new File("") {
@@ -72,8 +88,8 @@ public class DbImportActionTest {
 
         DbLoader dbLoader = new DbLoader(null, null, null) {
             @Override
-            public DataMap load(DbLoaderConfiguration config) throws SQLException {
-                return new DataMapBuilder(new DataMap()).withDbEntities(2).build();
+            public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException
{
+                 new DataMapBuilder(dataMap).withDbEntities(2).build();
             }
 
             @Override
@@ -113,8 +129,7 @@ public class DbImportActionTest {
     public void testImportWithFieldChanged() throws Exception {
         DbLoader dbLoader = new DbLoader(null, null, null) {
             @Override
-            public DataMap load(DbLoaderConfiguration config) throws SQLException {
-                DataMap dataMap = new DataMap("dataMap");
+            public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException
{
                 new DataMapBuilder(dataMap).with(
                         dbEntity("ARTGROUP").attributes(
                                 dbAttr("GROUP_ID").typeInt().primaryKey(),
@@ -125,8 +140,6 @@ public class DbImportActionTest {
                         objEntity("org.apache.cayenne.testdo.testmap", "ArtGroup", "ARTGROUP").attributes(
                                 objAttr("name").type(String.class).dbPath("NAME")
                 ));
-
-                return dataMap;
             }
 
             @Override
@@ -185,13 +198,11 @@ public class DbImportActionTest {
     public void testImportWithoutChanges() throws Exception {
         DbLoader dbLoader = new DbLoader(null, null, null) {
             @Override
-            public DataMap load(DbLoaderConfiguration config) throws SQLException {
-                DataMap dataMap = new DataMap("dataMap");
+            public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException
{
                 new DataMapBuilder(dataMap).with(
                         dbEntity("ARTGROUP").attributes(
                                 dbAttr("NAME").typeVarchar(100).mandatory()
                         ));
-                return dataMap;
             }
 
             @Override
@@ -248,7 +259,12 @@ public class DbImportActionTest {
 
         DbImportAction action = buildDbImportAction(projectSaver, mapLoader);
 
-        action.execute(params);
+		try {
+			action.execute(params);
+			fail();
+		} catch (SQLException e) {
+			// expected
+		}
 
         verify(projectSaver, never()).save(any(Project.class));
         verify(mapLoader, never()).loadDataMap(any(InputSource.class));

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
index 4776507..64fc8c6 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
@@ -408,15 +408,11 @@ public class DbLoaderHelper {
             loadStatusNote = "Importing tables...";
             try {
                 loader.setCreatingMeaningfulPK(meaningfulPk);
-                String[] types = loader.getDefaultTableTypes();
-                if (types.length == 0) {
-                    throw new SQLException("No supported table types found.");
-                }
-
+               
                 DbLoaderConfiguration configuration = new DbLoaderConfiguration();
                 configuration.setFiltersConfig(new FiltersConfigBuilder(new ReverseEngineering())
                         .add(filterBuilder.build()).filtersConfig());
-                loader.load(dataMap, configuration, types);
+                loader.load(dataMap, configuration);
 
                 /**
                  * Update default rules for relationships

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
b/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
index 5354f9d..4fcf401 100644
--- a/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
+++ b/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
@@ -19,26 +19,19 @@
 package org.apache.cayenne.tools;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
 
 import org.apache.cayenne.access.loader.filters.EntityFilters;
 import org.apache.cayenne.access.loader.filters.FilterFactory;
-import org.apache.cayenne.tools.dbimport.config.Catalog;
-import org.apache.cayenne.tools.dbimport.config.ExcludeColumn;
-import org.apache.cayenne.tools.dbimport.config.ExcludeProcedure;
-import org.apache.cayenne.tools.dbimport.config.FiltersConfigBuilder;
-import org.apache.cayenne.tools.dbimport.config.IncludeColumn;
-import org.apache.cayenne.tools.dbimport.config.IncludeProcedure;
-import org.apache.cayenne.tools.dbimport.config.IncludeTable;
-import org.apache.cayenne.tools.dbimport.config.ReverseEngineering;
-import org.apache.cayenne.tools.dbimport.config.Schema;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.tools.configuration.ToolsModule;
 import org.apache.cayenne.tools.dbimport.DbImportAction;
 import org.apache.cayenne.tools.dbimport.DbImportConfiguration;
 import org.apache.cayenne.tools.dbimport.DbImportModule;
+import org.apache.cayenne.tools.dbimport.config.Catalog;
+import org.apache.cayenne.tools.dbimport.config.FiltersConfigBuilder;
+import org.apache.cayenne.tools.dbimport.config.ReverseEngineering;
+import org.apache.cayenne.tools.dbimport.config.Schema;
 import org.apache.cayenne.util.Util;
 import org.apache.commons.logging.Log;
 import org.apache.maven.plugin.AbstractMojo;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
index 49fd23a..939f185 100644
--- a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
+++ b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
@@ -18,16 +18,16 @@
  ****************************************************************/
 package org.apache.cayenne.tools;
 
-import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.*;
-import static org.junit.Assert.assertEquals;
+import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertCatalog;
+import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertCatalogAndSchema;
+import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertFlat;
+import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertSchemaContent;
 
+import org.apache.cayenne.tools.dbimport.DbImportConfiguration;
 import org.apache.cayenne.tools.dbimport.config.Schema;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.junit.Test;
 
-/**
- * @since 3.2.
- */
 public class DbImporterMojoConfigurationTest extends AbstractMojoTestCase {
 
     @Test
@@ -47,6 +47,12 @@ public class DbImporterMojoConfigurationTest extends AbstractMojoTestCase
{
     public void testLoadCatalogAndSchema() throws Exception {
         assertCatalogAndSchema(getCdbImport("pom-catalog-and-schema.xml").getReverseEngineering());
     }
+    
+	@Test
+	public void testDefaultPackage() throws Exception {
+		DbImportConfiguration config = getCdbImport("pom-default-package.xml").toParameters();
+		assertEquals("com.example.test", config.getDefaultPackage());
+	}
 
     @Test
     public void testLoadFlat() throws Exception {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
index 9a36e60..3b7e7e2 100644
--- a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
+++ b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
@@ -107,6 +107,10 @@ public class DbImporterMojoTest extends AbstractMojoTestCase {
 	public void testViewsExclude() throws Exception {
 		test("testViewsExclude");
 	}
+	
+	public void testDefaultPackage() throws Exception {
+		test("testDefaultPackage");
+	}
 
 	private void test(String name) throws Exception {
 		DbImporterMojo cdbImport = getCdbImport("dbimport/" + name + "-pom.xml");

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-default-package.xml
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-default-package.xml
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-default-package.xml
new file mode 100644
index 0000000..81acfb3
--- /dev/null
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-default-package.xml
@@ -0,0 +1,36 @@
+<?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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+	http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-cayenne-plugin</artifactId>
+                <configuration>
+                    <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+                    <defaultPackage>com.example.test</defaultPackage>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage-pom.xml
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage-pom.xml
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage-pom.xml
new file mode 100644
index 0000000..10d85e6
--- /dev/null
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage-pom.xml
@@ -0,0 +1,42 @@
+<?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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+	http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+	<name>DbImporterMojo Test1</name>	
+
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-cayenne-plugin</artifactId>
+				<configuration>
+					<map>target/test-classes/org/apache/cayenne/tools/dbimport/testDefaultPackage.map.xml</map>
+                    <defaultPackage>com.example.test</defaultPackage>
+                    <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
+                    <url>jdbc:derby:memory:DbImporterMojoTest;create=true</url>
+
+                    <schema>SCHEMA_01</schema>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage.map.xml-result
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage.map.xml-result
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage.map.xml-result
new file mode 100644
index 0000000..3624e3c
--- /dev/null
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage.map.xml-result
@@ -0,0 +1,52 @@
+<?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/7/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+          project-version="7">
+    <property name="defaultPackage" value="com.example.test"/>
+    <property name="defaultSchema" value="SCHEMA_01"/>
+    <db-entity name="CHILD" schema="SCHEMA_01">
+        <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-attribute name="PARENT_ID" type="CHAR" length="25"/>
+    </db-entity>
+    <db-entity name="PARENT" schema="SCHEMA_01">
+        <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="Child" className="com.example.test.Child" dbEntityName="CHILD">
+        <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-attribute name="parentId" type="java.lang.String" db-attribute-path="PARENT_ID"/>
+    </obj-entity>
+    <obj-entity name="Parent" className="com.example.test.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>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ab1caa9/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage.sql
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage.sql
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage.sql
new file mode 100644
index 0000000..279065c
--- /dev/null
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDefaultPackage.sql
@@ -0,0 +1,40 @@
+--  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 SCHEMA schema_01;
+SET SCHEMA schema_01;
+
+CREATE TABLE schema_01.Parent (
+  id INTEGER NOT NULL,
+  COL2 CHAR(25),
+  COL3 DECIMAL(10,2),
+  COL4 VARCHAR(25),
+  COL5 DATE,
+
+  PRIMARY KEY (id),
+  UNIQUE (COL3)
+);
+
+CREATE TABLE schema_01.Child (
+  id INTEGER NOT NULL,
+  Parent_id CHAR(25),
+  COL3 DECIMAL(10,2),
+  COL4 VARCHAR(25),
+  COL5 DATE,
+
+  PRIMARY KEY (id)
+);


Mime
View raw message