0 Replies Latest reply on Aug 16, 2015 8:06 PM by bluelabel

    Wildfly 8.2.0 + Arquillian

    bluelabel

      Recently, we moved from Glassfish 4.0 to Wildfly 8.2.0. With GF however, our integration tests worked without any issues. But when we try to use Arquillian with embedded wildfly 8.2.0 so many issues occurred and iam not sure how to solve them.

      I ll start with my pom

       

      <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>com.abc</groupId>
          <artifactId>pos-domain</artifactId>
          <version>2.1.0.52-SNAPSHOT</version>
          <packaging>ejb</packaging>
          <name>pos-domain</name>
        <!-- parent project-->
          <parent>
              <groupId>com.abc</groupId>
              <artifactId>pos</artifactId>
              <version>2.1.0.52-SNAPSHOT</version>
          </parent>
        <properties>
              <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
              <hibernate.version>4.3.5.Final</hibernate.version>
              <querydsl.version>3.6.0</querydsl.version>
              <shiro.version>1.2.1</shiro.version>
              <jasperReports.version>6.1.0</jasperReports.version>
          </properties>
      
      
          <dependencyManagement>
              <dependencies>
                  <!-- Import of arquillian dependencies -->
                  <dependency>
                      <groupId>org.jboss.arquillian</groupId>
                      <artifactId>arquillian-bom</artifactId>
                      <version>1.0.3.Final</version>
                      <scope>import</scope>
                      <type>pom</type>
                  </dependency>
                  <!-- Override version of transient dependency for test execution.
                  Weld requires slf4j version 1.5.1 while POS application uses 1.6 -->
                  <dependency>
                      <groupId>org.slf4j</groupId>
                      <artifactId>slf4j-api</artifactId>
                      <version>1.5.10</version>
                      <scope>test</scope>
                  </dependency>
              </dependencies>
          </dependencyManagement>
          <dependencies>
              <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>4.10</version>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.jboss.arquillian.junit</groupId>
                  <artifactId>arquillian-junit-container</artifactId>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.jboss.shrinkwrap.resolver</groupId>
                  <artifactId>shrinkwrap-resolver-depchain</artifactId>
                  <scope>test</scope>
                  <version>2.1.1</version>
                  <type>pom</type>
                  <exclusions>
                      <exclusion>
                          <!-- Shrinkwrap still using deprecated google collections which is
                          causing conflict with mysema's google guava dependency-->
                          <groupId>com.google.collections</groupId>
                          <artifactId>google-collections</artifactId>
                      </exclusion>
                  </exclusions>
              </dependency>
              <dependency>
                  <groupId>org.quartz-scheduler</groupId>
                  <artifactId>quartz</artifactId>
                  <version>2.1.7</version>
              </dependency>
              <!-- Hiberante provider -->
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-entitymanager</artifactId>
                  <version>${hibernate.version}</version>
              </dependency>
              <!-- L2 hibernate cache -->
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-ehcache</artifactId>
                  <version>${hibernate.version}</version>
              </dependency>
              <dependency>
                  <groupId>org.hibernate.javax.persistence</groupId>
                  <artifactId>hibernate-jpa-2.1-api</artifactId>
                  <version>1.0.0.Final</version>
              </dependency>
              <!-- Hibernate core does not required for the application to work,
                  but contains some Hibernate exception classes which are good
                  to have to get proper stack trace if some exception happened
              -->
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-core</artifactId>
                  <version>${hibernate.version}</version>
              </dependency>
              <dependency>
                  <groupId>javax</groupId>
                  <artifactId>javaee-api</artifactId>
                  <version>7.0</version>
                  <scope>provided</scope>
              </dependency>
            <!-- Mockito mock framework -->
              <dependency>
                  <groupId>org.mockito</groupId>
                  <artifactId>mockito-all</artifactId>
                  <version>1.8.4</version>
                  <type>jar</type>
              </dependency>
            <dependency>
                  <groupId>org.apache.commons</groupId>
                  <artifactId>commons-lang3</artifactId>
                  <version>3.1</version>
              </dependency>
              <dependency>
                  <groupId>org.apache.commons</groupId>
                  <artifactId>commons-math3</artifactId>
                  <version>3.1.1</version>
              </dependency>
            <!-- Shiro security framework -->
              <dependency>
                  <groupId>org.apache.shiro</groupId>
                  <artifactId>shiro-core</artifactId>
                  <version>${shiro.version}</version>
              </dependency>
              <dependency>
                  <groupId>org.apache.shiro</groupId>
                  <artifactId>shiro-web</artifactId>
                  <version>${shiro.version}</version>
              </dependency>
              <dependency>
                  <groupId>commons-beanutils</groupId>
                  <artifactId>commons-beanutils</artifactId>
                  <version>1.8.3</version>
              </dependency>
              <!--  Shiro uses ehcache as a cache manager, see shiro.ini -->
              <dependency>
                  <groupId>org.apache.shiro</groupId>
                  <artifactId>shiro-ehcache</artifactId>
                  <version>1.1.0</version>
              </dependency>
            <!-- apache mail -->
              <dependency>
                  <groupId>org.apache.commons</groupId>
                  <artifactId>commons-email</artifactId>
                  <version>1.3.1</version>
              </dependency>
            <!-- Apache common codec for base64 encoding -->
              <dependency>
                  <groupId>commons-codec</groupId>
                  <artifactId>commons-codec</artifactId>
                  <version>1.7</version>
              </dependency>
            <!--QueryDSL query engine for the JPA -->
              <dependency>
                  <groupId>com.mysema.querydsl</groupId>
                  <artifactId>querydsl-apt</artifactId>
                  <version>${querydsl.version}</version>
              </dependency>
            <dependency>
                  <groupId>com.mysema.querydsl</groupId>
                  <artifactId>querydsl-jpa</artifactId>
                  <version>${querydsl.version}</version>
              </dependency>
              <!-- POS API -->
              <dependency>
                  <groupId>com.abc</groupId>
                  <artifactId>pos-api</artifactId>
                  <version>1.13.0.50</version>
              </dependency>
              <!-- POS Margin analysis module -->
              <dependency>
                  <groupId>com.abc</groupId>
                  <artifactId>pos-mam</artifactId>
                  <version>2.1.0.52-SNAPSHOT</version>
              </dependency>
              <!-- Jasper Reports -->
              <dependency>
                  <groupId>net.sf.jasperreports</groupId>
                  <artifactId>jasperreports</artifactId>
                  <version>${jasperReports.version}</version>
                  <exclusions>
                      <exclusion>
                          <!-- Since Jasper version 6.1.0, a castor-xml library dependency was added to able customized chart themes using Spring framework.
                          As a result, many Spring libraries were added to our WAR file. Thus, the code below avoids such libraries to be added. -->
                          <groupId>org.codehaus.castor</groupId>
                          <artifactId>castor-xml</artifactId>
                      </exclusion>
                  </exclusions>
              </dependency>
              <!-- for using groovy as script language inside jasper reports -->
              <dependency>
                  <groupId>org.codehaus.groovy</groupId>
                  <artifactId>groovy-all</artifactId>
                  <version>2.0.1</version>
              </dependency>
              <!--  dependencies for business rule engine -->
              <dependency>
                  <groupId>org.drools</groupId>
                  <artifactId>drools-core</artifactId>
                  <version>5.5.0.Final</version>
              </dependency>
              <dependency>
                  <groupId>org.drools</groupId>
                  <artifactId>drools-compiler</artifactId>
                  <version>5.5.0.Final</version>
              </dependency>
              <dependency>
                  <groupId>org.codehaus.janino</groupId>
                  <artifactId>janino</artifactId>
                  <version>2.5.16</version>
              </dependency>
              <dependency>
                  <groupId>net.sf.opencsv</groupId>
                  <artifactId>opencsv</artifactId>
                  <version>2.3</version>
              </dependency>
              <!-- joda time hibernate maping -->
              <dependency>
                  <groupId>org.jadira.usertype</groupId>
                  <artifactId>usertype.core</artifactId>
                  <version>Torqueits-3.2.0.GA</version>
              </dependency>
              <!-- dependencies for deltaspike which is used to control CDI context -->
              <dependency>
                  <groupId>org.apache.deltaspike.cdictrl</groupId>
                  <artifactId>deltaspike-cdictrl-api</artifactId>
                  <version>0.5</version>
              </dependency>
              <dependency>
                  <groupId>org.apache.deltaspike.cdictrl</groupId>
                  <artifactId>deltaspike-cdictrl-weld</artifactId>
                  <version>0.5</version>
              </dependency>
              <dependency>
                  <groupId>org.apache.deltaspike.core</groupId>
                  <artifactId>deltaspike-core-api</artifactId>
                  <version>0.5</version>
              </dependency>
              <dependency>
                  <groupId>org.apache.deltaspike.core</groupId>
                  <artifactId>deltaspike-core-impl</artifactId>
                  <version>0.5</version>
              </dependency>
              <!-- Library for Scaling Images-->
              <dependency>
                  <groupId>com.mortennobel</groupId>
                  <artifactId>java-image-scaling</artifactId>
                  <version>0.8.5</version>
              </dependency>
              <!-- Bean Validation provider -->
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-validator</artifactId>
                  <version>5.0.0.Final</version>
                  <scope>test</scope>
              </dependency>
              <!-- Apache commons-io (Example of usage: FilenameUtils.getExtension()) -->
              <dependency>
                  <groupId>commons-io</groupId>
                  <artifactId>commons-io</artifactId>
                  <version>2.4</version>
              </dependency>
              <dependency>
                  <groupId>com.github.rmannibucau</groupId>
                  <artifactId>arquillian-extension-shiro</artifactId>
                  <version>1.0.2</version>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>com.abc</groupId>
                  <artifactId>pos-update</artifactId>
                  <version>${project.version}</version>
                  <scope>test</scope>
              </dependency>
          </dependencies>
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <version>2.3.2</version>
                      <configuration>
                          <source>1.8</source>
                          <target>1.8</target>
                          <compilerArguments>
                              <endorseddirs>${endorsed.dir}</endorseddirs>
                          </compilerArguments>
                      </configuration>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-ejb-plugin</artifactId>
                      <version>2.3</version>
                      <configuration>
                          <ejbVersion>3.1</ejbVersion>
                          <archive>
                              <!-- Put the maven version and build number into the manifest -->
                              <manifest>
                                  <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                  <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                              </manifest>
                              <manifestEntries>
                                  <Implementation-Build>${build.number}</Implementation-Build>
                                  <!-- Used to know that it is a POS component in the About page -->
                                  <POS-Component>true</POS-Component>
                              </manifestEntries>
                          </archive>
                      </configuration>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-dependency-plugin</artifactId>
                      <version>2.1</version>
                      <executions>
                          <execution>
                              <phase>validate</phase>
                              <goals>
                                  <goal>copy</goal>
                              </goals>
                              <configuration>
                                <outputDirectory>${endorsed.dir}</outputDirectory>
                                  <silent>true</silent>
                                  <artifactItems>
                                      <artifactItem>
                                          <groupId>javax</groupId>
                                          <artifactId>javaee-endorsed-api</artifactId>
                                          <version>6.0</version>
                                          <type>jar</type>
                                      </artifactItem>
                                  </artifactItems>
                              </configuration>
                          </execution>
                      </executions>
                  </plugin>
                  <plugin>
                      <groupId>com.mysema.maven</groupId>
                      <artifactId>maven-apt-plugin</artifactId>
                      <version>0.3.2</version>
                      <executions>
                          <execution>
                              <goals>
                                  <goal>process</goal>
                              </goals>
                              <configuration>
                                  <outputDirectory>target/generated-sources/java</outputDirectory>
                                  <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                              </configuration>
                          </execution>
                      </executions>
                  </plugin>
                  <plugin>
                      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>versions-maven-plugin</artifactId>
                      <version>2.1</version>
                  </plugin>
                  <plugin>
                      <artifactId>maven-scm-plugin</artifactId>
                      <version>1.9</version>
                      <configuration>
                          <tag>${project.artifactId}-${project.version}</tag>
                      </configuration>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-release-plugin</artifactId>
                      <version>2.4.2</version>
                      <configuration>
                          <autoVersionSubmodules>true</autoVersionSubmodules>
                          <suppressCommitBeforeBranch>true</suppressCommitBeforeBranch>
                          <remoteTagging>false</remoteTagging>
                          <updateBranchVersions>true</updateBranchVersions>
                          <updateWorkingCopyVersions>true</updateWorkingCopyVersions>
                      </configuration>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-javadoc-plugin</artifactId>
                      <version>2.9.1</version>
                      <configuration>
                          <failOnError>false</failOnError>
                      </configuration>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <version>2.18</version>
                      <configuration>
                          <excludes>
                              <!--Exclude integration tests-->
                              <exclude>*TestIT.java</exclude>
                          </excludes>
                          <!--  class path exclusion added to allow execute individual integration tests in the same way as normal unit tests. This makes easier to handle integration tests in Netbeans -->
                          <classpathDependencyExcludes>
                              <!-- implementation of core-api from deltaspike conflicting with implementation from arquillian as it also based on deltaspike-->
                              <classpathDependencyExclude>org.apache.deltaspike.core:deltaspike-core-impl</classpathDependencyExclude>
                          </classpathDependencyExcludes>
                          <!--  Add an internal Glassfish dependency (com.sun.xml.bind:jaxb-osgi) as
                          an endorsed directory. This will ensure that validation.xml is parsed by Hibernate Validator. -->
                          <argLine>-Djava.endorsed.dirs=${settings.localRepository}/com/sun/xml/bind/jaxb-osgi/2.2.4/</argLine>
                      </configuration>
                      <dependencies>
                          <dependency>
                              <groupId>com.sun.xml.bind</groupId>
                              <artifactId>jaxb-osgi</artifactId>
                              <version>2.2.4</version>
                          </dependency>
                      </dependencies>
                  </plugin>
            </plugins>
          </build>
          <profiles>
              <!--default profile-->
              <profile>
                  <id>default</id>
                  <activation>
                      <activeByDefault>true</activeByDefault>
                  </activation>
                  <dependencies>
                      <dependency>
                          <!-- force maven to use version 1.6.1 when executing with default profile -->
                          <groupId>org.slf4j</groupId>
                          <artifactId>slf4j-api</artifactId>
                          <version>1.6.1</version>
                          <scope>provided</scope>
                      </dependency>
                  </dependencies>
            </profile>
              <!--Integration test profile-->
              <!-- Integration tests executed only for this profile. To enable this profile add '-Pintegration-tests' string to the maven command -->
              <profile>
                  <id>integration-tests</id>
                  <activation>
                      <activeByDefault>false</activeByDefault>
                  </activation>
                  <dependencies>
                      <dependency>
                          <groupId>com.google.guava</groupId>
                          <artifactId>guava</artifactId>
                          <version>13.0-final</version>
                          <scope>test</scope>
                      </dependency>
                      <dependency>
                          <groupId>org.wildfly.arquillian</groupId>
                          <artifactId>wildfly-arquillian-container-embedded</artifactId>
                          <version>1.0.0.Final</version>
                          <scope>test</scope>
                      </dependency>
                      <dependency>
                          <groupId>org.wildfly</groupId>
                          <artifactId>wildfly-embedded</artifactId>
                          <version>8.2.0.Final</version>
                      </dependency>
                      <dependency>
                          <groupId>com.microsoft.sqlserver</groupId>
                          <artifactId>sqljdbc4</artifactId>
                          <version>4.0</version>
                          <scope>test</scope>
                      </dependency>          
                  </dependencies>
                  <build>
                      <plugins>
                          <plugin>
                              <artifactId>maven-dependency-plugin</artifactId>
                              <executions>
                                  <execution>
                                      <id>unpack</id>
                                      <phase>process-test-classes</phase>
                                      <goals>
                                          <goal>unpack</goal>
                                      </goals>
                                      <configuration>
                                          <artifactItems>
                                              <artifactItem>
                                                  <groupId>org.wildfly</groupId>
                                                  <artifactId>wildfly-dist</artifactId>
                                                  <version>8.2.0.Final</version>
                                                  <type>zip</type>
                                                  <overWrite>false</overWrite>
                                                  <outputDirectory>target</outputDirectory>
                                              </artifactItem>
                                          </artifactItems>
                                      </configuration>
                                  </execution>
                              </executions>
                          </plugin>                                
                          <plugin>
                              <artifactId>maven-surefire-plugin</artifactId>
                              <version>2.18</version>
                              <configuration>
                                  <skip>false</skip>
                                  <includes>
                                      <include>**/*.java</include>
                                  </includes>
                                  <classpathDependencyExcludes>
                                      <!-- implementation of core-api from deltaspike conflicting with implementation from arquillian as it also based on deltaspike-->
                                      <classpathDependencyExclude>org.apache.deltaspike.core:deltaspike-core-impl</classpathDependencyExclude>
                                  </classpathDependencyExcludes>                    
                                  <systemPropertyVariables>
                                      <!-- you can use different resource file, you will need to override resourcesXml parameter value
                                      like:  -DresourcesXml=d:\glassfish-resources.xml
                                      -->
                                      <resourcesXml>src/test/resources/wildfly-resources.xml</resourcesXml>
                                  </systemPropertyVariables>
                              </configuration>
                              <dependencies>
                                  <dependency>
                                      <groupId>com.sun.xml.bind</groupId>
                                      <artifactId>jaxb-osgi</artifactId>
                                      <version>2.2.4</version>
                                  </dependency>
                              </dependencies>
                          </plugin>
                      </plugins>
                  </build>
              </profile>
          </profiles>
          <description>The point of sale application, domain logic</description>
      </project>
      
      
      
      
      

       

      arquillian.xml - Stays in test package

      <?xml version="1.0" encoding="UTF-8"?>
      <arquillian xmlns="http://jboss.org/schema/arquillian"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
      
          <container qualifier="wildfly" default="true">
              <configuration>
                  <property name="bindHttpPort">7070</property>
                  <!-- resource file variable configured inside pom.xml file -->
                  <property name="resourcesXml">${resourcesXml}</property>
                  <property name="jbossHome">C:\wildfly-8.2.0.Final</property>
                  <property name="modulePath">C:\wildfly-8.2.0.Final\modules</property>
              </configuration>
          </container>
      </arquillian>
      
      
      
      
      

       

      test-persistence.xml - Stays in test package

      <?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="pos_PU" transaction-type="JTA">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
              <jta-data-source>jdbc/pos_test_arquillian</jta-data-source>
              <exclude-unlisted-classes>false</exclude-unlisted-classes>
              <properties>
                  <property name="hibernate.enable_lazy_load_no_trans" value="true"/>
                  <!-- We should add the show_sql property to the local profile to load it dynamically, but for now we set it to
                  false for performance reasons -->
                  <property name="hibernate.show_sql" value="false"/>
                  <!-- Upgrade to hiberante 4.*, hibernate.transaction.manager_lookup_class is depricated and needs to be repalced
                  with hibernate.transaction.jta.platform. For the glassfish server the default implementation is SunOneJtaPlatform -->
                  <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServer2008Dialect"/>
                  <property name="hibernate.transaction.jta.platform" value="rg.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform"/>
                  <!-- enabling L2 cache -->
                  <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/>
                  <property name="hibernate.generate_statistics" value ="true" />
                  <property name="hibernate.cache.use_second_level_cache" value="true"/>
                  <property name="hibernate.cache.use_query_cache" value="false"/>
                  <!-- global settings for the database and jvm timezone, used in conjuction with joda datetime. Following will set JVM and database timezones to UTC -->
                  <property name="jadira.usertype.databaseZone" value="UTC"/>
                  <property name="jadira.usertype.javaZone" value="UTC"/>
                  <!-- This will force global mapping for all user types provided by jadira library including mapping for org.joda.time.DateTime and org.joda.time.LocalDate -->
                  <property name="jadira.usertype.autoRegisterUserTypes" value="true"/>
              </properties>
          </persistence-unit>
      </persistence>
      
      

       

      Data source (wildfly-resources.xml)

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN"
          "http://www.sun.com/software/appserver/dtds/sun-resources_1_4.dtd">
      <resources>
          <jdbc-resource pool-name="ArquillianSqlServerPool"
                         jndi-name="jdbc/pos_test_arquillian"/>
          <jdbc-connection-pool datasource-classname="com.microsoft.sqlserver.jdbc.SQLServerDataSource" name="ArquillianSqlServerPool" res-type="javax.sql.DataSource">
                  <property name="ApplicationName" value="Microsoft JDBC Driver for SQL Server"></property>
                  <property name="LoginTimeout" value="15"></property>
                  <property name="PortNumber" value="1433"></property>
                  <property name="url" value="jdbc:sqlserver://localhost;database=test"></property>
                  <property name="User" value="posuser"></property>
                  <property name="Password" value="test"></property>
          </jdbc-connection-pool>
      </resources>
      
      

       

      Abstract test class: AbstractintegrationTest

      import com.torqueits.pos.database.DatabaseUpdateManager;
      import javax.annotation.Resource;
      import javax.sql.DataSource;
      import org.jboss.arquillian.container.test.api.Deployment;
      import org.jboss.arquillian.container.test.api.OverProtocol;
      import org.jboss.arquillian.junit.Arquillian;
      import org.jboss.shrinkwrap.api.ShrinkWrap;
      import org.jboss.shrinkwrap.api.asset.EmptyAsset;
      import org.jboss.shrinkwrap.api.spec.JavaArchive;
      import org.junit.Before;
      import org.junit.runner.RunWith;
      /**
      * Base class for integration tests
      *
      */
      @RunWith(Arquillian.class)
      public abstract class AbstractIntegrationTest {
          /**
           * Inject datasource
           */
          @Resource(lookup = "jdbc/pos_test_arquillian")
          protected DataSource dataSource;
          /**
           * Flag to indicate whether the database is reset. This is a global
           * parameter and will be set to true after db reset first time.
           */
          private static boolean databaseReset;
          /**
           * Prepare archive to run container
           *
           * @return
           */
          @Deployment
          @OverProtocol("Servlet 3.0")
          public static JavaArchive createTestArchive() {
              JavaArchive jar = ShrinkWrap
                      .create(JavaArchive.class, "test.jar")
                      .addPackages(true, "com.abc.pos")
                      .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
                      .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
              return jar;
          }
      
          /**
           * Check database state, when executing very first time in test suite
           * execution, will reset db
           *
           * @throws Exception
           */
          @Before
          public void preparePersistenceTest() throws Exception {
              if (!databaseReset) {
                  DatabaseUpdateManager manager = new DatabaseUpdateManager();
                  manager.clean(this.dataSource);
                  manager.checkAndUpdate(this.dataSource);
                  databaseReset = true;
              }
          }
      }
      
      

       

      Actual test class:

      public class ApplicationUserManagerTestIT extends AbstractIntegrationTest {
      
      
          /**
           * User manager
           */
          @Inject
          private ApplicationUserManager applicationUserManager;
          /**
           * Default user existing in the database
           */
          private ApplicationUserEntity adminUser;
          /**
           * Business partner manager
           */
          @Inject
          private BusinessPartnerManager businessPartnerManager;
          /**
           * Authorization manager
           */
          @Inject
          protected AuthorizationManager authorizationManager;
      
          /**
           * Constant for test email address
           */
          private static final String TEST_EMAIL = "email@email.test";
      
      
          /**
           * Clean and restore database
           *
           * @throws Exception
           */
          @Before
          public void prepare() throws Exception {
              super.preparePersistenceTest();
              this.adminUser = this.applicationUserManager.findById(1L);
              /* Workaround to mock user and permission check */
              Subject subject = Mockito.mock(Subject.class);
              PrincipalCollection principals = Mockito.mock(PrincipalCollection.class);
              Session session = Mockito.mock(Session.class);
              Mockito.when(subject.getPrincipals()).thenReturn(principals);
              Mockito.when(principals.getPrimaryPrincipal()).thenReturn(this.adminUser);
              Mockito.when(subject.getSession()).thenReturn(session);
              Mockito.when(session.getId()).thenReturn(0L);
              this.authorizationManager.setSubject(subject);
          }
      
          /**
           * Test of applicationUserManager#save method
           */
          @Test
          @LoggedWithSubject(value = "user", roles = "*")
          @InSequence(1)
          public void testCreateApplicationUser() {
              /* default admin user which already exist in db */
              ApplicationUserEntity user = this.createUser("ArquillianUserTest");
              ContactInformationEntity defaultEmail = this.businessPartnerManager.createDefaultEmail(user.getBusinessPartner());
              defaultEmail.setContactDetails(TEST_EMAIL);
              this.applicationUserManager.save(user);
              /* check that user, active version and business partner created in the database */
              Assert.assertNotNull(user.getId());
              Assert.assertNotNull(user.getActiveVersion().getId());
              Assert.assertNotNull(user.getBusinessPartner().getId());
          }
      
      
          /**
           * Creates a new user instance
           *
           * @param name
           * @return
           */
          private ApplicationUserEntity createUser(String name) {
              ApplicationUserEntity user = new ApplicationUserEntity();
              ApplicationUserVersion userVersion = new ApplicationUserVersion();
              userVersion.getVersionInfo().setCreatedBy(this.adminUser);
              userVersion.getVersionInfo().setCreatedDate(DateTimeUtils.getCurrentDateTime());
              userVersion.setActive(true);
              user.setLogin(name);
              user.setLocked(Boolean.FALSE);
              user.setAuthenticationMethod(AuthenticationMethod.DATABASE);
              user.setActiveVersion(userVersion);
              return user;
          }
      }
      
      

       

      When i run the test, following error shows in the console,

       

      WFLYEMB0014: Cannot load module org.wildfly.embedded from: local module loader @353d0772 (finder: local module finder @2667f029 (roots: C:\wildfly-8.2.0.Final\modules,C:\wildfly-8.2.0.Final\modules\system\layers\base))
      java.lang.RuntimeException
        at org.wildfly.core.embedded.EmbeddedServerFactory.create(EmbeddedServerFactory.java:152)
        at org.wildfly.core.embedded.EmbeddedServerFactory.create(EmbeddedServerFactory.java:117)
        at org.wildfly.core.embedded.EmbeddedServerFactory.create(EmbeddedServerFactory.java:89)
        at org.jboss.as.arquillian.container.embedded.EmbeddedDeployableContainer.setup(EmbeddedDeployableContainer.java:47)
        at org.jboss.as.arquillian.container.embedded.EmbeddedDeployableContainer.setup(EmbeddedDeployableContainer.java:34)
        at org.jboss.arquillian.container.impl.ContainerImpl.setup(ContainerImpl.java:181)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$7.perform(ContainerLifecycleController.java:149)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$7.perform(ContainerLifecycleController.java:145)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forContainer(ContainerLifecycleController.java:255)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.setupContainer(ContainerLifecycleController.java:144)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
        at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:57)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
        at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$1.perform(ContainerLifecycleController.java:62)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$1.perform(ContainerLifecycleController.java:55)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forEachContainer(ContainerLifecycleController.java:209)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.setupContainers(ContainerLifecycleController.java:54)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
        at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
        at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:85)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
        at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
        at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeSuite(EventTestRunnerAdaptor.java:68)
        at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:97)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
      Caused by: org.jboss.modules.ModuleNotFoundException: org.wildfly.embedded:main
        at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:240)
        at org.wildfly.core.embedded.EmbeddedServerFactory.create(EmbeddedServerFactory.java:150)
        at org.wildfly.core.embedded.EmbeddedServerFactory.create(EmbeddedServerFactory.java:117)
        at org.wildfly.core.embedded.EmbeddedServerFactory.create(EmbeddedServerFactory.java:89)
        at org.jboss.as.arquillian.container.embedded.EmbeddedDeployableContainer.setup(EmbeddedDeployableContainer.java:47)
        at org.jboss.as.arquillian.container.embedded.EmbeddedDeployableContainer.setup(EmbeddedDeployableContainer.java:34)
        at org.jboss.arquillian.container.impl.ContainerImpl.setup(ContainerImpl.java:181)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$7.perform(ContainerLifecycleController.java:149)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$7.perform(ContainerLifecycleController.java:145)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forContainer(ContainerLifecycleController.java:255)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.setupContainer(ContainerLifecycleController.java:144)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
        at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:57)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
        at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$1.perform(ContainerLifecycleController.java:62)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$1.perform(ContainerLifecycleController.java:55)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forEachContainer(ContainerLifecycleController.java:209)
        at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.setupContainers(ContainerLifecycleController.java:54)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
        at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
        at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:85)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
        at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
        at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeSuite(EventTestRunnerAdaptor.java:68)
        at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:97)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
      
      

       

      What have i done wrong?