Added an integration-test, that depends on properties from a persistence.xml
authorKai Moritz <km@juplo.de>
Sun, 3 May 2015 12:51:12 +0000 (14:51 +0200)
committerKai Moritz <km@juplo.de>
Sat, 16 May 2015 11:29:42 +0000 (13:29 +0200)
src/it/h4mp-mod/pom.xml [new file with mode: 0644]
src/it/h4mp-mod/schema.sql [new file with mode: 0644]
src/it/h4mp-mod/src/main/java/h4mp/MainEntity.java [new file with mode: 0644]
src/it/h4mp-mod/src/main/resources/META-INF/persistence.xml [new file with mode: 0644]
src/it/h4mp-mod/verify.bsh [new file with mode: 0644]

diff --git a/src/it/h4mp-mod/pom.xml b/src/it/h4mp-mod/pom.xml
new file mode 100644 (file)
index 0000000..1e05bf6
--- /dev/null
@@ -0,0 +1,80 @@
+<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">
+       <modelVersion>4.0.0</modelVersion>
+       <groupId>de.cege</groupId>
+       <artifactId>h4mp-mod</artifactId>
+       <version>0.0.1-SNAPSHOT</version>
+       <packaging>war</packaging>
+       <name>h4m-mod</name>
+
+       <dependencies>
+               <dependency>
+                       <groupId>javax</groupId>
+                       <artifactId>javaee-api</artifactId>
+                       <version>7.0</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.hibernate</groupId>
+                       <artifactId>hibernate-envers</artifactId>
+                       <version>4.3.5.Final</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>4.8.2</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.derby</groupId>
+                       <artifactId>derby</artifactId>
+                       <version>10.10.1.1</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.hibernate</groupId>
+                       <artifactId>hibernate-entitymanager</artifactId>
+                       <version>4.3.5.Final</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-simple</artifactId>
+                       <version>1.5.8</version>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+       <properties>
+               <maven.compiler.source>1.7</maven.compiler.source>
+               <maven.compiler.target>1.7</maven.compiler.target>
+               <failOnMissingWebXml>false</failOnMissingWebXml>
+               <version>@project.version@</version>
+       </properties>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>de.juplo</groupId>
+                               <artifactId>hibernate4-maven-plugin</artifactId>
+                               <version>${version}</version>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>export</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                               <configuration>
+                                       <target>NONE</target>
+                                       <envers>true</envers>
+                                       <format>true</format>
+                                       <delimiter>;</delimiter>
+                                       <force>true</force>
+                                       <type>CREATE</type>
+                                       <hibernateDialect>org.hibernate.dialect.PostgreSQL9Dialect</hibernateDialect>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+</project>
diff --git a/src/it/h4mp-mod/schema.sql b/src/it/h4mp-mod/schema.sql
new file mode 100644 (file)
index 0000000..1fc1d88
--- /dev/null
@@ -0,0 +1,28 @@
+
+    create table MainEntity (
+        id int8 not null,
+        str varchar(255),
+        primary key (id)
+    );
+
+    create table MainEntity_AUD (
+        id int8 not null,
+        REV int4 not null,
+        REVTYPE int2,
+        str varchar(255),
+        str_MOD boolean,
+        primary key (id, REV)
+    );
+
+    create table REVINFO (
+        REV int4 not null,
+        REVTSTMP int8,
+        primary key (REV)
+    );
+
+    alter table MainEntity_AUD 
+        add constraint FK_kpx35pyi0ssiutbfxbf8klu06 
+        foreign key (REV) 
+        references REVINFO;
+
+    create sequence hibernate_sequence;
diff --git a/src/it/h4mp-mod/src/main/java/h4mp/MainEntity.java b/src/it/h4mp-mod/src/main/java/h4mp/MainEntity.java
new file mode 100644 (file)
index 0000000..4e2dbb7
--- /dev/null
@@ -0,0 +1,17 @@
+package h4mp;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.envers.Audited;
+
+@Entity
+@Audited
+public class MainEntity {
+       @Id
+       @GeneratedValue
+       long id;
+
+       String str;
+}
diff --git a/src/it/h4mp-mod/src/main/resources/META-INF/persistence.xml b/src/it/h4mp-mod/src/main/resources/META-INF/persistence.xml
new file mode 100644 (file)
index 0000000..a0e75e0
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0"
+       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_2_0.xsd">
+       <persistence-unit name="primary">
+               <jta-data-source>java:jboss/datasources/PostgreSQLDS</jta-data-source>
+
+               <properties>
+                       <property name="hibernate.hbm2ddl.auto" value="create-drop" />
+                       <property name="hibernate.show_sql" value="true" />
+
+                       <!-- Envers -->
+                       <property name="org.hibernate.envers.global_with_modified_flag"
+                               value="true" />
+               </properties>
+
+       </persistence-unit>
+</persistence>
diff --git a/src/it/h4mp-mod/verify.bsh b/src/it/h4mp-mod/verify.bsh
new file mode 100644 (file)
index 0000000..e13f800
--- /dev/null
@@ -0,0 +1,7 @@
+import de.juplo.test.FileComparator;
+
+
+FileComparator comparator = new FileComparator(basedir);
+
+if (!comparator.isEqual("schema.sql","target/schema.sql"))
+  return false;