Arquillian provides a easy mechanism to test your application code inside a remote or embedded container or by interacting as a client of the container.
The mission of the Arquillian project is to provide a simple test harness that developers can use to produce a broad range of integration tests for their Java applications (most likely enterprise applications). A test case may be executed within the container, deployed alongside the code under test, or by coordinating with the container, acting as a client to the deployed code.
Arquillian defines two styles of container, remote and embedded. A remote container resides in a separate JVM from the test runner. Its lifecycle may be managed by Arquillian, or Arquillian may bind to a container that is already started. An embedded container resides in the same JVM and is mostly likely managed by Arquillian. Containers can be further classified by their capabilities. Examples include a fully compliant Java EE application server (e.g., GlassFish, JBoss AS, Embedded GlassFish), a Servlet container (e.g., Tomcat, Jetty) and a bean container (e.g., Weld SE). Arquillian ensures that the container used for testing is pluggable, so the developer is not locked into a proprietary testing environment.
Arquillian seeks to minimize the burden on the developer to carry out integration testing by handling all aspects of test execution, including:
To avoid introducing unnecessary complexity into the developer's build environment, Arquillian integrates transparently with familiar testing frameworks (e.g., JUnit 4, TestNG 5), allowing tests to be launched using existing IDE, Ant and Maven test plugins without any add-ons.
Arquillian makes integration testing a breeze.
| Anonymous SCM | http://anonsvn.jboss.org/repos/common/arquillian/trunk |
| Committer SCM | https://svn.jboss.org/repos/common/arquillian/trunk |
| Issue Tracking | https://jira.jboss.org/jira/browse/ARQ |
| Reference Guide | http://docs.jboss.org/arquillian/reference/1.0.0.Alpha1/en-US/ |
| Demo documentation | |
| User Forums | Arquillian Space |
| Development Forums | Arquillian Development Space |
| FAQ | |
| Project Lead | Pete Muir |
| Contributors | Aslak Knutsen, Dan Allen, Steven Boscarine, Andrew Rubinger |
| IRC | #jbosstesting on irc.freenode.net |
| Module Name | Maven2 ID | Status |
|---|---|---|
| api | org.jboss.arquillian:arquillian-api | Development In Use |
| build | org.jboss.arquillian:arquillian-build | Development In Use |
| impl-base | org.jboss.arquillian:arquillian-impl-base | Development In Use |
| spi | org.jboss.arquillian:arquillian-spi | Development In Use |
| packager-javaee | org.jboss.arquillian.packager:arquillian-packager-javaee | Development In Use |
| packager-applicationarchive | org.jboss.arquillian.packager:arquillian-packager-applicationarchive | Development In Use |
| testenricher-ejb | org.jboss.arquillian.testenricher:arquillian-testenricher-ejb | Development In Use |
| testenricher-resource | org.jboss.arquillian.testenricher:arquillian-testenricher-resource | Development In Use |
| testenricher-cdi | org.jboss.arquillian.testenricher:arquillian-testenricher-cdi | Development In Use |
| protocol-servlet | org.jboss.arquillian.protocol:arquillian-protocol-servlet | Development In Use |
| protocol-local | org.jboss.arquillian.protocol:arquillian-protocol-local | Development In Use |
| jbossas-embedded-60 | org.jboss.arquillian.container:arquillian-jbossas-embedded-60 | Development In Use |
| jbossas-remote-51 | org.jboss.arquillian.contianer:arquillian-jboss-remote-51 | Development In Use |
| jbossas-remote-60 | org.jboss.arquillian.container:arquillian-jboss-remote-60 | Development In Use |
| weld-embedded | org.jboss.arquillian.container:arquillian-weld-embedded | Development In Use |
| glassfish-embedded-30 | org.jboss.arquillian.container:arquillian-glassfish-embedded-30 | Development In Use |
| openejb | org.jboss.arquillian.container:arquillian-openejb | Development In Use |
| junit | org.jboss.arquillian:arquillian-junit | Development In Use |
| testng | org.jboss.arquillian:arquillian-testng | Development In Use |
| example-junit | org.jboss.arquillian.example:arquillian-example-junit | Development In Use |
| example-testng | org.jboss.arquillian.example:arquillian-example-testng | Development In Use |
| example-domain | org.jboss.arquillian.example:arquillian-example-domain | Development In Use |
| 0.1.x | Retired | Prototyping and Development Series |
| 1.0.0.AlphaX | In Process | Early-access Release Series used primarily for testing integration and gathering community input |
| 1.0.0.BetaX | Short-term | Candidate for Frozen APIs, major features are complete |
| 1.0.0.CRX | Short-term | Release Candidates; APIs stable except for bug fixes |
| 1.0.0.Final | Future | Promoted from re-tag of a release candidate; Stable |
| 1.0.x.Final | Future | Incremental Patch Releases; no API changes, backwards-compatible |
| 1.x.y.Final | Unscheduled | New feature; backwards-compatibility preserved |
| 2.0.0.AlphaX | Unscheduled | Overhaul, refactoring. Features may be added/dropped, API contract disappears |
Test a EJB in container using JUnit
package com.acme.ejb;
import javax.ejb.EJB;
import junit.framework.Assert;
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
public class GreetingManagerTest
{
@Deployment
public static JavaArchive createDeployment() {
return Archives.create("test.jar", JavaArchive.class)
.addClasses(
GreetingManager.class,
GreetingManagerBean.class);
}
@EJB
private GreetingManager greetingManager;
@Test
public void shouldGreetUser() throws Exception {
String userName = "Devoxx";
Assert.assertEquals(
"Hello " + userName,
greetingManager.greet(userName));
}
}
Maven Dependencies
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-junit</artifactId>
<version>${version.org.jboss.arquillian_arquillian}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-jbossas-remote-60</artifactId>
<version>${version.org.jboss.arquillian_arquillian}</version>
</dependency>
</dependencies>
There are no comments on this article