Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Warp fills the void between client-side and server-side testing.

README.md

Arquillian Warp Build Status

Warp fills the void between client-side and server-side testing

This extension allows you to write client-side test which asserts server-side logic.

Warp has built-in support for following frameworks

  • Servlet API
  • JSF 2

and it has also several framework extensions

Documentation

Reading

Release blogs

Links

Community

Getting Started

Setting up a project

Just add impl module to classpath and run test either from IDE or maven.

<dependency>
    <groupId>org.jboss.arquillian.extension</groupId>
    <artifactId>arquillian-warp</artifactId>
    <version>1.0.0.Alpha4</version>
    <type>pom</type>
</dependency>

or any framework-specific extension:

<dependency>
    <groupId>org.jboss.arquillian.extension</groupId>
    <artifactId>arquillian-warp-jsf</artifactId>
    <version>1.0.0.Alpha4</version>
</dependency>

Use the servlet protocol in arquillian.xml configuration:

<defaultProtocol type="Servlet 3.0"/>

For more information on getting started, see documentation.

Writing Warp tests

To allow your test to use the Warp, place a @WarpTest annotation to the test class:

@RunWith(Arquillian.class)
@WarpTest
@RunAsClient
public class BasicTest {
}

Don't forget to force Arquillian to run the test on a client with a @RunAsClient annotation.

Using `Warp` to trigger the client action

You can use any HTTP client, such as WebDriver (driven by @Drone), to trigger the server logic:

@Drone
WebDriver browser;

Then use Warp utility class to run initiate method.

@Test
public void test() {

    Warp
       .initiate(new Activity() {

            public void perform() {
                browser.navigate().to(contextPath + "index.jsf");
            }})

       .inspect(new Inspection() {
            private static final long serialVersionUID = 1L;
        });
}

You need to provide Activity - the contract of this interface is that its perform method leads to triggering one or more HTTP requests against contextPath URL (injected by Arquillian).

Finally, in the inspect method, you need to provide object which implements Inspection interface. This interface provides contract for object which can execute server-side logic.

Don't forget to provide serialVersionUID for Inspection objects.

Asserting server state with `Inspection`

In the Inspection implementation, you can provide test methods annotated with lifecycle-test annotations:

  • @BeforeServlet
  • @AfterServlet
  • @BeforePhase
  • @AfterPhase

Simple assertion may look like:

new Inspection() {

    private static final long serialVersionUID = 1L;

    @Inject
    CDIBean cdiBean;

    @AfterPhase(RENDER_RESPONSE)
    public void test_initial_state() {
        assertEquals("John", cdiBean.getName());
    }
}

Note that you can use dependency injection to bring the classes such as CDI beans, EJB beans, or any other resource supported by Arquillian.

Learning from Tests

In order to explore more use cases for Warp, the best way is to explore functional tests:

Something went wrong with that request. Please try again.