Repository: cayenne Updated Branches: refs/heads/master acf54ba62 -> e2474202c
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/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 83bb0d2..755a64d 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 @@ -30,13 +30,21 @@ import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.Iterator; +import org.apache.cayenne.tools.dbimport.config.Catalog; +import org.apache.cayenne.tools.dbimport.config.IncludeTable; +import org.apache.cayenne.tools.dbimport.config.Schema; import org.apache.cayenne.tools.dbimport.DbImportConfiguration; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.codehaus.plexus.util.FileUtils; +import org.custommonkey.xmlunit.DetailedDiff; +import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.XMLUnit; import org.xml.sax.SAXException; +import static org.apache.commons.lang.StringUtils.isBlank; + public class DbImporterMojoTest extends AbstractMojoTestCase { static { @@ -85,6 +93,22 @@ public class DbImporterMojoTest extends AbstractMojoTestCase { test("testImportAddTableAndColumn"); } + public void testSimpleFiltering() throws Exception { + test("testSimpleFiltering"); + } + + public void testFilteringWithSchema() throws Exception { + test("testFilteringWithSchema"); + } + + public void testSchemasAndTableExclude() throws Exception { + test("testSchemasAndTableExclude"); + } + + public void testViewsExclude() throws Exception { + test("testViewsExclude"); + } + private void test(String name) throws Exception { DbImporterMojo cdbImport = getCdbImport("dbimport/" + name + "-pom.xml"); File mapFile = cdbImport.getMap(); @@ -112,16 +136,42 @@ public class DbImporterMojoTest extends AbstractMojoTestCase { Connection connection = DriverManager.getConnection(dbImportConfiguration.getUrl()); Statement stmt = connection.createStatement(); + ResultSet views = connection.getMetaData().getTables(null, null, null, new String[]{"VIEW"}); + while (views.next()) { + String schema = views.getString("TABLE_SCHEM"); + System.out.println("DROP VIEW " + (isBlank(schema) ? "" : schema + ".") + views.getString("TABLE_NAME")); + stmt.execute("DROP VIEW " + (isBlank(schema) ? "" : schema + ".") + views.getString("TABLE_NAME")); + } + ResultSet tables = connection.getMetaData().getTables(null, null, null, new String[]{"TABLE"}); while (tables.next()) { - System.out.println("DROP TABLE " + tables.getString("TABLE_NAME")); - stmt.execute("DROP TABLE " + tables.getString("TABLE_NAME")); + 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"); + } } } private void verifyResult(File map, File mapFileCopy) { try { - assertXMLEqual(new FileReader(map.getAbsolutePath() + "-result"), new FileReader(mapFileCopy)); + FileReader control = new FileReader(map.getAbsolutePath() + "-result"); + FileReader test = new FileReader(mapFileCopy); + + DetailedDiff diff = new DetailedDiff(new Diff(control, test)); + if (!diff.similar()) { + System.out.println(" >>>> " + map.getAbsolutePath() + "-result"); + System.out.println(" >>>> " + mapFileCopy); + fail(diff.toString()); + } + } catch (SAXException e) { e.printStackTrace(); fail(); @@ -131,6 +181,59 @@ public class DbImporterMojoTest extends AbstractMojoTestCase { } } + public void testFilteringConfig() throws Exception { + DbImporterMojo cdbImport = getCdbImport("config/pom-01.xml"); + + assertEquals(2, cdbImport.getReverseEngineering().getCatalogs().size()); + Iterator<Catalog> iterator = cdbImport.getReverseEngineering().getCatalogs().iterator(); + assertEquals("catalog-name-01", iterator.next().getName()); + + Catalog catalog = iterator.next(); + assertEquals("catalog-name-02", catalog.getName()); + Iterator<Schema> schemaIterator = catalog.getSchemas().iterator(); + + assertEquals("schema-name-01", schemaIterator.next().getName()); + + Schema schema = schemaIterator.next(); + assertEquals("schema-name-02", schema.getName()); + + Iterator<IncludeTable> includeTableIterator = schema.getIncludeTables().iterator(); + assertEquals("incTable-01", includeTableIterator.next().getPattern()); + + IncludeTable includeTable = includeTableIterator.next(); + assertEquals("incTable-02", includeTable.getPattern()); + assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern()); + assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern()); + + assertEquals("includeColumn-02", schema.getIncludeColumns().iterator().next().getPattern()); + assertEquals("excludeColumn-02", schema.getExcludeColumns().iterator().next().getPattern()); + + assertEquals("includeColumn-03", catalog.getIncludeColumns().iterator().next().getPattern()); + assertEquals("excludeColumn-03", catalog.getExcludeColumns().iterator().next().getPattern()); + + schemaIterator = cdbImport.getReverseEngineering().getSchemas().iterator(); + schema = schemaIterator.next(); + assertEquals("schema-name-03", schema.getName()); + + schema = schemaIterator.next(); + assertEquals("schema-name-04", schema.getName()); + + includeTableIterator = schema.getIncludeTables().iterator(); + assertEquals("incTable-04", includeTableIterator.next().getPattern()); + assertEquals("excTable-04", schema.getExcludeTables().iterator().next().getPattern()); + + includeTable = includeTableIterator.next(); + assertEquals("incTable-05", includeTable.getPattern()); + assertEquals("includeColumn-04", includeTable.getIncludeColumns().iterator().next().getPattern()); + assertEquals("excludeColumn-04", includeTable.getExcludeColumns().iterator().next().getPattern()); + + assertEquals("includeColumn-04", schema.getIncludeColumns().iterator().next().getPattern()); + assertEquals("excludeColumn-04", schema.getExcludeColumns().iterator().next().getPattern()); + + assertEquals("includeColumn-03", catalog.getIncludeColumns().iterator().next().getPattern()); + assertEquals("excludeColumn-03", catalog.getExcludeColumns().iterator().next().getPattern()); + } + private void prepareDatabase(String sqlFile, DbImportConfiguration dbImportConfiguration) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, IOException, URISyntaxException { Class.forName(dbImportConfiguration.getDriver()).newInstance(); // Get a connection http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-01.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-01.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-01.xml new file mode 100644 index 0000000..b16afd8 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-01.xml @@ -0,0 +1,99 @@ +<?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/org/apache/cayenne/tools/dbimporter-map1.map.xml</map> + + <reverseEngineering> + <catalog>catalog-name-01</catalog> + + <catalog> + <name>catalog-name-02</name> + + <schema>schema-name-01</schema> + + <schema> + <name>schema-name-02</name> + + <includeTable>incTable-01</includeTable> + <excludeTable>excTable-01</excludeTable> + + <includeTable> + <pattern>incTable-02</pattern> + + <includeColumn>includeColumn-01</includeColumn> + <excludeColumn>excludeColumn-01</excludeColumn> + </includeTable> + + <includeColumn>includeColumn-02</includeColumn> + <excludeColumn>excludeColumn-02</excludeColumn> + </schema> + + <includeColumn>includeColumn-03</includeColumn> + <excludeColumn>excludeColumn-03</excludeColumn> + </catalog> + + <schema>schema-name-03</schema> + + <schema> + <name>schema-name-04</name> + + <includeTable>incTable-04</includeTable> + <excludeTable>excTable-04</excludeTable> + + <includeTable> + <pattern>incTable-05</pattern> + + <includeColumn>includeColumn-04</includeColumn> + <excludeColumn>excludeColumn-04</excludeColumn> + </includeTable> + + <includeColumn>includeColumn-04</includeColumn> + <excludeColumn>excludeColumn-04</excludeColumn> + </schema> + + <includeTable>incTable-06</includeTable> + <excludeTable>excTable-06</excludeTable> + + <includeTable> + <pattern>incTable-07</pattern> + + <includeColumn>includeColumn-06</includeColumn> + <excludeColumn>excludeColumn-06</excludeColumn> + </includeTable> + + <includeColumn>includeColumn-05</includeColumn> + <excludeColumn>excludeColumn-05</excludeColumn> + </reverseEngineering> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-catalog-and-schema.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-catalog-and-schema.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-catalog-and-schema.xml new file mode 100644 index 0000000..5b6932d --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-catalog-and-schema.xml @@ -0,0 +1,82 @@ +<?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> + + <catalog> + <name>catalog-name</name> + <schema> + <name>schema-name</name> + <includeTable>includeTable-01</includeTable> + + <includeTable> + <pattern>includeTable-02</pattern> + </includeTable> + + <includeTable> + <pattern>includeTable-03</pattern> + + <includeColumn>includeColumn-01</includeColumn> + <excludeColumn>excludeColumn-01</excludeColumn> + </includeTable> + + <excludeTable>excludeTable-01</excludeTable> + <excludeTable> + <pattern>excludeTable-02</pattern> + </excludeTable> + <excludeTable>excludeTable-03</excludeTable> + + <includeColumn>includeColumn-01</includeColumn> + <includeColumn> + <pattern>includeColumn-02</pattern> + </includeColumn> + <includeColumn>includeColumn-03</includeColumn> + <excludeColumn>excludeColumn-01</excludeColumn> + <excludeColumn> + <pattern>excludeColumn-02</pattern> + </excludeColumn> + <excludeColumn>excludeColumn-03</excludeColumn> + + <includeProcedure>includeProcedure-01</includeProcedure> + <includeProcedure> + <pattern>includeProcedure-02</pattern> + </includeProcedure> + <includeProcedure>includeProcedure-03</includeProcedure> + <excludeProcedure>excludeProcedure-01</excludeProcedure> + <excludeProcedure> + <pattern>excludeProcedure-02</pattern> + </excludeProcedure> + <excludeProcedure>excludeProcedure-03</excludeProcedure> + </schema> + </catalog> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-catalog.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-catalog.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-catalog.xml new file mode 100644 index 0000000..43bd650 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-catalog.xml @@ -0,0 +1,85 @@ +<?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> + + <catalog>catalog-name-01</catalog> + + <catalog> + <name>catalog-name-02</name> + </catalog> + + <catalog> + <name>catalog-name-03</name> + <includeTable>includeTable-01</includeTable> + + <includeTable> + <pattern>includeTable-02</pattern> + </includeTable> + + <includeTable> + <pattern>includeTable-03</pattern> + + <includeColumn>includeColumn-01</includeColumn> + <excludeColumn>excludeColumn-01</excludeColumn> + </includeTable> + + <excludeTable>excludeTable-01</excludeTable> + <excludeTable> + <pattern>excludeTable-02</pattern> + </excludeTable> + <excludeTable>excludeTable-03</excludeTable> + + <includeColumn>includeColumn-01</includeColumn> + <includeColumn> + <pattern>includeColumn-02</pattern> + </includeColumn> + <includeColumn>includeColumn-03</includeColumn> + <excludeColumn>excludeColumn-01</excludeColumn> + <excludeColumn> + <pattern>excludeColumn-02</pattern> + </excludeColumn> + <excludeColumn>excludeColumn-03</excludeColumn> + + <includeProcedure>includeProcedure-01</includeProcedure> + <includeProcedure> + <pattern>includeProcedure-02</pattern> + </includeProcedure> + <includeProcedure>includeProcedure-03</includeProcedure> + <excludeProcedure>excludeProcedure-01</excludeProcedure> + <excludeProcedure> + <pattern>excludeProcedure-02</pattern> + </excludeProcedure> + <excludeProcedure>excludeProcedure-03</excludeProcedure> + </catalog> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-flat.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-flat.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-flat.xml new file mode 100644 index 0000000..e245f94 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-flat.xml @@ -0,0 +1,78 @@ +<?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> + + <reverseEngineering> + <includeTable>includeTable-01</includeTable> + + <includeTable> + <pattern>includeTable-02</pattern> + </includeTable> + + <includeTable> + <pattern>includeTable-03</pattern> + + <includeColumn>includeColumn-01</includeColumn> + <excludeColumn>excludeColumn-01</excludeColumn> + </includeTable> + + <excludeTable>excludeTable-01</excludeTable> + <excludeTable> + <pattern>excludeTable-02</pattern> + </excludeTable> + <excludeTable>excludeTable-03</excludeTable> + + <includeColumn>includeColumn-01</includeColumn> + <includeColumn> + <pattern>includeColumn-02</pattern> + </includeColumn> + <includeColumn>includeColumn-03</includeColumn> + <excludeColumn>excludeColumn-01</excludeColumn> + <excludeColumn> + <pattern>excludeColumn-02</pattern> + </excludeColumn> + <excludeColumn>excludeColumn-03</excludeColumn> + + <includeProcedure>includeProcedure-01</includeProcedure> + <includeProcedure> + <pattern>includeProcedure-02</pattern> + </includeProcedure> + <includeProcedure>includeProcedure-03</includeProcedure> + <excludeProcedure>excludeProcedure-01</excludeProcedure> + <excludeProcedure> + <pattern>excludeProcedure-02</pattern> + </excludeProcedure> + <excludeProcedure>excludeProcedure-03</excludeProcedure> + </reverseEngineering> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-mapping.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-mapping.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-mapping.xml new file mode 100644 index 0000000..10c99da --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-mapping.xml @@ -0,0 +1,67 @@ +<?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> + + <typeMapper > + <mapperClassName>class</mapperClassName> + <usePrimitives>false</usePrimitives> + + <type> + <java>my.personal.type</java> + <jdbc>varchar</jdbc> + </type> + <type> + <java>java-01</java> + <jdbc>jdbc-01</jdbc> + </type> + <type> + <java>java-02</java> + <jdbc>jdbc-02</jdbc> + <length>21</length> + <notNull>true</notNull> + </type> + <type> + <java>java-03</java> + <jdbc>jdbc-03</jdbc> + <precision>5</precision> + <scale>2</scale> + </type> + <type> + <java>java-03</java> + <jdbc>jdbc-03</jdbc> + <precision>7</precision> + <notNull>true</notNull> + </type> + </typeMapper> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-schema.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-schema.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-schema.xml new file mode 100644 index 0000000..62fc3f5 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-schema.xml @@ -0,0 +1,85 @@ +<?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> + + <schema>schema-name-01</schema> + + <schema> + <name>schema-name-02</name> + </schema> + + <schema> + <name>schema-name-03</name> + <includeTable>includeTable-01</includeTable> + + <includeTable> + <pattern>includeTable-02</pattern> + </includeTable> + + <includeTable> + <pattern>includeTable-03</pattern> + + <includeColumn>includeColumn-01</includeColumn> + <excludeColumn>excludeColumn-01</excludeColumn> + </includeTable> + + <excludeTable>excludeTable-01</excludeTable> + <excludeTable> + <pattern>excludeTable-02</pattern> + </excludeTable> + <excludeTable>excludeTable-03</excludeTable> + + <includeColumn>includeColumn-01</includeColumn> + <includeColumn> + <pattern>includeColumn-02</pattern> + </includeColumn> + <includeColumn>includeColumn-03</includeColumn> + <excludeColumn>excludeColumn-01</excludeColumn> + <excludeColumn> + <pattern>excludeColumn-02</pattern> + </excludeColumn> + <excludeColumn>excludeColumn-03</excludeColumn> + + <includeProcedure>includeProcedure-01</includeProcedure> + <includeProcedure> + <pattern>includeProcedure-02</pattern> + </includeProcedure> + <includeProcedure>includeProcedure-03</includeProcedure> + <excludeProcedure>excludeProcedure-01</excludeProcedure> + <excludeProcedure> + <pattern>excludeProcedure-02</pattern> + </excludeProcedure> + <excludeProcedure>excludeProcedure-03</excludeProcedure> + </schema> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema-pom.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema-pom.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema-pom.xml new file mode 100644 index 0000000..70806d7 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema-pom.xml @@ -0,0 +1,41 @@ +<?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/testFilteringWithSchema.map.xml</map> + <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/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema.map.xml-result ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema.map.xml-result b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema.map.xml-result new file mode 100644 index 0000000..093f6cc --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema.map.xml-result @@ -0,0 +1,51 @@ +<?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="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="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="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/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema.sql ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema.sql b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema.sql new file mode 100644 index 0000000..7e172f5 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testFilteringWithSchema.sql @@ -0,0 +1,48 @@ + +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) +); + +CREATE SCHEMA schema_02; +SET SCHEMA schema_02; + +CREATE TABLE schema_02.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_02.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/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude-pom.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude-pom.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude-pom.xml new file mode 100644 index 0000000..8b1ba32 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude-pom.xml @@ -0,0 +1,43 @@ +<?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/testOldParamsSchemasAndTableExclude.map.xml</map> + <driver>org.apache.derby.jdbc.EmbeddedDriver</driver> + <url>jdbc:derby:memory:DbImporterMojoTest;create=true</url> + + <schema>SCHEMA_01</schema> + + <tablePattern>Parent</tablePattern> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude.map.xml-result ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude.map.xml-result b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude.map.xml-result new file mode 100644 index 0000000..5853842 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude.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/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"> + <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="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/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude.sql ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude.sql b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude.sql new file mode 100644 index 0000000..7e172f5 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testOldParamsSchemasAndTableExclude.sql @@ -0,0 +1,48 @@ + +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) +); + +CREATE SCHEMA schema_02; +SET SCHEMA schema_02; + +CREATE TABLE schema_02.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_02.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/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude-pom.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude-pom.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude-pom.xml new file mode 100644 index 0000000..66b051e --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude-pom.xml @@ -0,0 +1,45 @@ +<?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/testSchemasAndTableExclude.map.xml</map> + <driver>org.apache.derby.jdbc.EmbeddedDriver</driver> + <url>jdbc:derby:memory:DbImporterMojoTest;create=true</url> + + <schema> + <name>SCHEMA_01</name> + </schema> + + <excludeTables>Child</excludeTables> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude.map.xml-result ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude.map.xml-result b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude.map.xml-result new file mode 100644 index 0000000..83f9934 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude.map.xml-result @@ -0,0 +1,38 @@ +<?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="defaultSchema" value="SCHEMA_01"/> + <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="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/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude.sql ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude.sql b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude.sql new file mode 100644 index 0000000..7e172f5 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSchemasAndTableExclude.sql @@ -0,0 +1,48 @@ + +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) +); + +CREATE SCHEMA schema_02; +SET SCHEMA schema_02; + +CREATE TABLE schema_02.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_02.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/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering-pom.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering-pom.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering-pom.xml new file mode 100644 index 0000000..1cb3ed6 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering-pom.xml @@ -0,0 +1,41 @@ +<?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/testSimpleFiltering.map.xml</map> + <driver>org.apache.derby.jdbc.EmbeddedDriver</driver> + <url>jdbc:derby:memory:DbImporterMojoTest;create=true</url> + + <tablePattern>Parent</tablePattern> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering.map.xml-result ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering.map.xml-result b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering.map.xml-result new file mode 100644 index 0000000..f8eb58e --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering.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/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"> + <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/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering.sql ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering.sql b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering.sql new file mode 100644 index 0000000..fb820b7 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testSimpleFiltering.sql @@ -0,0 +1,20 @@ +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/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude-pom.xml ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude-pom.xml b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude-pom.xml new file mode 100644 index 0000000..1f8f25d --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude-pom.xml @@ -0,0 +1,41 @@ +<?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/testViewsExclude.map.xml</map> + <driver>org.apache.derby.jdbc.EmbeddedDriver</driver> + <url>jdbc:derby:memory:DbImporterMojoTest;create=true</url> + + <excludeTables>v_*</excludeTables> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude.map.xml-result ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude.map.xml-result b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude.map.xml-result new file mode 100644 index 0000000..25bf598 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude.map.xml-result @@ -0,0 +1,43 @@ +<?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"> + <db-entity name="GIRL" schema="APP"> + <db-attribute name="ID" type="INTEGER" isMandatory="true" length="10"/> + </db-entity> + <db-entity name="PERSON" 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="Girl" className="Girl" dbEntityName="GIRL"> + <obj-attribute name="id" type="java.lang.Integer" db-attribute-path="ID"/> + </obj-entity> + <obj-entity name="Person" className="Person" dbEntityName="PERSON"> + <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/e2474202/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude.sql ---------------------------------------------------------------------- diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude.sql b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude.sql new file mode 100644 index 0000000..5e32df5 --- /dev/null +++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testViewsExclude.sql @@ -0,0 +1,14 @@ + +CREATE TABLE Person ( + id INTEGER NOT NULL, + COL2 CHAR(25), + COL3 DECIMAL(10,2), + COL4 VARCHAR(25), + COL5 DATE, + + PRIMARY KEY (id), + UNIQUE (COL3) +); + +CREATE VIEW girl (id) AS SELECT id FROM Person; +CREATE VIEW v_vview (id) AS SELECT id FROM Person; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/e2474202/plugins/pom.xml ---------------------------------------------------------------------- diff --git a/plugins/pom.xml b/plugins/pom.xml index 71405fe..5445e67 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -96,6 +96,22 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>3.3</version> + <configuration> + <goalPrefix>signature</goalPrefix> + </configuration> + <executions> + <execution> + <goals> + <goal>descriptor</goal> + </goals> + <phase>process-classes</phase> + </execution> + </executions> + </plugin> </plugins> </build> </project>