How to setup Arquillian testing with Wildfly

This tutorial requires:

  • Knowledge with GIT
  • Knowledge with archetype
Requirements:
  • Wildfly
  • eclipse
What to do:
  1. In eclipse create a new maven project: File->New->Other, enter maven in the filter. Select Maven Project.
  2. Click next, then next. In the filter enter "javaee". Select wildfly-javaee7-webapp-archetype.
  3. Click next, enter group and artifact id.
  4. Click finish. Your project should be created.
  5. Open arquillian.xml in src/test/resources. Uncomment configuration section and set the jbossHome property:
    <?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">
    
     <!-- Force the use of the Servlet 3.0 protocol with all containers, as it 
      is the most mature -->
     <defaultProtocol type="Servlet 3.0" />
    
     <!-- Example configuration for a remote WildFly instance -->
     <container qualifier="wildfly" default="true">
      <!-- By default, arquillian will use the JBOSS_HOME environment variable. 
       Alternatively, the configuration below can be uncommented. -->
      <configuration>
       <property name="jbossHome">C:\java\jboss\wildfly-10.1.0.Final</property>
    <!--    <property name="javaVmArguments">-Xmx512m -XX:MaxPermSize=128m -->
    <!--                 -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y -->
    <!--             </property> -->
      </configuration>
     </container>
    
     <engine>
      <property name="deploymentExportPath">target/deployments</property>
     </engine>
    
    </arquillian>
    
  6. Then in your terminal, go to your project directory and run:
    >mvn clean test -Parq-wildfly-managed
    >This run arquillian test using wildfly managed container.
It's actually a straightforward process. The tricky part is creating your test war. Open MemberRegistrationTest, to see what I mean. Sometimes it's useful to include an archive with all its dependencies than including one class at a time.
How to setup Arquillian testing with Wildfly How to setup Arquillian testing with Wildfly Reviewed by Edward Legaspi on Sunday, April 16, 2017 Rating: 5

No comments:

Powered by Blogger.