Java Reference
In-Depth Information
Warp.initiate(new Activity() {
@Override
public void perform() {
final String response = target
.request(MediaType.APPLICATION_JSON_TYPE)
.get(String.class); // [2]
assertNotNull(response); // [3]
}
}).inspect(new Inspection() {
private static final long serialVersionUID = 1L;
@ArquillianResource
private RestContext restContext;
@AfterServlet
public void testGetSeats() {
assertEquals(200,
restContext.getHttpResponse().getStatusCode());
assertEquals(MediaType.APPLICATION_JSON,
restContext.getHttpResponse().getContentType());
assertNotNull(restContext.getHttpResponse().getEntity());
// [4]
}
});
}
}
First of all, you can see all the annotations mentioned earlier. We use the ShrinkWrap
Resolver MavenImporter class here to get the whole project in the deployment.
The [1] object is the injection of the application URL. In [2] , we execute a client re-
quest to get the seats and in [3] , we do some basic client-side assertion. In [4] , we test
the server side, to check if the appropriate HTTP code was returned and so on. In more
complex scenarios, we can execute some beans logic to confirm that the appropriate state
change was performed on the server side. This last thing distinguishes the Arquillian Warp
from running tests in the client mode (a @RunAsClient annotation) and doing asser-
tions with ResteasyWebTarget .
Search WWH ::




Custom Search