A DeployableContainer implementation that manages the complete lifecycle of an embedded (same JVM) Tomcat 7 Servlet Container. (Keep in mind that only select EE APIs are available in Tomcat 7, such as JNDI and Servlet 3.0). Test archives are adapted to Tomcat's StandardContext API by ShrinkWrap and deployed programmatically.
Container Injection Support Matrix
@Resource
|
@EJB
|
@EJB (no-interface)
|
@Inject (CDI)
|
@Inject (MC)
|
@PersistenceContext @PersistenceUnit
|
|
|
|
|
|
|
CDI support requires use of Weld Servlet and associated configuration. The WAR will have to be unpacked as well in order for Weld to locate the classes. See the following configuration example.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arquillian
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="tomcat" default="true">
<configuration>
<property name="unpackArchive">true</property>
</configuration>
</container>
</arquillian>
Configuration
Default Protocol: Servlet 3.0
Container Configuration Options
Name
|
Type
|
Default
|
Description
|
bindHttpPort
|
int
|
8080
|
The HTTP port the server should bind to.
|
bindAddress
|
String
|
localhost
|
The host the server should be run on.
|
tomcatHome
|
String
|
|
Optional location of a Tomcat installation to link against.
|
serverName
|
String
|
arquillian-tomcat-embedded-7
|
Optional name of the server
|
appBase
|
String
|
webapps
|
Optional relative or absolute path to the directory where applications are deployed (e.g., webapps).
|
workDir
|
String
|
|
Optional relative or absolute path to the directory where applications are expanded and session serialization data is stored (e.g., work).
|
unpackArchive
|
boolean
|
false
|
Specify if the deployment should be deployed exploded or compressed.
|
Example of Maven profile setup
<profile>
<id>tomcat-embedded</id>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-tomcat-embedded-7</artifactId>
<version>1.0.0.Final-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>7.0.19</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>7.0.19</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>3.7</version>
<scope>test</scope>
</dependency>
<!-- Weld servlet for testing CDI injections -->
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet</artifactId>
<version>1.1.5-Final</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>