<extension qualifier="seam2"> <!-- This way you can override Seam version which you have defined in pom.xml --> <property name="seamVersion">2.2.1.Final</property> </extension>
With Arquillian Seam 2 extension you can easily test your applications created with Seam 2 framework against real containers!
Following features are supported:
Test enrichment for @In injection points from the Seam 2 Context.
Packaging support for adding the Seam 2 framework (so you don't need to specify it explictly in your @Deployment method).
You can turn off autopackaging feature in arquillian.xml. See subsequent section for details.
You can customize Arquillian Seam 2 extension configuration in arquillian.xml by adding following element:
<extension qualifier="seam2"> <!-- This way you can override Seam version which you have defined in pom.xml --> <property name="seamVersion">2.2.1.Final</property> </extension>
List of all available properties
Property name |
Default value |
Description |
seamVersion |
2.2.2.Final |
Version of Seam 2 framework artifact used by autopackaging mechanism |
jbossElVersion |
1.0_02.CR5 |
Version of JBoss Expression Language extension artifact used by Seam 2 |
autoPackage |
true |
Turn on/off autopackaging feature. |
Let's consider following Seam 2 component
@Name("fluidOuncesConverter") public class FluidOuncesConverter { public Double convertToMillilitres(Double ounces) { return ounces * 29.5735296; } }
In order to test it we can write standard Arquillian-powered test:
import static org.fest.assertions.Assertions.assertThat; // fluent assertions used in the test // arquillian and seam imports @RunWith(Arquillian.class) public class ComponentInjectionTestCase { @Deployment public static Archive<?> createDeployment() { return ShrinkWrap.create(WebArchive.class, "test.war") .addClass(FluidOuncesConverter.class) .addPackages(true, "org.fest") .addAsResource(EmptyAsset.INSTANCE, "seam.properties") .setWebXML("web.xml"); } @In FluidOuncesConverter fluidOuncesConverter; @Test public void shouldInjectSeamComponent() throws Exception { assertThat(fluidOuncesConverter).isNotNull(); } @Test public void shouldConvertFluidOuncesToMillilitres() throws Exception { // given Double ouncesToConver = Double.valueOf(8.0d); Double expectedMillilitres = Double.valueOf(236.5882368d); // when Double millilitres = fluidOuncesConverter.convertToMillilitres(ouncesToConver); // then assertThat(millilitres).isEqualTo(expectedMillilitres); } }
The only extra dependency needed is arquillian-seam2, as described in the snippet below.
<dependency> <groupId>org.jboss.arquillian.extension</groupId> <artifactId>arquillian-seam2</artifactId> <version>${version.arquillian.seam2}</version> <scope>test</scope> </dependency>
Take a look at the Getting started to see how you set up arquillian using maven.
Note: You might face problems obtaining some Seam 2 dependencies. You should add these repositories to fix the problem.