2 Replies Latest reply on May 5, 2012 2:34 PM by dan.j.allen

    Looking for a driver for a declarative REST testing extension

    dan.j.allen

      The JAX-RS EG recently announced that a set of client APIs will be standardized in JAX-RS 2.0 (see example). With that announcement, and the continued industry adoption of REST services, I think the time is right to convert the Arquillian declarative REST testing prototype that Aslak created into an official module. The extension is currently based on RESTEasy, but should be changed immediately to use the proposed JAX-RS client APIs.

       

      I propose the following repository name:

       

      • arquillian-extension-rest

       

      Here's an example from the prototype:

       

         @Test @GET @Path("rest/customer") @Consumes(MediaType.APPLICATION_XML)
         public void shouldBeAbleToListAllCustomers(ClientResponse<List<Customer>> response)
         {
            Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus());
      
            List<Customer> customers = response.getEntity(new GenericType<List<Customer>>(){});
            Assert.assertEquals(2, customers.size());
         }
      

       

      As motivation for this intiative, see the recent post Writing lightweight REST integration tests with the Jersey Test Framework. While it may be lightweight (debatable), it's tied to a lot of internal classes, leading to these words of caution:

       

      • Decide what type of container to use before writing tests < We always say the *opposite*
      • Do not use WebAppDescriptor for low-level containers < Exactly, use ShrinkWrap Descriptors, a portable API

       

      The post also talks about having to use mocks and other workarounds to make the test work without a proper environment. All of that is solved by Arquillian, so providing a REST extension is an excellent fit.

       

      Note: https://github.com/jherault seems to be interested since he proposed an update in the comments of the gist Aslak posted.