JBoss Community Archive (Read Only)

Arquillian Old

JSFUnit

Partially out of date

See Getting Started Examples and Annotation Guide

The JSFUnit integration to Arquillian is a simpler way of using JSFUnit.

JSFUnit integration requires a Java EE 6 compliant server. The packaging is based on web-fragments from Servlet 3.0.

Code example

// imports here...
@RunWith(Arquillian.class)
public class JSFUnitTestCase
{
   @Deployment
   public static WebArchive createDeployment()
   {
      return ShrinkWrap.create(WebArchive.class ,"test.war")
                  .addClasses(
                        RequestScopeBean.class, 
                        ScopeAwareBean.class)
                  .setWebXML("jsf/jsf-web.xml")
                  .addResource("jsf/index.xhtml", "index.xhtml")
                  .addWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
   }

   @Test
   public void shouldExecutePage() throws Exception
   {
      JSFSession jsfSession = new JSFSession("/index.jsf");
      
      Assert.assertTrue(Environment.is12Compatible());
      Assert.assertTrue(Environment.is20Compatible());
      Assert.assertEquals(2, Environment.getJSFMajorVersion());
      Assert.assertEquals(0, Environment.getJSFMinorVersion());

      JSFServerSession server = jsfSession.getJSFServerSession();
      
      Assert.assertEquals("request", server.getManagedBeanValue("#{requestBean.scope}"));
   }
}

Maven setup exampleThe only dependencies needed is to add org.jboss.arquillian.framework:arquillian-framework-jsfunit and org.jboss.jsfunit:jboss-jsfunit-core to your pom.xml. The rest is handled by Arquillian in the background. Take a look at the Getting started to see how you set up arquillian using maven.

<dependency>
   <groupId>org.jboss.arquillian.framework</groupId>
   <artifactId>arquillian-framework-jsfunit</artifactId>
   <version>1.0.0-SNAPSHOT</version>
   <scope>test</scope>
</dependency>
<dependency>
   <groupId>org.jboss.jsfunit</groupId>
   <artifactId>jboss-jsfunit-core</artifactId>
   <version>1.3.0.Final</version>
   <scope>test</scope>
</dependency>

To use JSFUnit with Arquillian, JSFUnit 1.3.0.Final is required.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-10 12:19:01 UTC, last content change 2011-04-16 15:47:17 UTC.