users@jersey.java.net

problem to return/get? location during tests with jersey-test-framework-grizzly

From: Frédéric Bouquet <bouquet.frederic_at_gmail.com>
Date: Thu, 20 May 2010 12:41:21 +0200

Hello list,

I have a problem with my project.
I have a resource which, when created answers the location in headers
like it (myId contains the id of the created resource) :

URI uri = URI.create(uriInfo.getAbsolutePath().toString() + "/" + myId);
response = Response.created(uri).build();

(If there's a better way to build the URI, I'm open to it :))
It works when I deploy it with embedded-glassfish.


When I want to unit test it with the test framework (grizzly).
I post the resource like it :

ClientResponse cr = webResource.header("Content-Type",
"text/xml").post(ClientResponse.class, "<myxml... />");

Then, I want to get back this resource using the header Location. I
tryed to get :
- cr.getLocation()
- cr.getHeaders().getFirst("Location")
But both return null.

How can I GET the resource created and pointed by the header Location ?


I use jersey 1.2.
I deploy with maven-embedded-glassfish-plugin (1.2)
I test with jersey-test-framework-grizzly (1.2). I have a bug with
jersey-test-framework-embedded-glassfish and maybe maven (the same
perhabs I've seen in the mailing list and bookstore example)

The architecture is like it :
- post http://domain.dln:port/project/resources : creates a resource
- get http://domain.dln:port/project/resources/{id} : gets the
resource with id {id}

Thank you for your help,

Fred