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
- Spring MVC
Alpha
- led by Jakub Narloch - REST
Proof of Concept
- led by Jakub Narloch - SeamTest migration layer
Proof of Concept
- led by Marek Schmidt
- Chat: #jbosstesting channel @ irc.freenode.net
- Blogs
- Forums
- Roadmap
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.Alpha3</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.Alpha3</version>
</dependency>
Use the servlet protocol in arquillian.xml
configuration:
<defaultProtocol type="Servlet 3.0"/>
For more information on getting started, see documentation.
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.
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.
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.
In order to explore more use cases for Warp, the best way is to explore functional tests: