From d5a4326bf1fe2045a7b2183cfd3d8fdb30fcb406 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 3 May 2015 14:51:12 +0200 Subject: [PATCH] Added an integration-test, that depends on properties from a persistence.xml --- src/it/h4mp-mod/pom.xml | 80 +++++++++++++++++++ src/it/h4mp-mod/schema.sql | 28 +++++++ .../src/main/java/h4mp/MainEntity.java | 17 ++++ .../main/resources/META-INF/persistence.xml | 20 +++++ src/it/h4mp-mod/verify.bsh | 7 ++ 5 files changed, 152 insertions(+) create mode 100644 src/it/h4mp-mod/pom.xml create mode 100644 src/it/h4mp-mod/schema.sql create mode 100644 src/it/h4mp-mod/src/main/java/h4mp/MainEntity.java create mode 100644 src/it/h4mp-mod/src/main/resources/META-INF/persistence.xml create mode 100644 src/it/h4mp-mod/verify.bsh diff --git a/src/it/h4mp-mod/pom.xml b/src/it/h4mp-mod/pom.xml new file mode 100644 index 00000000..1e05bf6c --- /dev/null +++ b/src/it/h4mp-mod/pom.xml @@ -0,0 +1,80 @@ + + 4.0.0 + de.cege + h4mp-mod + 0.0.1-SNAPSHOT + war + h4m-mod + + + + javax + javaee-api + 7.0 + provided + + + org.hibernate + hibernate-envers + 4.3.5.Final + + + + junit + junit + 4.8.2 + test + + + org.apache.derby + derby + 10.10.1.1 + test + + + org.hibernate + hibernate-entitymanager + 4.3.5.Final + test + + + org.slf4j + slf4j-simple + 1.5.8 + test + + + + 1.7 + 1.7 + false + @project.version@ + + + + + + de.juplo + hibernate4-maven-plugin + ${version} + + + + export + + + + + NONE + true + true + ; + true + CREATE + org.hibernate.dialect.PostgreSQL9Dialect + + + + + diff --git a/src/it/h4mp-mod/schema.sql b/src/it/h4mp-mod/schema.sql new file mode 100644 index 00000000..1fc1d887 --- /dev/null +++ b/src/it/h4mp-mod/schema.sql @@ -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 index 00000000..4e2dbb77 --- /dev/null +++ b/src/it/h4mp-mod/src/main/java/h4mp/MainEntity.java @@ -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 index 00000000..a0e75e0a --- /dev/null +++ b/src/it/h4mp-mod/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,20 @@ + + + + java:jboss/datasources/PostgreSQLDS + + + + + + + + + + + diff --git a/src/it/h4mp-mod/verify.bsh b/src/it/h4mp-mod/verify.bsh new file mode 100644 index 00000000..e13f8002 --- /dev/null +++ b/src/it/h4mp-mod/verify.bsh @@ -0,0 +1,7 @@ +import de.juplo.test.FileComparator; + + +FileComparator comparator = new FileComparator(basedir); + +if (!comparator.isEqual("schema.sql","target/schema.sql")) + return false; -- 2.20.1