openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1678344 - in /openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/openjpa/ src/main/java/org/apache/openjpa/too...
Date Fri, 08 May 2015 13:08:31 GMT
Author: struberg
Date: Fri May  8 13:08:30 2015
New Revision: 1678344

URL: http://svn.apache.org/r1678344
Log:
OPENJPA-2581 ITs for dropSchema action

txs to sreiterer for the patch!

Added:
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/pom.xml  
(with props)
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/openjpa/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/openjpa/tools/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/openjpa/tools/maven/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/openjpa/tools/maven/testentity/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/openjpa/tools/maven/testentity/DropSchemaTestEntity.java
  (with props)
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/resources/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/resources/META-INF/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/resources/META-INF/persistence.xml
  (with props)
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/openjpa/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/openjpa/tools/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/openjpa/tools/maven/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/openjpa/tools/maven/test/
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/openjpa/tools/maven/test/ItDropSchemaTest.java
  (with props)

Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/pom.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/pom.xml?rev=1678344&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/pom.xml (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/pom.xml Fri
May  8 13:08:30 2015
@@ -0,0 +1,168 @@
+<?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.
+-->
+<!--
+    Maven release plugin requires the project tag to be on a single line.
+-->
+<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/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.openjpa</groupId>
+        <artifactId>openjpa-tools</artifactId>
+        <version>@pom.version@</version>
+    </parent>
+
+    <groupId>org.apache.openjpa.tools.openjpa-maven-plugin.testing</groupId>
+    <artifactId>enhance</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_2.0_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-validation_1.0_spec</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa-kernel</artifactId>
+            <version>@pom.version@</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa-jdbc</artifactId>
+            <version>@pom.version@</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa-persistence</artifactId>
+            <version>@pom.version@</version>
+        </dependency>
+
+        <dependency>
+            <groupId>hsqldb</groupId>
+            <artifactId>hsqldb</artifactId>
+            <version>${hsqldb.version}</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.openjpa</groupId>
+                <artifactId>openjpa-maven-plugin</artifactId>
+                <version>@pom.version@</version>
+                <executions>
+                    <execution>
+                        <id>mappingtool</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>enhance</goal>
+                            <goal>sql</goal>
+                            <goal>schema</goal>
+                        </goals>
+                        <configuration>
+                            <toolProperties>
+                                <property>
+                                    <name>someSetting</name>
+                                    <value>someValue</value>
+                                </property>
+                            </toolProperties>
+                        </configuration>
+                    </execution>
+
+                    <!-- execute after database.sql has been executed in db with sql-maven-plugin
-->
+                    <execution>
+                        <id>drop-with-schematool</id>
+                        <phase>process-test-classes</phase>
+                        <goals>
+                            <goal>sql</goal>
+                        </goals>
+                        <configuration>
+                            <sqlAction>dropSchema</sqlAction>
+                            <sqlFile>${project.build.directory}/clear_database.sql</sqlFile>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+
+            <!-- Create table in database to verify if dropSchema does not consider
+                 the current database state -->
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>sql-maven-plugin</artifactId>
+                <version>1.5</version>
+
+                <!-- common configuration shared by all executions -->
+                <configuration>
+                    <driver>org.hsqldb.jdbcDriver</driver>
+                    <url>jdbc:hsqldb:mem:test</url>
+                    <username>sa</username>
+                    <password></password>
+                </configuration>
+
+                <dependencies>
+                    <dependency>
+                        <groupId>hsqldb</groupId>
+                        <artifactId>hsqldb</artifactId>
+                        <version>${hsqldb.version}</version>
+                    </dependency>
+                </dependencies>
+
+                <executions>
+                    <execution>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>execute</goal>
+                        </goals>
+                        <configuration>
+                            <srcFiles>
+                                <srcFile>${project.build.directory}/database.sql</srcFile>
+                            </srcFiles>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/openjpa/tools/maven/testentity/DropSchemaTestEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/openjpa/tools/maven/testentity/DropSchemaTestEntity.java?rev=1678344&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/openjpa/tools/maven/testentity/DropSchemaTestEntity.java
(added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/openjpa/tools/maven/testentity/DropSchemaTestEntity.java
Fri May  8 13:08:30 2015
@@ -0,0 +1,79 @@
+/*
+ * 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.openjpa.tools.maven.testentity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Enumerated;
+import javax.persistence.EnumType;
+
+
+@Entity
+public class DropSchemaTestEntity {
+
+    @Id
+    private int xint1;
+
+    private String string1;
+
+    public enum SampleEnum {
+        Option1, Option2, Option3
+    }
+
+    @Enumerated(EnumType.STRING)
+    private SampleEnum myEnum;
+
+
+    protected DropSchemaTestEntity() {
+    }
+
+    public DropSchemaTestEntity(int int1, String string1) {
+        this.xint1 = int1;
+        this.string1 = string1;
+    }
+
+    public int getInt1() {
+        return xint1;
+    }
+
+    public void setInt1(int int1) {
+        this.xint1 = int1;
+    }
+
+    public String getString1() {
+        return string1;
+    }
+
+    public void setString1(String string1) {
+        this.string1 = string1;
+    }
+
+    public String toString()  {
+        return xint1 + ":" + string1;
+    }
+
+    public SampleEnum getMyEnum() {
+        return myEnum;
+    }
+
+    public void setMyEnum(SampleEnum myEnum) {
+        this.myEnum = myEnum;
+    }
+
+}

Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/java/org/apache/openjpa/tools/maven/testentity/DropSchemaTestEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/resources/META-INF/persistence.xml?rev=1678344&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/resources/META-INF/persistence.xml
(added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/resources/META-INF/persistence.xml
Fri May  8 13:08:30 2015
@@ -0,0 +1,39 @@
+<?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.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+    version="1.0">
+
+    <!-- simply all annotated persistent entities will be part of this unit-->
+    <persistence-unit name="TestUnit">
+
+        <properties>
+            <property name="openjpa.jdbc.DBDictionary" value="hsql" />
+            <property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver"
/>
+            <property name="openjpa.ConnectionURL" value="jdbc:hsqldb:mem:test" />
+            <property name="openjpa.ConnectionUserName" value="sa" />
+            <property name="openjpa.ConnectionPassword" value="" />
+
+        </properties>
+
+    </persistence-unit>
+
+</persistence>
+

Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/main/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/openjpa/tools/maven/test/ItDropSchemaTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/openjpa/tools/maven/test/ItDropSchemaTest.java?rev=1678344&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/openjpa/tools/maven/test/ItDropSchemaTest.java
(added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/openjpa/tools/maven/test/ItDropSchemaTest.java
Fri May  8 13:08:30 2015
@@ -0,0 +1,50 @@
+/*
+ * 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.openjpa.tools.maven.test;
+
+import junit.framework.TestCase;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
+public class ItDropSchemaTest extends TestCase {
+
+    /** contains the directory where all generated results are placed */
+    private final static String TARGET_DIR = "target";
+    
+    /** the file containing the generated SQL syntax */
+    private final static String SQL_FILE = "clear_database.sql";
+    
+    /** if the SQL generation has been successful, the following result should be in the
SQL file */
+    private final static String VALID_SQL = "DROP TABLE DropSchemaTestEntity;";
+    
+    /**
+     * check if the generated SQL script is correct.
+     * @throws Exception
+     */
+    public void testSqlGeneration() throws Exception
+    {
+        File sqlFile = new File( TARGET_DIR, SQL_FILE );
+        BufferedReader in = new BufferedReader( new FileReader( sqlFile ) );
+        String sqlIn = in.readLine();
+        assertEquals( VALID_SQL, sqlIn );
+    }
+    
+}

Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionDropSchema/src/test/java/org/apache/openjpa/tools/maven/test/ItDropSchemaTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message