Warp fills the void between client-side and server-side testing.
Java HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
api [maven-release-plugin] prepare for next development iteration Mar 11, 2014
build [maven-release-plugin] prepare for next development iteration Mar 11, 2014
extension
ftest Server assertion errors will be ignored if there is a client exception Jun 27, 2016
impl Server assertion errors will be ignored if there is a client exception Jun 27, 2016
spi [maven-release-plugin] prepare for next development iteration Mar 11, 2014
wiki
.gitignore ARQ-1261: refactored tests to common ftest-base Oct 29, 2013
NOTICE.txt added NOTICE file with the reference to the original sources Sep 21, 2015
README.md
apl.txt added maven-license-plugin check May 22, 2012
license.txt
pom.xml ARQ-2013 Update Arquillian, Drone, Resolver, JaCoCo and JUnit Mar 14, 2016
settings.xml added settings.xml for use on cloudbees Jan 20, 2014

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: