From: Kai Moritz Date: Sat, 25 Oct 2014 14:52:34 +0000 (+0200) Subject: Integrated integration test provided by Claus Graf (clausgraf@gmail.com) X-Git-Tag: hibernate4-maven-plugin-1.0.5~8 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=3a3aeaabdb1841faf5e1bf8d220230597fb22931;p=hibernate4-maven-plugin Integrated integration test provided by Claus Graf (clausgraf@gmail.com) --- diff --git a/pom.xml b/pom.xml index df20ab05..6433f6f1 100644 --- a/pom.xml +++ b/pom.xml @@ -85,6 +85,10 @@ Mark Robinson mark@mrobinson.ca + + Claus Graf + clausgraf@gmail.com + diff --git a/src/it/dependency-test/dependent/pom.xml b/src/it/dependency-test/dependent/pom.xml new file mode 100644 index 00000000..e7c15f39 --- /dev/null +++ b/src/it/dependency-test/dependent/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + de.cege + dependent + 0.0.1 + + + + javax + javaee-api + 7.0 + provided + + + org.hibernate + hibernate-envers + 4.3.5.Final + + + + 1.7 + 1.7 + false + + \ No newline at end of file diff --git a/src/it/dependency-test/dependent/src/main/java/dependent/DependentEntity.java b/src/it/dependency-test/dependent/src/main/java/dependent/DependentEntity.java new file mode 100644 index 00000000..16bc4044 --- /dev/null +++ b/src/it/dependency-test/dependent/src/main/java/dependent/DependentEntity.java @@ -0,0 +1,17 @@ +package dependent; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.envers.Audited; + +@Entity +@Audited +public class DependentEntity { + @Id + @GeneratedValue + long id; + + String name; +} diff --git a/src/it/dependency-test/h4mp/pom.xml b/src/it/dependency-test/h4mp/pom.xml new file mode 100644 index 00000000..4e179d25 --- /dev/null +++ b/src/it/dependency-test/h4mp/pom.xml @@ -0,0 +1,85 @@ + + 4.0.0 + de.cege + h4mp + 0.0.1-SNAPSHOT + war + h4mp + + + + 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 + + + + de.cege + dependent + 0.0.1 + + + + 1.7 + 1.7 + false + + + + + + de.juplo + hibernate4-maven-plugin + @project.version@ + + + + export + + + + + NONE + true + true + ; + true + CREATE + org.hibernate.dialect.PostgreSQL9Dialect + + + + + diff --git a/src/it/dependency-test/h4mp/src/main/java/h4mp/MainEntity.java b/src/it/dependency-test/h4mp/src/main/java/h4mp/MainEntity.java new file mode 100644 index 00000000..f717d175 --- /dev/null +++ b/src/it/dependency-test/h4mp/src/main/java/h4mp/MainEntity.java @@ -0,0 +1,21 @@ +package h4mp; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +import org.hibernate.envers.Audited; + +import dependent.DependentEntity; + +@Entity +@Audited +public class MainEntity { + @Id + @GeneratedValue + long id; + + @ManyToOne + DependentEntity dependentEntity; +} diff --git a/src/it/dependency-test/h4mp/src/main/resources/META-INF/persistence.xml b/src/it/dependency-test/h4mp/src/main/resources/META-INF/persistence.xml new file mode 100644 index 00000000..a419eda9 --- /dev/null +++ b/src/it/dependency-test/h4mp/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,17 @@ + + + + java:jboss/datasources/PostgreSQLDS + + dependent.DependentEntity + + + + + + + diff --git a/src/it/dependency-test/h4mp/src/test/java/h4mp/MainEntityTest.java b/src/it/dependency-test/h4mp/src/test/java/h4mp/MainEntityTest.java new file mode 100644 index 00000000..32e528fe --- /dev/null +++ b/src/it/dependency-test/h4mp/src/test/java/h4mp/MainEntityTest.java @@ -0,0 +1,49 @@ +package h4mp; + +import static org.junit.Assert.*; +import static org.hamcrest.core.Is.*; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityTransaction; +import javax.persistence.Persistence; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import dependent.DependentEntity; + +public class MainEntityTest { + + private EntityManager em; + private EntityTransaction transaction; + + @Before + public void initializeDependencies() { + em = Persistence.createEntityManagerFactory("jpaIntegrationTest") + .createEntityManager(); + transaction = em.getTransaction(); + } + + @SuppressWarnings({ "rawtypes" }) + @Test + public void test() { + DependentEntity entity = new DependentEntity(); + + transaction.begin(); + em.persist(entity); + transaction.commit(); + + List resultList = em.createNativeQuery( + "select * from dependententity_aud").getResultList(); + assertThat(resultList.size(), is(1)); + } + + @After + public void after() { + em.close(); + } + +} diff --git a/src/it/dependency-test/h4mp/src/test/resources/META-INF/persistence.xml b/src/it/dependency-test/h4mp/src/test/resources/META-INF/persistence.xml new file mode 100644 index 00000000..83e13de6 --- /dev/null +++ b/src/it/dependency-test/h4mp/src/test/resources/META-INF/persistence.xml @@ -0,0 +1,23 @@ + + + + + dependent.DependentEntity + h4mp.MainEntity + + + + + + + + + + + + diff --git a/src/it/dependency-test/pom.xml b/src/it/dependency-test/pom.xml new file mode 100644 index 00000000..8e1506ed --- /dev/null +++ b/src/it/dependency-test/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + de.juplo + dependency-test + Hibernate 4 Dependency-Test + 0.1-SNAPSHOT + pom + + dependent + h4mp + +