Fixed bug with directories, that should be scanned for annotations
authorKai Moritz <kai@juplo.de>
Tue, 7 Feb 2017 11:17:14 +0000 (12:17 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 7 Feb 2017 12:08:33 +0000 (13:08 +0100)
All configuration values for <scanClasses> and <scanTestClasses> were
ignored.

Thanx to Thomas Mauß, how reported this bug and provided a very usefull
integration test, that made it possible to find the bug in a breeze!

27 files changed:
src/it/hmp-testclasses-annotationscanning/pom.xml [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/readme.txt [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/BaseEntity.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/Fachgebiet.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/IBaseEntity.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/callback/UserChangeTrackListener.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/extension/IUserChangeInfo.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/extension/IUserChangeTrackable.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/userchangeinfo/BaseUserChangeTrackedEntity.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/userchangeinfo/UserChangeInfo.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/model/domain/userchangeinfo/test/UserChangeInfoTest.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/model/test/userchangeinfo/UserChangeInfoTestEntity.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/persistence/producer/EntityManagerProducer.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/service/IUserChangeInfoTestService.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/service/impl/UserChangeInfoTestService.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/test/util/BaseDeploymentPackage.java [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.dbunit.properties [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.jpacacheeviction.properties [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.properties [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.script.properties [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.xml [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/resources/beans.xml [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/resources/datasets/userchangeinfo/userchangeinfo.json [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/resources/logback-test.xml [new file with mode: 0644]
src/it/hmp-testclasses-annotationscanning/src/test/resources/test-persistence.xml [new file with mode: 0644]
src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java

diff --git a/src/it/hmp-testclasses-annotationscanning/pom.xml b/src/it/hmp-testclasses-annotationscanning/pom.xml
new file mode 100644 (file)
index 0000000..32461a6
--- /dev/null
@@ -0,0 +1,280 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+  <modelVersion>4.0.0</modelVersion>\r
+\r
+  <groupId>net.java.examples</groupId>\r
+  <artifactId>hmp-testclasses-annotationscanning</artifactId>\r
+  <version>0.0.1-SNAPSHOT</version>\r
+  \r
+  <packaging>jar</packaging>\r
+\r
+  <name>Hibernate-Maven-Plugin Scan Testclasses Example</name>\r
+  <description>Sample Maven Project for Testing the Annotation-Scanning from TestClasses</description>\r
+\r
+  <properties>\r
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
+    <java.source>1.8</java.source>\r
+       <java.target>1.8</java.target>\r
+    \r
+    <plugin.compiler.version>3.3</plugin.compiler.version>\r
+    \r
+    <jboss.spec.version>3.0.2.Final-redhat-15</jboss.spec.version>\r
+    \r
+    <org.apache.openejb.version>4.7.4</org.apache.openejb.version>\r
+    <logback.version>1.1.3</logback.version>\r
+    <slf4j.version>1.7.7</slf4j.version>\r
+    <hibernate.version>4.2.18.Final-redhat-2</hibernate.version>\r
+    <hibernate.validator.version>4.3.2.Final-redhat-2</hibernate.validator.version>\r
+    \r
+  </properties>\r
+\r
+  <repositories>\r
+    <repository>\r
+      <id>redhat-techpreview-all-repository</id>\r
+      <name>Red Hat Tech Preview repository (all)</name>\r
+      <url>http://maven.repository.redhat.com/techpreview/all/</url>\r
+      <layout>default</layout>\r
+      <releases>\r
+        <enabled>true</enabled>\r
+        <updatePolicy>never</updatePolicy>\r
+      </releases>\r
+      <snapshots>\r
+        <enabled>false</enabled>\r
+        <updatePolicy>never</updatePolicy>\r
+      </snapshots>\r
+    </repository>\r
+  </repositories>\r
+  <pluginRepositories>\r
+    <pluginRepository>\r
+      <id>redhat-techpreview-all-repository</id>\r
+      <name>Red Hat Tech Preview repository (all)</name>\r
+      <url>http://maven.repository.redhat.com/techpreview/all/</url>\r
+      <layout>default</layout>\r
+      <releases>\r
+        <enabled>true</enabled>\r
+        <updatePolicy>never</updatePolicy>\r
+      </releases>\r
+      <snapshots>\r
+        <enabled>false</enabled>\r
+        <updatePolicy>never</updatePolicy>\r
+      </snapshots>\r
+    </pluginRepository>\r
+  </pluginRepositories>\r
+\r
+  <dependencies>\r
+         \r
+       <!-- Deltspike Dependencies -->\r
+       <dependency>\r
+               <groupId>org.apache.deltaspike.core</groupId>\r
+               <artifactId>deltaspike-core-api</artifactId>\r
+               <version>1.0.1</version>\r
+       </dependency>\r
+       <dependency>\r
+               <groupId>org.apache.deltaspike.core</groupId>\r
+               <artifactId>deltaspike-core-impl</artifactId>\r
+               <version>1.0.1</version>\r
+       </dependency>\r
+       \r
+       <!-- Different Compile Dependencies -->\r
+       <dependency>\r
+               <groupId>commons-beanutils</groupId>\r
+               <artifactId>commons-beanutils</artifactId>\r
+               <version>1.8.3.redhat-6</version>\r
+       </dependency>\r
+       <dependency>\r
+               <groupId>commons-collections</groupId>\r
+               <artifactId>commons-collections</artifactId>\r
+               <version>3.2.1.redhat-3</version>\r
+       </dependency>\r
+       <dependency>\r
+               <groupId>org.apache.commons</groupId>\r
+               <artifactId>commons-lang3</artifactId>\r
+               <version>3.4</version>\r
+       </dependency>\r
+       <dependency>\r
+               <groupId>com.google.guava</groupId>\r
+               <artifactId>guava</artifactId>\r
+               <version>13.0.1.redhat-2</version>\r
+       </dependency>\r
+      \r
+       <!-- SLF4J&Logback Dependencies -->\r
+       <dependency>\r
+               <groupId>org.slf4j</groupId>\r
+               <artifactId>slf4j-api</artifactId>\r
+               <version>${slf4j.version}</version>\r
+               <scope>provided</scope>\r
+       </dependency>\r
+       <dependency>\r
+               <groupId>ch.qos.logback</groupId>\r
+               <artifactId>logback-classic</artifactId>\r
+               <version>${logback.version}</version>\r
+       </dependency>\r
+       \r
+       <!-- Hibernate Dependencies -->\r
+       <dependency>\r
+               <groupId>org.hibernate</groupId>\r
+               <artifactId>hibernate-validator</artifactId>\r
+               <version>${hibernate.validator.version}</version>\r
+       </dependency>\r
+       <dependency>\r
+               <groupId>org.hibernate</groupId>\r
+               <artifactId>hibernate-core</artifactId>\r
+               <version>${hibernate.version}</version>\r
+       </dependency>\r
+       <dependency>\r
+               <groupId>org.hibernate</groupId>\r
+               <artifactId>hibernate-entitymanager</artifactId>\r
+               <version>${hibernate.version}</version>\r
+               <scope>test</scope>\r
+       </dependency>\r
+\r
+    <!-- Arquillian & OpenEJB-Dependencies -->\r
+    <dependency>\r
+               <groupId>org.apache.openejb</groupId>\r
+               <artifactId>arquillian-openejb-embedded-4</artifactId>\r
+               <version>${org.apache.openejb.version}</version>\r
+               <scope>test</scope>\r
+       </dependency>\r
+       <dependency>\r
+               <groupId>org.apache.openejb</groupId>\r
+               <artifactId>openejb-core</artifactId>\r
+               <version>${org.apache.openejb.version}</version>\r
+               <scope>test</scope>\r
+               <exclusions>\r
+                       <exclusion>\r
+                               <artifactId>slf4j-jdk14</artifactId>\r
+                               <groupId>org.slf4j</groupId>\r
+                       </exclusion>\r
+               </exclusions>\r
+       </dependency>\r
+       <dependency>\r
+               <groupId>org.jboss.arquillian.extension</groupId>\r
+               <artifactId>arquillian-persistence-impl</artifactId>\r
+               <version>1.0.0.Alpha6</version>\r
+               <scope>test</scope>\r
+               <exclusions>\r
+          <exclusion>\r
+            <artifactId>log4j</artifactId>\r
+            <groupId>log4j</groupId>\r
+          </exclusion>\r
+          <exclusion>\r
+            <artifactId>commons-collections</artifactId>\r
+            <groupId>commons-collections</groupId>\r
+          </exclusion>\r
+        </exclusions>\r
+       </dependency>\r
+       <dependency>\r
+               <groupId>org.jboss.shrinkwrap.resolver</groupId>\r
+               <artifactId>shrinkwrap-resolver-impl-maven</artifactId>\r
+               <version>2.1.0</version>\r
+               <scope>test</scope>\r
+       </dependency>\r
+       \r
+       <!-- H2 Database -->\r
+       <dependency>\r
+               <groupId>com.h2database</groupId>\r
+               <artifactId>h2</artifactId>\r
+               <version>1.3.168.redhat-4</version>\r
+               <scope>test</scope>\r
+       </dependency>\r
+       \r
+       <!-- JUnit -->\r
+    <dependency>\r
+      <groupId>junit</groupId>\r
+      <artifactId>junit</artifactId>\r
+      <version>4.12</version>\r
+      <scope>test</scope>\r
+    </dependency>\r
+    \r
+    <!-- AssertJ -->\r
+       <dependency>\r
+               <groupId>org.assertj</groupId>\r
+               <artifactId>assertj-core</artifactId>\r
+               <version>2.0.0</version>\r
+               <scope>test</scope>\r
+       </dependency>\r
+       \r
+  </dependencies>\r
+  \r
+  <build>\r
+               <plugins>\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-compiler-plugin</artifactId>\r
+                               <version>${plugin.compiler.version}</version>\r
+                               <configuration>\r
+                                       <source>${java.source}</source>\r
+                                       <target>${java.target}</target>\r
+                               </configuration>\r
+                       </plugin>\r
+                       <plugin>\r
+                               <groupId>de.juplo</groupId>\r
+                               <artifactId>hibernate-maven-plugin</artifactId>\r
+                               <version>@project.version@</version>\r
+                               <executions>\r
+                                       <execution>\r
+                                               <phase>test-compile</phase>\r
+                                               <goals>\r
+                                                       <goal>drop</goal>\r
+                                                       <goal>create</goal>\r
+                                               </goals>\r
+                                       </execution>\r
+                               </executions>\r
+                               <configuration>\r
+                                       <!-- Connection-Properties -->\r
+                                       <dialect>org.hibernate.dialect.H2Dialect</dialect>\r
+                                       <driver>org.h2.Driver</driver>\r
+                                   <url><![CDATA[jdbc:h2:file:${project.build.directory}/db/test]]></url>\r
+                                   <username>sa</username>\r
+                                   <password>sa</password>\r
+\r
+                                       <!-- Other Properties -->\r
+                                       <force>true</force>  <!-- needed, otherwise test:create skips script-execution -->\r
+                                       <outputFile>db-schema/create-schema.ddl</outputFile>\r
+                                       <format>true</format>\r
+                                       <scanTestClasses>true</scanTestClasses>\r
+                               </configuration>\r
+                               <dependencies>\r
+                                       <dependency>\r
+                                               <groupId>com.h2database</groupId>\r
+                                               <artifactId>h2</artifactId>\r
+                                               <version>1.3.168-redhat-2</version>\r
+                                       </dependency>\r
+                               </dependencies>\r
+                       </plugin>\r
+               </plugins>\r
+               \r
+               <pluginManagement>\r
+                       <plugins>\r
+                               <!--This plugin's configuration is used to store Eclipse m2e settings\r
+                                       only. It has no influence on the Maven build itself. -->\r
+                               <plugin>\r
+                                       <groupId>org.eclipse.m2e</groupId>\r
+                                       <artifactId>lifecycle-mapping</artifactId>\r
+                                       <version>1.0.0</version>\r
+                                       <configuration>\r
+                                               <lifecycleMappingMetadata>\r
+                                                       <pluginExecutions>\r
+                                                               <pluginExecution>\r
+                                                                       <pluginExecutionFilter>\r
+                                                                               <groupId>de.juplo</groupId>\r
+                                                                               <artifactId>hibernate-maven-plugin</artifactId>\r
+                                                                               <versionRange>[2.0.0,)</versionRange>\r
+                                                                               <goals>\r
+                                                                                       <goal>drop</goal>\r
+                                                                                       <goal>create</goal>\r
+                                                                               </goals>\r
+                                                                       </pluginExecutionFilter>\r
+                                                                       <action>\r
+                                                                               <ignore />\r
+                                                                       </action>\r
+                                                               </pluginExecution>\r
+                                                       </pluginExecutions>\r
+                                               </lifecycleMappingMetadata>\r
+                                       </configuration>\r
+                               </plugin>\r
+                       </plugins>\r
+               </pluginManagement>\r
+       </build>\r
+  \r
+</project>\r
diff --git a/src/it/hmp-testclasses-annotationscanning/readme.txt b/src/it/hmp-testclasses-annotationscanning/readme.txt
new file mode 100644 (file)
index 0000000..1728007
--- /dev/null
@@ -0,0 +1,19 @@
+Example-Project "Hibernate-Maven-Plugin Testclasses Annotation-Scanning"\r
+\r
+This is a small Exampleproject for a base Database-Integrationtest, with the use of the "Hibernate Maven Plugin" from de.juplo for the automatic Generation and the Execution of the create-schema-sql-script. \r
+\r
+The hibernate-maven-plugin - defined in the plugins-section in the pom.xml -  scans the code for Entities to create the schema-script. Entity-Scanning is or can be done in following 3 locations:\r
+*) Project-Classes: By default, the plugin scans for @Entitiy-Annotated classes under "target/classes".\r
+*) Project-Testclasses: By default, the plugin scans for @Entitiy-Annotated classes under "target/test-classes".\r
+*) Project-Dependencies: Compile-Time-Dependencies wil also be scanned.\r
+\r
+Test-Structure:\r
+-) Basic Code for User-Change-Tracking over JPA EntityListener: Some basic Interfaces and Classes for a automatic tracking of the User and the Date at the Phases PRE-PERSIST and PRE-UPDATE are located under src/main/java.\r
+-) The important Test-Entity "UserChangeInfoTest" for testing the userinfo-tracking and the Testservice-Declaration and -Implementation for storing/updating/reading such Test-Entity is located under src/test/java. \r
+-) Integrationtest(s): The Integrationtest "UserChangeInfoTest" is based on Arquillian. Arquillian starts an OpenEJB Embedded Container, seeds the Database with Testdata, and executes the Integrationtest.\r
+-) Dataset-Files, and different configurationfiles for Arquillian, JPA, Logback,... are located under src/test/resources.\r
+\r
+\r
+Building the Project:\r
+As usual: To build and install the project into your local maven-repository, execute "mvn install".\r
+\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/BaseEntity.java b/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/BaseEntity.java
new file mode 100644 (file)
index 0000000..6d64c37
--- /dev/null
@@ -0,0 +1,61 @@
+package net.java.examples.hmp.model.domain;\r
+\r
+import java.io.Serializable;\r
+\r
+import org.hibernate.proxy.HibernateProxy;\r
+\r
+public abstract class BaseEntity<T extends Serializable> implements IBaseEntity<T>, Serializable {\r
+\r
+    private static final long serialVersionUID = -5828097391861473323L;\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public int hashCode() {\r
+        int result;\r
+        if (getId() == null) {\r
+            result = super.hashCode();\r
+        } else {\r
+            final int prime = 31;\r
+            result = 1;\r
+            result = prime * result + ((getId() == null) ? 0 : getId().hashCode());\r
+        }\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(final Object obj) {\r
+        if (this == obj) {\r
+            return true;\r
+        }\r
+        if (obj == null) {\r
+            return false;\r
+        }\r
+\r
+        Class<?> otherClass = null;\r
+        if (obj instanceof HibernateProxy) {\r
+            otherClass = ((HibernateProxy) obj).getHibernateLazyInitializer().getPersistentClass();\r
+        } else {\r
+            otherClass = obj.getClass();\r
+        }\r
+        if (getClass() != otherClass) {\r
+            return false;\r
+        }\r
+\r
+        return compareEqualityWithThisInstance((BaseEntity<?>) obj);\r
+    }\r
+\r
+    private boolean compareEqualityWithThisInstance(BaseEntity<?> otherEntity) {\r
+        if (getId() != null) {\r
+            return getId().equals(otherEntity.getId());\r
+        }\r
+\r
+        return false;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return this.getClass().getName() + "[id=" + getId() + "]";\r
+    }\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/Fachgebiet.java b/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/Fachgebiet.java
new file mode 100644 (file)
index 0000000..0464a16
--- /dev/null
@@ -0,0 +1,80 @@
+package net.java.examples.hmp.model.domain;\r
+\r
+import java.io.Serializable;\r
+\r
+import javax.persistence.Column;\r
+import javax.persistence.Entity;\r
+import javax.persistence.EntityListeners;\r
+import javax.persistence.GeneratedValue;\r
+import javax.persistence.GenerationType;\r
+import javax.persistence.Id;\r
+import javax.persistence.SequenceGenerator;\r
+import javax.persistence.Table;\r
+import javax.persistence.Version;\r
+import javax.validation.constraints.Size;\r
+\r
+import org.hibernate.validator.constraints.NotBlank;\r
+\r
+import net.java.examples.hmp.model.domain.callback.UserChangeTrackListener;\r
+import net.java.examples.hmp.model.domain.userchangeinfo.BaseUserChangeTrackedEntity;\r
+\r
+@Entity\r
+@Table(name = "HMP_FACHGEBIET")\r
+@EntityListeners(UserChangeTrackListener.class)\r
+public class Fachgebiet extends BaseUserChangeTrackedEntity<Long> implements Serializable {\r
+\r
+    private static final long serialVersionUID = -2362501487481778376L;\r
+\r
+    @Id\r
+    @Column(name = "ID", nullable = false)\r
+    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "FachgebietSeq")\r
+    @SequenceGenerator(name = "FachgebietSeq", sequenceName = "HMP_SEQ", allocationSize = 1)\r
+    private Long id;\r
+\r
+    @NotBlank\r
+    @Size(max = 2)\r
+    @Column(name = "CODE", nullable = false)\r
+    private String code;\r
+\r
+    @NotBlank\r
+    @Size(max = 500)\r
+    @Column(name = "NAME", nullable = false)\r
+    private String name;\r
+\r
+    @Version\r
+    @Column(name = "VERSION")\r
+    private Long version;\r
+\r
+    @Override\r
+    public Long getId() {\r
+        return id;\r
+    }\r
+\r
+    public void setId(Long id) {\r
+        this.id = id;\r
+    }\r
+\r
+    public String getCode() {\r
+        return code;\r
+    }\r
+\r
+    public void setCode(String code) {\r
+        this.code = code;\r
+    }\r
+\r
+    public String getName() {\r
+        return name;\r
+    }\r
+\r
+    public void setName(String name) {\r
+        this.name = name;\r
+    }\r
+\r
+    public Long getVersion() {\r
+        return version;\r
+    }\r
+\r
+    public void setVersion(Long version) {\r
+        this.version = version;\r
+    }\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/IBaseEntity.java b/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/IBaseEntity.java
new file mode 100644 (file)
index 0000000..d309229
--- /dev/null
@@ -0,0 +1,19 @@
+package net.java.examples.hmp.model.domain;\r
+\r
+import java.io.Serializable;\r
+\r
+/**\r
+ * Basis interface fuer alle entities. Jede entity muss eine serialisierbare ID liefern.\r
+ * \r
+ * @param <T> Klassentyp fuer ID\r
+ */\r
+public interface IBaseEntity<T extends Serializable> {\r
+\r
+    /**\r
+     * Liefert die Id.\r
+     * \r
+     * @return T die Id\r
+     */\r
+    T getId();\r
+\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/callback/UserChangeTrackListener.java b/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/callback/UserChangeTrackListener.java
new file mode 100644 (file)
index 0000000..5553284
--- /dev/null
@@ -0,0 +1,60 @@
+package net.java.examples.hmp.model.domain.callback;\r
+\r
+import java.util.Date;\r
+\r
+import javax.persistence.PrePersist;\r
+import javax.persistence.PreUpdate;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import net.java.examples.hmp.model.domain.extension.IUserChangeInfo;\r
+import net.java.examples.hmp.model.domain.extension.IUserChangeTrackable;\r
+\r
+public class UserChangeTrackListener {\r
+\r
+    public static final String DEFAULT_USER_NAME = "System";\r
+\r
+    private static final Logger LOG = LoggerFactory.getLogger(UserChangeTrackListener.class);\r
+\r
+    @PreUpdate\r
+    protected void preUpdate(IUserChangeTrackable userChangeTrackable) {\r
+        IUserChangeInfo userChangeInfo = userChangeTrackable.getUserChangeInfo();\r
+\r
+        if (userChangeInfo == null) {\r
+            LOG.warn("IUserChangeInfo of entity {} is null, no change tracking possible.", userChangeTrackable);\r
+            return;\r
+        }\r
+\r
+        userChangeInfo.setChangeDate(new Date());\r
+        userChangeInfo.setChangeUser(getCurrentUser());\r
+\r
+        if (LOG.isTraceEnabled()) {\r
+            LOG.trace("onPreUpdate objectType={}, userChangeInfo={}", userChangeTrackable.getClass().getName(), userChangeInfo.toString());\r
+        }\r
+    }\r
+\r
+    @PrePersist\r
+    protected void prePersist(IUserChangeTrackable userChangeTrackable) {\r
+        IUserChangeInfo userChangeInfo = userChangeTrackable.getUserChangeInfo();\r
+\r
+        userChangeInfo.setCreateDate(new Date());\r
+        userChangeInfo.setChangeDate(userChangeInfo.getCreateDate());\r
+        userChangeInfo.setCreateUser(getCurrentUser());\r
+        userChangeInfo.setChangeUser(userChangeInfo.getCreateUser());\r
+\r
+        if (LOG.isTraceEnabled()) {\r
+            LOG.trace("onPrePersist objectType={}, userChangeInfo={}", userChangeTrackable.getClass().getName(), userChangeInfo.toString());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Real methodcode replaced with example-code.\r
+     * \r
+     * @return Always displays the same constant string\r
+     */\r
+    protected String getCurrentUser() {\r
+\r
+        return DEFAULT_USER_NAME;\r
+    }\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/extension/IUserChangeInfo.java b/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/extension/IUserChangeInfo.java
new file mode 100644 (file)
index 0000000..38180ae
--- /dev/null
@@ -0,0 +1,22 @@
+package net.java.examples.hmp.model.domain.extension;\r
+\r
+import java.util.Date;\r
+\r
+public interface IUserChangeInfo {\r
+\r
+    Date getCreateDate();\r
+\r
+    void setCreateDate(Date createDate);\r
+\r
+    Date getChangeDate();\r
+\r
+    void setChangeDate(Date changeDate);\r
+\r
+    String getCreateUser();\r
+\r
+    void setCreateUser(String createUser);\r
+\r
+    String getChangeUser();\r
+\r
+    void setChangeUser(String changeUser);\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/extension/IUserChangeTrackable.java b/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/extension/IUserChangeTrackable.java
new file mode 100644 (file)
index 0000000..18c4d4c
--- /dev/null
@@ -0,0 +1,6 @@
+package net.java.examples.hmp.model.domain.extension;\r
+\r
+public interface IUserChangeTrackable {\r
+\r
+    IUserChangeInfo getUserChangeInfo();\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/userchangeinfo/BaseUserChangeTrackedEntity.java b/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/userchangeinfo/BaseUserChangeTrackedEntity.java
new file mode 100644 (file)
index 0000000..53c9364
--- /dev/null
@@ -0,0 +1,31 @@
+package net.java.examples.hmp.model.domain.userchangeinfo;\r
+\r
+import java.io.Serializable;\r
+\r
+import javax.persistence.Embedded;\r
+import javax.persistence.MappedSuperclass;\r
+\r
+import net.java.examples.hmp.model.domain.BaseEntity;\r
+import net.java.examples.hmp.model.domain.extension.IUserChangeTrackable;\r
+\r
+@MappedSuperclass\r
+public abstract class BaseUserChangeTrackedEntity<T extends Serializable> extends BaseEntity<T> implements IUserChangeTrackable {\r
+\r
+    private static final long serialVersionUID = -7850597447088838323L;\r
+\r
+    @Embedded\r
+    private UserChangeInfo userChangeInfo = new UserChangeInfo();\r
+\r
+    @Override\r
+    public UserChangeInfo getUserChangeInfo() {\r
+        // Workaround for Hibernate! For detailed information see this link: https://hibernate.atlassian.net/browse/HHH-7610\r
+        if (this.userChangeInfo == null) {\r
+            this.userChangeInfo = new UserChangeInfo();\r
+        }\r
+        return this.userChangeInfo;\r
+    }\r
+\r
+    public void setUserChangeInfo(UserChangeInfo userChangeInfo) {\r
+        this.userChangeInfo = userChangeInfo;\r
+    }\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/userchangeinfo/UserChangeInfo.java b/src/it/hmp-testclasses-annotationscanning/src/main/java/net/java/examples/hmp/model/domain/userchangeinfo/UserChangeInfo.java
new file mode 100644 (file)
index 0000000..a5d10f6
--- /dev/null
@@ -0,0 +1,82 @@
+package net.java.examples.hmp.model.domain.userchangeinfo;\r
+\r
+import java.io.Serializable;\r
+import java.util.Date;\r
+\r
+import javax.persistence.Column;\r
+import javax.persistence.Embeddable;\r
+import javax.persistence.Temporal;\r
+import javax.persistence.TemporalType;\r
+import javax.validation.constraints.Size;\r
+\r
+import net.java.examples.hmp.model.domain.extension.IUserChangeInfo;\r
+\r
+@Embeddable\r
+public class UserChangeInfo implements IUserChangeInfo, Serializable {\r
+\r
+    private static final long serialVersionUID = -1372176907214369831L;\r
+\r
+    @Temporal(TemporalType.TIMESTAMP)\r
+    @Column(name = "ERSTELLT_AM")\r
+    private Date createDate;\r
+\r
+    @Temporal(TemporalType.TIMESTAMP)\r
+    @Column(name = "GEAENDERT_AM")\r
+    private Date changeDate;\r
+\r
+    @Size(max = 20)\r
+    @Column(name = "ERSTELLT_VON")\r
+    private String createUser;\r
+\r
+    @Size(max = 20)\r
+    @Column(name = "GEAENDERT_VON")\r
+    private String changeUser;\r
+\r
+    @Override\r
+    public Date getCreateDate() {\r
+        return createDate;\r
+    }\r
+\r
+    @Override\r
+    public void setCreateDate(Date createDate) {\r
+        this.createDate = createDate;\r
+    }\r
+\r
+    @Override\r
+    public Date getChangeDate() {\r
+        return changeDate;\r
+    }\r
+\r
+    @Override\r
+    public void setChangeDate(Date changeDate) {\r
+        this.changeDate = changeDate;\r
+    }\r
+\r
+    @Override\r
+    public String getCreateUser() {\r
+        return createUser;\r
+    }\r
+\r
+    @Override\r
+    public void setCreateUser(String createUser) {\r
+        this.createUser = createUser;\r
+    }\r
+\r
+    @Override\r
+    public String getChangeUser() {\r
+        return changeUser;\r
+    }\r
+\r
+    @Override\r
+    public void setChangeUser(String changeUser) {\r
+        this.changeUser = changeUser;\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public String toString() {\r
+        return "UserChangeInfo [createDate=" + createDate + ", createUser=" + createUser + ", changeDate=" + changeDate + ", changeUser=" + changeUser + "]";\r
+    }\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/model/domain/userchangeinfo/test/UserChangeInfoTest.java b/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/model/domain/userchangeinfo/test/UserChangeInfoTest.java
new file mode 100644 (file)
index 0000000..496aaf8
--- /dev/null
@@ -0,0 +1,84 @@
+package net.java.examples.hmp.model.domain.userchangeinfo.test;\r
+\r
+import static org.assertj.core.api.Assertions.assertThat;\r
+\r
+import javax.inject.Inject;\r
+\r
+import org.jboss.arquillian.container.test.api.Deployment;\r
+import org.jboss.arquillian.junit.Arquillian;\r
+import org.jboss.arquillian.persistence.UsingDataSet;\r
+import org.jboss.shrinkwrap.api.spec.WebArchive;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import net.java.examples.hmp.model.domain.callback.UserChangeTrackListener;\r
+import net.java.examples.hmp.model.domain.extension.IUserChangeInfo;\r
+import net.java.examples.hmp.model.test.userchangeinfo.UserChangeInfoTestEntity;\r
+import net.java.examples.hmp.service.IUserChangeInfoTestService;\r
+import net.java.examples.hmp.test.util.BaseDeploymentPackage;\r
+\r
+@RunWith(Arquillian.class)\r
+@UsingDataSet("datasets/userchangeinfo/userchangeinfo.json")\r
+public class UserChangeInfoTest {\r
+\r
+    private static final Logger LOG = LoggerFactory.getLogger(UserChangeInfoTest.class);\r
+\r
+    @Inject\r
+    private IUserChangeInfoTestService userChangeInfoTestService;\r
+\r
+    @Deployment\r
+    public static WebArchive createDeploymentPackage() {\r
+        BaseDeploymentPackage deploymentPackage = new BaseDeploymentPackage() //\r
+                .createStandardDeploymentPackage() //\r
+                .addTestPersistence() //\r
+                .addPackagesModel() //\r
+                .addPackageTestModel() //\r
+                .addPackagesUserChangeTrack() //\r
+                .addPackagesTestServices();\r
+\r
+        LOG.debug(deploymentPackage.toString());\r
+        return deploymentPackage.getWAR();\r
+    }\r
+\r
+    @Test\r
+    public void saveAndLoadWithDefaultUser() {\r
+        UserChangeInfoTestEntity userChangeInfoTestEntity = createAndPersistTestEntity();\r
+\r
+        userChangeInfoTestEntity = this.userChangeInfoTestService.getData(userChangeInfoTestEntity.getId());\r
+        IUserChangeInfo userChangeInfo = userChangeInfoTestEntity.getUserChangeInfo();\r
+\r
+        assertThat("junit-test").isEqualTo(userChangeInfoTestEntity.getName());\r
+\r
+        assertThat(userChangeInfo.getCreateUser()).isEqualTo(UserChangeTrackListener.DEFAULT_USER_NAME);\r
+        assertThat(userChangeInfo.getChangeUser()).isEqualTo(UserChangeTrackListener.DEFAULT_USER_NAME);\r
+\r
+        assertThat(userChangeInfo.getCreateDate()).isNotNull();\r
+        assertThat(userChangeInfo.getChangeDate()).isNotNull();\r
+        assertThat(userChangeInfo.getCreateDate().getTime()).isEqualTo(userChangeInfo.getChangeDate().getTime());\r
+    }\r
+\r
+    private UserChangeInfoTestEntity createAndPersistTestEntity() {\r
+        UserChangeInfoTestEntity userChangeInfoTestEntity = new UserChangeInfoTestEntity();\r
+        userChangeInfoTestEntity.setName("junit-test");\r
+\r
+        this.userChangeInfoTestService.persistData(userChangeInfoTestEntity);\r
+\r
+        return userChangeInfoTestEntity;\r
+    }\r
+\r
+    @Test\r
+    public void getUserChangeInfoTestEntityExpectingUserChangeInfoObjectNotNull() {\r
+        UserChangeInfoTestEntity userChangeInfoTestEntity = this.userChangeInfoTestService.getData(new Long(1002));\r
+\r
+        assertThat(userChangeInfoTestEntity).isNotNull();\r
+        assertThat(userChangeInfoTestEntity.getName()).isEqualTo("Testentity - alle UserChangeInfoFelder sind null");\r
+\r
+        assertThat(userChangeInfoTestEntity.getUserChangeInfo()).isNotNull();\r
+        assertThat(userChangeInfoTestEntity.getUserChangeInfo().getCreateUser()).isNull();\r
+        assertThat(userChangeInfoTestEntity.getUserChangeInfo().getCreateDate()).isNull();\r
+        assertThat(userChangeInfoTestEntity.getUserChangeInfo().getChangeUser()).isNull();\r
+        assertThat(userChangeInfoTestEntity.getUserChangeInfo().getChangeDate()).isNull();\r
+    }\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/model/test/userchangeinfo/UserChangeInfoTestEntity.java b/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/model/test/userchangeinfo/UserChangeInfoTestEntity.java
new file mode 100644 (file)
index 0000000..7ca7234
--- /dev/null
@@ -0,0 +1,54 @@
+package net.java.examples.hmp.model.test.userchangeinfo;\r
+\r
+import javax.persistence.Column;\r
+import javax.persistence.Entity;\r
+import javax.persistence.EntityListeners;\r
+import javax.persistence.GeneratedValue;\r
+import javax.persistence.Id;\r
+import javax.persistence.SequenceGenerator;\r
+import javax.persistence.Table;\r
+\r
+import net.java.examples.hmp.model.domain.callback.UserChangeTrackListener;\r
+import net.java.examples.hmp.model.domain.userchangeinfo.BaseUserChangeTrackedEntity;\r
+\r
+/**\r
+ * Entity zum Testen der UserChangeInfo Funktionalitaet.\r
+ */\r
+@Entity\r
+@Table(name = "HMP_UCI_TEST_ENTITY")\r
+@EntityListeners(UserChangeTrackListener.class)\r
+public class UserChangeInfoTestEntity extends BaseUserChangeTrackedEntity<Long> {\r
+\r
+    private static final long serialVersionUID = -530295910082787747L;\r
+\r
+    @Id\r
+    @Column(name = "ID", nullable = false)\r
+    @GeneratedValue(generator = "UserchangeInfoTestEntitySeq")\r
+    @SequenceGenerator(name = "UserchangeInfoTestEntitySeq", sequenceName = "HMP_SEQ", allocationSize = 1)\r
+    private Long id;\r
+\r
+    @Column(name = "NAME", nullable = false)\r
+    private String name;\r
+\r
+    @Override\r
+    public Long getId() {\r
+        return id;\r
+    }\r
+\r
+    public void setId(Long id) {\r
+        this.id = id;\r
+    }\r
+\r
+    public String getName() {\r
+        return name;\r
+    }\r
+\r
+    public void setName(String name) {\r
+        this.name = name;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return "UserChangeInfoTestEntity [id=" + id + ", name=" + name + "]";\r
+    }\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/persistence/producer/EntityManagerProducer.java b/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/persistence/producer/EntityManagerProducer.java
new file mode 100644 (file)
index 0000000..abcd3ee
--- /dev/null
@@ -0,0 +1,23 @@
+package net.java.examples.hmp.persistence.producer;\r
+\r
+import javax.enterprise.context.RequestScoped;\r
+import javax.enterprise.inject.Produces;\r
+import javax.persistence.EntityManager;\r
+import javax.persistence.PersistenceContext;\r
+\r
+public class EntityManagerProducer {\r
+\r
+    @PersistenceContext(unitName = "persistence-hmp")\r
+    private EntityManager em;\r
+\r
+    /**\r
+     * Liefert den BOA-EntityManager.\r
+     * \r
+     * @return EntityManager\r
+     */\r
+    @Produces\r
+    @RequestScoped\r
+    public EntityManager createEntityManager() {\r
+        return em;\r
+    }\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/service/IUserChangeInfoTestService.java b/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/service/IUserChangeInfoTestService.java
new file mode 100644 (file)
index 0000000..e62b153
--- /dev/null
@@ -0,0 +1,32 @@
+package net.java.examples.hmp.service;\r
+\r
+import net.java.examples.hmp.model.test.userchangeinfo.UserChangeInfoTestEntity;\r
+\r
+/**\r
+ * Testservice fuer UserChangeInfo Tests\r
+ */\r
+public interface IUserChangeInfoTestService {\r
+\r
+    /**\r
+     * persist ausfuehren\r
+     * \r
+     * @param entity UserChangeInfoTestEntity\r
+     */\r
+    void persistData(UserChangeInfoTestEntity entity);\r
+\r
+    /**\r
+     * merge+flush ausfuehren\r
+     * \r
+     * @param entity UserChangeInfoTestEntity\r
+     * @return gespeicherte Daten\r
+     */\r
+    UserChangeInfoTestEntity mergeData(UserChangeInfoTestEntity entity);\r
+\r
+    /**\r
+     * Find by id\r
+     * \r
+     * @param id ID fuer entity\r
+     * @return UserChangeInfoTestEntity\r
+     */\r
+    UserChangeInfoTestEntity getData(Long id);\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/service/impl/UserChangeInfoTestService.java b/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/service/impl/UserChangeInfoTestService.java
new file mode 100644 (file)
index 0000000..040bad0
--- /dev/null
@@ -0,0 +1,34 @@
+package net.java.examples.hmp.service.impl;\r
+\r
+import javax.ejb.Stateless;\r
+import javax.persistence.EntityManager;\r
+import javax.persistence.PersistenceContext;\r
+\r
+import net.java.examples.hmp.model.test.userchangeinfo.UserChangeInfoTestEntity;\r
+import net.java.examples.hmp.service.IUserChangeInfoTestService;\r
+\r
+@Stateless\r
+public class UserChangeInfoTestService implements IUserChangeInfoTestService {\r
+\r
+    @PersistenceContext\r
+    private EntityManager em;\r
+\r
+    @Override\r
+    public void persistData(UserChangeInfoTestEntity entity) {\r
+        em.persist(entity);\r
+        em.flush();\r
+    }\r
+\r
+    @Override\r
+    public UserChangeInfoTestEntity mergeData(UserChangeInfoTestEntity entity) {\r
+        em.merge(entity);\r
+        em.flush();\r
+\r
+        return getData(entity.getId());\r
+    }\r
+\r
+    @Override\r
+    public UserChangeInfoTestEntity getData(Long id) {\r
+        return em.find(UserChangeInfoTestEntity.class, id);\r
+    }\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/test/util/BaseDeploymentPackage.java b/src/it/hmp-testclasses-annotationscanning/src/test/java/net/java/examples/hmp/test/util/BaseDeploymentPackage.java
new file mode 100644 (file)
index 0000000..25d4468
--- /dev/null
@@ -0,0 +1,120 @@
+package net.java.examples.hmp.test.util;\r
+\r
+import org.jboss.shrinkwrap.api.ArchivePath;\r
+import org.jboss.shrinkwrap.api.Filter;\r
+import org.jboss.shrinkwrap.api.ShrinkWrap;\r
+import org.jboss.shrinkwrap.api.spec.WebArchive;\r
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;\r
+import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage;\r
+\r
+import net.java.examples.hmp.model.domain.BaseEntity;\r
+import net.java.examples.hmp.model.domain.callback.UserChangeTrackListener;\r
+import net.java.examples.hmp.model.domain.extension.IUserChangeInfo;\r
+import net.java.examples.hmp.model.domain.extension.IUserChangeTrackable;\r
+import net.java.examples.hmp.model.domain.userchangeinfo.BaseUserChangeTrackedEntity;\r
+import net.java.examples.hmp.model.domain.userchangeinfo.UserChangeInfo;\r
+import net.java.examples.hmp.model.test.userchangeinfo.UserChangeInfoTestEntity;\r
+import net.java.examples.hmp.persistence.producer.EntityManagerProducer;\r
+import net.java.examples.hmp.service.IUserChangeInfoTestService;\r
+import net.java.examples.hmp.service.impl.UserChangeInfoTestService;\r
+\r
+public class BaseDeploymentPackage {\r
+\r
+    private WebArchive war;\r
+    PomEquippedResolveStage resolver = createOfflineResolverForDefaultPomFile();\r
+\r
+    private static final IgnoreTestClassesFilter IGNORE_TEST_CLASSES_FILTER = new IgnoreTestClassesFilter();\r
+\r
+    public PomEquippedResolveStage createOfflineResolverForDefaultPomFile() {\r
+        return Maven.configureResolver().workOffline(true).loadPomFromFile("pom.xml");\r
+    }\r
+\r
+    public BaseDeploymentPackage addPackages(Package... packages) {\r
+        this.war.addPackages(false, IGNORE_TEST_CLASSES_FILTER, packages);\r
+        return this;\r
+    }\r
+\r
+    public BaseDeploymentPackage addClasses(Class<?>... classes) {\r
+        this.war.addClasses(classes);\r
+\r
+        return this;\r
+    }\r
+\r
+    public BaseDeploymentPackage addClass(Class<?> clazz) {\r
+        this.war.addClass(clazz);\r
+\r
+        return this;\r
+    }\r
+\r
+    public static class IgnoreTestClassesFilter implements Filter<ArchivePath> {\r
+\r
+        @Override\r
+        public boolean include(ArchivePath object) {\r
+            return !object.get().endsWith("Test.class");\r
+        }\r
+    }\r
+\r
+    public BaseDeploymentPackage createStandardDeploymentPackage() {\r
+        PomEquippedResolveStage resolver = createOfflineResolverForDefaultPomFile();\r
+\r
+        this.war = ShrinkWrap.create(WebArchive.class, "test.war")//\r
+                .addAsWebInfResource("beans.xml", "beans.xml")//\r
+                .addAsLibraries(resolver.resolve(//\r
+                        "org.assertj:assertj-core", // Assertj must be included to use the Assertj-Assertions in the Test-Methods\r
+                        "com.google.guava:guava", //\r
+                        "org.apache.commons:commons-lang3", //\r
+                        "commons-beanutils:commons-beanutils", //\r
+                        "org.apache.deltaspike.core:deltaspike-core-api", //\r
+                        "org.apache.deltaspike.core:deltaspike-core-impl").withTransitivity().asFile());\r
+\r
+        return this;\r
+    }\r
+\r
+    public BaseDeploymentPackage addTestPersistence() {\r
+        this.war.addAsResource("test-persistence.xml", "META-INF/persistence.xml");\r
+        return this;\r
+    }\r
+\r
+    public BaseDeploymentPackage addPackagesModel() {\r
+        addClass(EntityManagerProducer.class);\r
+\r
+        this.addPackageModelDomain();\r
+\r
+        return this;\r
+    }\r
+\r
+    private BaseDeploymentPackage addPackageModelDomain() {\r
+        addPackages(BaseEntity.class.getPackage());\r
+        addPackages(IUserChangeInfo.class.getPackage());\r
+\r
+        return this;\r
+    }\r
+\r
+    public BaseDeploymentPackage addPackageTestModel() {\r
+        // Here the definition of our Test-Entity, which is located under src/test/classes\r
+        addClass(UserChangeInfoTestEntity.class);\r
+\r
+        return this;\r
+    }\r
+\r
+    public BaseDeploymentPackage addPackagesUserChangeTrack() {\r
+        addClass(UserChangeInfo.class);\r
+        addClass(IUserChangeInfo.class);\r
+        addClass(UserChangeTrackListener.class);\r
+        addClass(IUserChangeTrackable.class);\r
+        addClass(BaseUserChangeTrackedEntity.class);\r
+\r
+        return this;\r
+    }\r
+\r
+    public BaseDeploymentPackage addPackagesTestServices() {\r
+        addClass(IUserChangeInfoTestService.class);\r
+        addClass(UserChangeInfoTestService.class);\r
+\r
+        return this;\r
+    }\r
+\r
+    public WebArchive getWAR() {\r
+        return this.war;\r
+    }\r
+}\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/src/it/hmp-testclasses-annotationscanning/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
new file mode 100644 (file)
index 0000000..7d31029
--- /dev/null
@@ -0,0 +1 @@
+org.jboss.arquillian.persistence.core.container.RemotePersistenceExtension
\ No newline at end of file
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.dbunit.properties b/src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.dbunit.properties
new file mode 100644 (file)
index 0000000..17fe2f1
--- /dev/null
@@ -0,0 +1,5 @@
+# can contain all dbunit properties\r
+caseSensitiveTableNames = false\r
+datatypeWarning = false\r
+defaultDataSetFormat = JSON\r
+datatypeFactory = org.dbunit.ext.h2.H2DataTypeFactory
\ No newline at end of file
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.jpacacheeviction.properties b/src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.jpacacheeviction.properties
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.properties b/src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.properties
new file mode 100644 (file)
index 0000000..15d5f6f
--- /dev/null
@@ -0,0 +1,4 @@
+defaultDataSeedStrategy = CLEAN_INSERT\r
+defaultDataSource = openejb:Resource/HmpArquillianTest\r
+dumpData = false\r
+arquillian.extension.persistence.default.transaction.mode=DISABLED
\ No newline at end of file
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.script.properties b/src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.extension.persistence.script.properties
new file mode 100644 (file)
index 0000000..5d3d981
--- /dev/null
@@ -0,0 +1,2 @@
+# can contain all script properties\r
+sqlStatementDelimiter = NEW_LINE
\ No newline at end of file
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.xml b/src/it/hmp-testclasses-annotationscanning/src/test/resources/arquillian.xml
new file mode 100644 (file)
index 0000000..b9b8a6d
--- /dev/null
@@ -0,0 +1,28 @@
+<arquillian xmlns="http://jboss.org/schema/arquillian"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="\r
+        http://jboss.org/schema/arquillian\r
+        http://jboss.org/schema/arquillian/arquillian_1_0.xsd">\r
+\r
+       <extension qualifier="persistence">\r
+               <property name="defaultTransactionMode">DISABLED</property>\r
+       </extension>\r
+\r
+       <container default="true" qualifier="openejb-embedded-4">\r
+               <configuration>\r
+               \r
+                       <!-- First Declaration-Block in the "properties"-property is for the BoaArquillianTest Datasource -->\r
+                       <!-- Second Declaration-Block in the "properties"-property is for the System-Properties like Deltaspike ProjectStage,... -->\r
+                       <property name="properties">\r
+                               HmpArquillianTest = new://Resource?type=DataSource\r
+                               HmpArquillianTest.JdbcUrl = jdbc:h2:file:target/db/test\r
+                               HmpArquillianTest.UserName = sa\r
+                               HmpArquillianTest.Password = sa\r
+                               HmpArquillianTest.jdbcDriver = org.h2.Driver\r
+                               \r
+                               org.apache.deltaspike.ProjectStage=UnitTest\r
+                               file.encoding=UTF-8\r
+                       </property>\r
+               </configuration>\r
+       </container>\r
+</arquillian>\r
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/resources/beans.xml b/src/it/hmp-testclasses-annotationscanning/src/test/resources/beans.xml
new file mode 100644 (file)
index 0000000..5e1a333
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:weld="http://jboss.org/schema/weld/beans"\r
+    xsi:schemaLocation="\r
+          http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd\r
+          http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">\r
+</beans>
\ No newline at end of file
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/resources/datasets/userchangeinfo/userchangeinfo.json b/src/it/hmp-testclasses-annotationscanning/src/test/resources/datasets/userchangeinfo/userchangeinfo.json
new file mode 100644 (file)
index 0000000..cb18b22
--- /dev/null
@@ -0,0 +1,15 @@
+{\r
+       "HMP_UCI_TEST_ENTITY":\r
+       [\r
+               {\r
+                       "ID":1001,\r
+                       "NAME":"Test UserChangeInfo-Entity ohne UserChangeInfo",\r
+                       "ERSTELLT_AM":"2014-01-01 12:12:12",\r
+                       "ERSTELLT_VON":"aq-p"\r
+               },\r
+               {\r
+                       "ID":1002,\r
+                       "NAME":"Testentity - alle UserChangeInfoFelder sind null"\r
+               }\r
+       ]\r
+}
\ No newline at end of file
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/resources/logback-test.xml b/src/it/hmp-testclasses-annotationscanning/src/test/resources/logback-test.xml
new file mode 100644 (file)
index 0000000..8d50df2
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+\r
+<!-- See http://logback.qos.ch/manual/appenders.html for Appenders-Configuration -->\r
+\r
+<configuration>\r
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+    <encoder>\r
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>\r
+    </encoder>\r
+  </appender>\r
+\r
+  <root level="WARN">\r
+    <appender-ref ref="STDOUT" />\r
+  </root>\r
+</configuration>
\ No newline at end of file
diff --git a/src/it/hmp-testclasses-annotationscanning/src/test/resources/test-persistence.xml b/src/it/hmp-testclasses-annotationscanning/src/test/resources/test-persistence.xml
new file mode 100644 (file)
index 0000000..a2e2c98
--- /dev/null
@@ -0,0 +1,21 @@
+<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/persistence"\r
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"\r
+    version="1.0">\r
+    <persistence-unit name="persistence-hmp" transaction-type="JTA">\r
+    \r
+       <provider>org.hibernate.ejb.HibernatePersistence</provider>\r
+    \r
+       <jta-data-source>HmpArquillianTest</jta-data-source>\r
+    \r
+       <class>net.java.examples.hmp.model.test.userchangeinfo.UserChangeInfoTestEntity</class>\r
+    \r
+        <properties>\r
+            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />\r
+            <property name="hibernate.show_sql" value="true" />\r
+            <property name="hibernate.format_sql" value="true" />\r
+            <!-- H2: Unique index or primary key violation -->\r
+            <!-- https://groups.google.com/forum/?fromgroups=#!topic/h2-database/yiK7cLt2YbA -->\r
+            <property name="hibernate.id.new_generator_mappings" value="true" />\r
+        </properties>\r
+    </persistence-unit>\r
+</persistence>\r
index c9ef2c5..6f3ff97 100644 (file)
@@ -1179,7 +1179,7 @@ public abstract class AbstractSchemaMojo extends AbstractMojo
   {
     try
     {
-      File dir = new File(outputDirectory);
+      File dir = new File(path);
       if (dir.exists())
       {
         getLog().info("Adding " + dir.getAbsolutePath() + " to the list of roots to scan...");