You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2017/02/01 13:23:57 UTC
[09/10] cayenne git commit: CAY-2215 split cayenne-tools into
cayenne-cgen and cayenne-ant
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java b/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
new file mode 100644
index 0000000..f6f616b
--- /dev/null
+++ b/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
@@ -0,0 +1,317 @@
+/*****************************************************************
+ * 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;
+
+import org.apache.cayenne.test.file.FileUtil;
+import org.apache.cayenne.test.resource.ResourceUtil;
+import org.apache.tools.ant.Location;
+import org.apache.tools.ant.Project;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.regex.Pattern;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class CayenneGeneratorTaskTest {
+
+ private static final File baseDir;
+ private static final File map;
+ private static final File mapEmbeddables;
+ private static final File template;
+
+ static {
+
+ baseDir = FileUtil.baseTestDirectory();
+ map = new File(baseDir, "antmap.xml");
+ mapEmbeddables = new File(baseDir, "antmap-embeddables.xml");
+ template = new File(baseDir, "velotemplate.vm");
+
+ ResourceUtil.copyResourceToFile("testmap.map.xml", map);
+ ResourceUtil.copyResourceToFile("embeddable.map.xml", mapEmbeddables);
+ ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/velotemplate.vm", template);
+ }
+
+ protected CayenneGeneratorTask task;
+
+ @Before
+ public void setUp() {
+
+ Project project = new Project();
+ project.setBaseDir(baseDir);
+
+ task = new CayenneGeneratorTask();
+ task.setProject(project);
+ task.setTaskName("Test");
+ task.setLocation(Location.UNKNOWN_LOCATION);
+ }
+
+ /**
+ * Test single classes with a non-standard template.
+ */
+ @Test
+ public void testSingleClassesCustTemplate() throws Exception {
+ // prepare destination directory
+ File mapDir = new File(baseDir, "single-classes-custtempl");
+ assertTrue(mapDir.mkdirs());
+
+ // setup task
+ task.setDestDir(mapDir);
+ task.setMap(map);
+ task.setMakepairs(false);
+ task.setUsepkgpath(true);
+ task.setTemplate(template.getPath());
+
+ // run task
+ task.execute();
+
+ // check results
+ File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+ assertTrue(a.isFile());
+ assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
+
+ File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/_Artist.java"));
+ assertFalse(_a.exists());
+ }
+
+ /** Test single classes generation including full package path. */
+ @Test
+ public void testSingleClasses1() throws Exception {
+ // prepare destination directory
+ File mapDir = new File(baseDir, "single-classes-tree");
+ assertTrue(mapDir.mkdirs());
+
+ // setup task
+ task.setDestDir(mapDir);
+ task.setMap(map);
+ task.setMakepairs(false);
+ task.setUsepkgpath(true);
+
+ // run task
+ task.execute();
+
+ // check results
+ File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+ assertTrue(a.isFile());
+ assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
+
+ File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/_Artist.java"));
+ assertFalse(_a.exists());
+ }
+
+ /** Test single classes generation ignoring package path. */
+ @Test
+ public void testSingleClasses2() throws Exception {
+ // prepare destination directory
+ File mapDir = new File(baseDir, "single-classes-flat");
+ assertTrue(mapDir.mkdirs());
+
+ // setup task
+ task.setDestDir(mapDir);
+ task.setMap(map);
+ task.setMakepairs(false);
+ task.setUsepkgpath(false);
+
+ // run task
+ task.execute();
+
+ // check results
+ File a = new File(mapDir, convertPath("Artist.java"));
+ assertTrue(a.exists());
+ assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
+
+ File _a = new File(mapDir, convertPath("_Artist.java"));
+ assertFalse(_a.exists());
+
+ File pkga = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+ assertFalse(pkga.exists());
+ }
+
+ /**
+ * Test pairs generation including full package path, default superclass
+ * package.
+ */
+ @Test
+ public void testPairs1() throws Exception {
+ // prepare destination directory
+ File mapDir = new File(baseDir, "pairs-tree");
+ assertTrue(mapDir.mkdirs());
+
+ // setup task
+ task.setDestDir(mapDir);
+ task.setMap(map);
+ task.setMakepairs(true);
+ task.setUsepkgpath(true);
+
+ // run task
+ task.execute();
+
+ // check results
+ File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+ assertTrue(a.isFile());
+ assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "_Artist");
+
+ File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/auto/_Artist.java"));
+ assertTrue(_a.exists());
+ assertContents(_a, "_Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
+ }
+
+ /** Test pairs generation in the same directory. */
+ @Test
+ public void testPairs2() throws Exception {
+ // prepare destination directory
+ File mapDir = new File(baseDir, "pairs-flat");
+ assertTrue(mapDir.mkdirs());
+
+ // setup task
+ task.setDestDir(mapDir);
+ task.setMap(map);
+ task.setMakepairs(true);
+ task.setUsepkgpath(false);
+
+ // run task
+ task.execute();
+
+ // check results
+ File a = new File(mapDir, convertPath("Artist.java"));
+ assertTrue(a.isFile());
+ assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "_Artist");
+
+ File _a = new File(mapDir, convertPath("_Artist.java"));
+ assertTrue(_a.exists());
+ assertContents(_a, "_Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
+
+ File pkga = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+ assertFalse(pkga.exists());
+ }
+
+ /**
+ * Test pairs generation including full package path with superclass and
+ * subclass in different packages.
+ */
+ @Test
+ public void testPairs3() throws Exception {
+ // prepare destination directory
+ File mapDir = new File(baseDir, "pairs-tree-split");
+ assertTrue(mapDir.mkdirs());
+
+ // setup task
+ task.setDestDir(mapDir);
+ task.setMap(map);
+ task.setMakepairs(true);
+ task.setUsepkgpath(true);
+ task.setSuperpkg("org.apache.cayenne.testdo.testmap.superart");
+
+ // run task
+ task.execute();
+
+ // check results
+ File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+ assertTrue(a.isFile());
+ assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "_Artist");
+
+ File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/superart/_Artist.java"));
+ assertTrue(_a.exists());
+ assertContents(_a, "_Artist", "org.apache.cayenne.testdo.testmap.superart", "CayenneDataObject");
+ }
+
+ @Test
+ public void testPairsEmbeddable3() throws Exception {
+ // prepare destination directory
+ File mapDir = new File(baseDir, "pairs-embeddables3-split");
+ assertTrue(mapDir.mkdirs());
+
+ // setup task
+ task.setDestDir(mapDir);
+ task.setMap(mapEmbeddables);
+ task.setMakepairs(true);
+ task.setUsepkgpath(true);
+ task.setSuperpkg("org.apache.cayenne.testdo.embeddable.auto");
+
+ // run task
+ task.execute();
+
+ // check entity results
+ File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/EmbedEntity1.java"));
+ assertTrue(a.isFile());
+ assertContents(a, "EmbedEntity1", "org.apache.cayenne.testdo.embeddable", "_EmbedEntity1");
+
+ File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/auto/_EmbedEntity1.java"));
+ assertTrue(_a.exists());
+ assertContents(_a, "_EmbedEntity1", "org.apache.cayenne.testdo.embeddable.auto", "CayenneDataObject");
+
+ // check embeddable results
+ File e = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/Embeddable1.java"));
+ assertTrue(e.isFile());
+ assertContents(e, "Embeddable1", "org.apache.cayenne.testdo.embeddable", "_Embeddable1");
+
+ File _e = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/auto/_Embeddable1.java"));
+ assertTrue(_e.exists());
+ assertContents(_e, "_Embeddable1", "org.apache.cayenne.testdo.embeddable.auto", "Object");
+ }
+
+ private String convertPath(String unixPath) {
+ return unixPath.replace('/', File.separatorChar);
+ }
+
+ private void assertContents(File f, String className, String packageName, String extendsName) throws Exception {
+
+ try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f)));) {
+ assertPackage(in, packageName);
+ assertClass(in, className, extendsName);
+ }
+ }
+
+ private void assertPackage(BufferedReader in, String packageName) throws Exception {
+
+ String s = null;
+ while ((s = in.readLine()) != null) {
+ if (Pattern.matches("^package\\s+([^\\s;]+);", s)) {
+ assertTrue(s.indexOf(packageName) > 0);
+ return;
+ }
+ }
+
+ fail("No package declaration found.");
+ }
+
+ private void assertClass(BufferedReader in, String className, String extendsName) throws Exception {
+
+ Pattern classPattern = Pattern.compile("^public\\s+");
+
+ String s = null;
+ while ((s = in.readLine()) != null) {
+ if (classPattern.matcher(s).find()) {
+ assertTrue(s.indexOf(className) > 0);
+ assertTrue(s.indexOf(extendsName) > 0);
+ assertTrue(s.indexOf(className) < s.indexOf(extendsName));
+ return;
+ }
+ }
+
+ fail("No class declaration found.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java b/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java
new file mode 100644
index 0000000..bd02e12
--- /dev/null
+++ b/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java
@@ -0,0 +1,75 @@
+/*****************************************************************
+ * 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;
+
+import org.apache.cayenne.dba.AutoAdapter;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.sqlserver.SQLServerAdapter;
+import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.commons.logging.Log;
+import org.junit.Test;
+
+import javax.sql.DataSource;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public class DbGeneratorTaskTest {
+
+ @Test
+ public void testSetUserName() throws Exception {
+ DbGeneratorTask task = new DbGeneratorTask();
+ task.setUserName("abc");
+ assertEquals("abc", task.userName);
+ }
+
+ @Test
+ public void testSetPassword() throws Exception {
+ DbGeneratorTask task = new DbGeneratorTask();
+ task.setPassword("xyz");
+ assertEquals("xyz", task.password);
+ }
+
+ @Test
+ public void testSetAdapter() throws Exception {
+ DataSource ds = mock(DataSource.class);
+ Injector injector = DIBootstrap.createInjector(new ToolsModule(mock(Log.class)));
+
+ DbGeneratorTask task = new DbGeneratorTask();
+
+ DbAdapter autoAdapter = task.getAdapter(injector, ds);
+ assertTrue(autoAdapter instanceof AutoAdapter);
+
+ task.setAdapter(SQLServerAdapter.class.getName());
+
+ DbAdapter sqlServerAdapter = task.getAdapter(injector, ds);
+ assertTrue(sqlServerAdapter instanceof SQLServerAdapter);
+ }
+
+ @Test
+ public void testSetUrl() throws Exception {
+ DbGeneratorTask task = new DbGeneratorTask();
+ task.setUrl("jdbc:///");
+ assertEquals("jdbc:///", task.url);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java b/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
new file mode 100644
index 0000000..df746c2
--- /dev/null
+++ b/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
@@ -0,0 +1,229 @@
+/*****************************************************************
+ * 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;
+
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration;
+import org.apache.cayenne.test.file.FileUtil;
+import org.apache.cayenne.test.jdbc.SQLReader;
+import org.apache.cayenne.test.resource.ResourceUtil;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.UnknownElement;
+import org.apache.tools.ant.util.FileUtils;
+import org.custommonkey.xmlunit.DetailedDiff;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.Difference;
+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.dbsync.reverse.dbimport.ReverseEngineeringUtils.*;
+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);
+ }
+
+ 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/c63b6be2/cayenne-ant/src/test/resources/embeddable.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/embeddable.map.xml b/cayenne-ant/src/test/resources/embeddable.map.xml
new file mode 100644
index 0000000..0b5c0b8
--- /dev/null
+++ b/cayenne-ant/src/test/resources/embeddable.map.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
+ project-version="6">
+ <property name="defaultPackage" value="org.apache.cayenne.testdo.embeddable"/>
+ <embeddable className="org.apache.cayenne.testdo.embeddable.Embeddable1">
+ <embeddable-attribute name="embedded10" type="java.lang.String" db-attribute-name="EMBEDDED10"/>
+ <embeddable-attribute name="embedded20" type="java.lang.String" db-attribute-name="EMBEDDED20"/>
+ </embeddable>
+ <db-entity name="EMBED_ENTITY1">
+ <db-attribute name="EMBEDDED10" type="VARCHAR" length="100"/>
+ <db-attribute name="EMBEDDED20" type="VARCHAR" length="100"/>
+ <db-attribute name="EMBEDDED30" type="VARCHAR" length="100"/>
+ <db-attribute name="EMBEDDED40" type="VARCHAR" length="100"/>
+ <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+ <db-attribute name="NAME" type="VARCHAR" length="100"/>
+ </db-entity>
+ <obj-entity name="EmbedEntity1" className="org.apache.cayenne.testdo.embeddable.EmbedEntity1" dbEntityName="EMBED_ENTITY1">
+ <embedded-attribute name="embedded1" type="org.apache.cayenne.testdo.embeddable.Embeddable1"/>
+ <embedded-attribute name="embedded2" type="org.apache.cayenne.testdo.embeddable.Embeddable1">
+ <embeddable-attribute-override name="embedded10" db-attribute-path="EMBEDDED30"/>
+ <embeddable-attribute-override name="embedded20" db-attribute-path="EMBEDDED40"/>
+ </embedded-attribute>
+ <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+ </obj-entity>
+</data-map>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml
new file mode 100644
index 0000000..ee44b9c
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml
@@ -0,0 +1,78 @@
+<!--
+ ~ 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="${context.dir}/WEB-INF/DefaultMap.map.xml"
+ adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+ driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:hsql://localhost/bookmarker"
+ username="sa">
+
+ <catalog name="catalog-name">
+ <schema name="schema-name">
+ <includeTable>includeTable-01</includeTable>
+
+ <includeTable>
+ <pattern>includeTable-02</pattern>
+ </includeTable>
+
+ <includeTable pattern="includeTable-03">
+ <includeColumn pattern="includeColumn-01"/>
+ <excludeColumn pattern="excludeColumn-01"/>
+ </includeTable>
+
+ <excludeTable>excludeTable-01</excludeTable>
+ <excludeTable>
+ <pattern>excludeTable-02</pattern>
+ </excludeTable>
+ <excludeTable pattern="excludeTable-03"/>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <includeColumn>
+ <pattern>includeColumn-02</pattern>
+ </includeColumn>
+ <includeColumn pattern="includeColumn-03"/>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ <excludeColumn>
+ <pattern>excludeColumn-02</pattern>
+ </excludeColumn>
+ <excludeColumn pattern="excludeColumn-03"/>
+
+ <includeProcedure>includeProcedure-01</includeProcedure>
+ <includeProcedure>
+ <pattern>includeProcedure-02</pattern>
+ </includeProcedure>
+ <includeProcedure pattern="includeProcedure-03"/>
+ <excludeProcedure>excludeProcedure-01</excludeProcedure>
+ <excludeProcedure>
+ <pattern>excludeProcedure-02</pattern>
+ </excludeProcedure>
+ <excludeProcedure pattern="excludeProcedure-03"/>
+ </schema>
+ </catalog>
+ </cdbimport>
+ </target>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog.xml
new file mode 100644
index 0000000..fa1781b
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog.xml
@@ -0,0 +1,82 @@
+<!--
+ ~ 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="${context.dir}/WEB-INF/DefaultMap.map.xml"
+ adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+ driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:hsql://localhost/bookmarker"
+ username="sa">
+
+ <catalog>catalog-name-01</catalog>
+
+ <catalog>
+ <name>catalog-name-02</name>
+ </catalog>
+
+ <catalog name="catalog-name-03">
+ <includeTable>includeTable-01</includeTable>
+
+ <includeTable>
+ <pattern>includeTable-02</pattern>
+ </includeTable>
+
+ <includeTable pattern="includeTable-03">
+ <includeColumn pattern="includeColumn-01"/>
+ <excludeColumn pattern="excludeColumn-01"/>
+ </includeTable>
+
+ <excludeTable>excludeTable-01</excludeTable>
+ <excludeTable>
+ <pattern>excludeTable-02</pattern>
+ </excludeTable>
+ <excludeTable pattern="excludeTable-03"/>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <includeColumn>
+ <pattern>includeColumn-02</pattern>
+ </includeColumn>
+ <includeColumn pattern="includeColumn-03"/>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ <excludeColumn>
+ <pattern>excludeColumn-02</pattern>
+ </excludeColumn>
+ <excludeColumn pattern="excludeColumn-03"/>
+
+ <includeProcedure>includeProcedure-01</includeProcedure>
+ <includeProcedure>
+ <pattern>includeProcedure-02</pattern>
+ </includeProcedure>
+ <includeProcedure pattern="includeProcedure-03"/>
+ <excludeProcedure>excludeProcedure-01</excludeProcedure>
+ <excludeProcedure>
+ <pattern>excludeProcedure-02</pattern>
+ </excludeProcedure>
+ <excludeProcedure pattern="excludeProcedure-03"/>
+ </catalog>
+ </cdbimport>
+ </target>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-flat.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-flat.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-flat.xml
new file mode 100644
index 0000000..286bcf3
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-flat.xml
@@ -0,0 +1,73 @@
+<!--
+ ~ 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="${context.dir}/WEB-INF/DefaultMap.map.xml"
+ adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+ driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:hsql://localhost/bookmarker"
+ username="sa">
+ <includeTable>includeTable-01</includeTable>
+
+ <includeTable>
+ <pattern>includeTable-02</pattern>
+ </includeTable>
+
+ <includeTable pattern="includeTable-03">
+ <includeColumn pattern="includeColumn-01"/>
+ <excludeColumn pattern="excludeColumn-01"/>
+ </includeTable>
+
+ <excludeTable>excludeTable-01</excludeTable>
+ <excludeTable>
+ <pattern>excludeTable-02</pattern>
+ </excludeTable>
+ <excludeTable pattern="excludeTable-03"/>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <includeColumn>
+ <pattern>includeColumn-02</pattern>
+ </includeColumn>
+ <includeColumn pattern="includeColumn-03"/>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ <excludeColumn>
+ <pattern>excludeColumn-02</pattern>
+ </excludeColumn>
+ <excludeColumn pattern="excludeColumn-03"/>
+
+ <includeProcedure>includeProcedure-01</includeProcedure>
+ <includeProcedure>
+ <pattern>includeProcedure-02</pattern>
+ </includeProcedure>
+ <includeProcedure pattern="includeProcedure-03"/>
+ <excludeProcedure>excludeProcedure-01</excludeProcedure>
+ <excludeProcedure>
+ <pattern>excludeProcedure-02</pattern>
+ </excludeProcedure>
+ <excludeProcedure pattern="excludeProcedure-03"/>
+ </cdbimport>
+ </target>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
new file mode 100644
index 0000000..5c0d2b6
--- /dev/null
+++ b/cayenne-ant/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/9/modelMap"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://cayenne.apache.org/schema/9/modelMap http://cayenne.apache.org/schema/9/modelMap.xsd"
+ project-version="9">
+ <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>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
new file mode 100644
index 0000000..befa01b
--- /dev/null
+++ b/cayenne-ant/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/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
new file mode 100644
index 0000000..e392d08
--- /dev/null
+++ b/cayenne-ant/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/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-mapping.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-mapping.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-mapping.xml
new file mode 100644
index 0000000..b6ab93e
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-mapping.xml
@@ -0,0 +1,44 @@
+<!--
+ 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="${context.dir}/WEB-INF/DefaultMap.map.xml"
+ adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+ driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:hsql://localhost/bookmarker"
+ username="sa">
+
+ <typeMapper mapperClassName="class" usePrimitives="false">
+ <type java="my.personal.type" jdbc="varchar"/>
+ <type java="java-01" jdbc="jdbc-01"/>
+ <type java="java-02" jdbc="jdbc-02" length="21" notNull="true"/>
+ <type java="java-03" jdbc="jdbc-03" precision="5" scale="2"/>
+ <type java="java-03" jdbc="jdbc-03" precision="7" notNull="true"/>
+ </typeMapper>
+
+ </cdbimport>
+ </target>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml
new file mode 100644
index 0000000..8cd89e8
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml
@@ -0,0 +1,33 @@
+<!--
+ 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"
+ reverseEngineeringFile="dbimport/config/reverseEngineering-catalog-and-schema.xml" />
+ </target>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-schema.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-schema.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-schema.xml
new file mode 100644
index 0000000..911af23
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-schema.xml
@@ -0,0 +1,83 @@
+<!--
+ ~ 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="${context.dir}/WEB-INF/DefaultMap.map.xml"
+ adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+ driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:hsql://localhost/bookmarker"
+ username="sa">
+
+ <schema>schema-name-01</schema>
+
+ <schema>
+ <name>schema-name-02</name>
+ </schema>
+
+ <schema name="schema-name-03">
+ <includeTable>includeTable-01</includeTable>
+
+ <includeTable>
+ <pattern>includeTable-02</pattern>
+ </includeTable>
+
+ <includeTable pattern="includeTable-03">
+ <includeColumn pattern="includeColumn-01"/>
+ <excludeColumn pattern="excludeColumn-01"/>
+ </includeTable>
+
+ <excludeTable>excludeTable-01</excludeTable>
+ <excludeTable>
+ <pattern>excludeTable-02</pattern>
+ </excludeTable>
+ <excludeTable pattern="excludeTable-03"/>
+
+ <includeColumn>includeColumn-01</includeColumn>
+ <includeColumn>
+ <pattern>includeColumn-02</pattern>
+ </includeColumn>
+ <includeColumn pattern="includeColumn-03"/>
+ <excludeColumn>excludeColumn-01</excludeColumn>
+ <excludeColumn>
+ <pattern>excludeColumn-02</pattern>
+ </excludeColumn>
+ <excludeColumn pattern="excludeColumn-03"/>
+
+ <includeProcedure>includeProcedure-01</includeProcedure>
+ <includeProcedure>
+ <pattern>includeProcedure-02</pattern>
+ </includeProcedure>
+ <includeProcedure pattern="includeProcedure-03"/>
+ <excludeProcedure>excludeProcedure-01</excludeProcedure>
+ <excludeProcedure>
+ <pattern>excludeProcedure-02</pattern>
+ </excludeProcedure>
+ <excludeProcedure pattern="excludeProcedure-03"/>
+ </schema>
+
+ </cdbimport>
+ </target>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
new file mode 100644
index 0000000..396b603
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
@@ -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.
+ -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+ <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+ classpath="${basedir}"/>
+
+ <target name="dist">
+ <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+ adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+ driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:hsql://localhost/bookmarker"
+ username="sa" skipPrimaryKeyLoading="true">
+ </cdbimport>
+ </target>
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
new file mode 100644
index 0000000..b2c801b
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
@@ -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.
+ -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+ <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+ classpath="${basedir}"/>
+
+ <target name="dist">
+ <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+ adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+ driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:hsql://localhost/bookmarker"
+ username="sa"
+ skipRelationshipsLoading="true"/>
+ </target>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-table-types.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
new file mode 100644
index 0000000..25bf032
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
@@ -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.
+ -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+ <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+ classpath="${basedir}"/>
+
+ <target name="dist">
+ <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+ adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+ driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:hsql://localhost/bookmarker"
+ username="sa">
+
+ <tableType>type1</tableType>
+
+ <tableType name="type2"/>
+ <tableType name="type3"/>
+ </cdbimport>
+ </target>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
new file mode 100644
index 0000000..d06be70
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap ../../main/resources/org/apache/cayenne/schema/3.0/modelMap.xsd"
+ project-version="1.1">
+ <property name="defaultPackage" value="org.apache.cayenne.testdo.cgen2"/>
+ <db-entity name="MYARTGROUP">
+ <db-attribute name="MY_GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+ <db-attribute name="CUSTOM" type="VARCHAR" isMandatory="true" length="100"/>
+ <db-attribute name="MY_PARENT_GROUP_ID" type="INTEGER"/>
+ </db-entity>
+ <obj-entity name="MyArtGroup" className="org.apache.cayenne.testdo.cgen2.MyArtGroup" dbEntityName="MYARTGROUP">
+ <obj-attribute name="custom" type="java.lang.String" db-attribute-path="CUSTOM"/>
+ </obj-entity>
+ <db-relationship name="toParentArtGroup" source="MYARTGROUP" target="ARTGROUP" toMany="false">
+ <db-attribute-pair source="MY_PARENT_GROUP_ID" target="GROUP_ID"/>
+ </db-relationship>
+ <obj-relationship name="toParentGroup" source="MyArtGroup" target="ArtGroup" deleteRule="Nullify" db-relationship-path="toParentArtGroup"/>
+</data-map>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen.map.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
new file mode 100644
index 0000000..1c378cf
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
+ project-version="6">
+
+ <db-entity name="ARTGROUP">
+ <db-attribute name="GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+ <db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
+ <db-attribute name="PARENT_GROUP_ID" type="INTEGER"/>
+ </db-entity>
+ <obj-entity name="ArtGroup" className="org.apache.cayenne.testdo.testmap.ArtGroup" dbEntityName="ARTGROUP">
+ <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+ </obj-entity>
+</data-map>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/velotemplate.vm b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
new file mode 100644
index 0000000..1ca078c
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
@@ -0,0 +1,13 @@
+## Test Velocity template
+${importUtils.setPackage($subPackageName)}##
+${importUtils.generate()}
+
+import java.util.List;
+import org.apache.cayenne.*;
+
+/** Class ${classGen.superPrefix}${classGen.className} was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public class ${subClassName} extends CayenneDataObject {