users@jersey.java.net

Re: Jersey Test Framework init failures

From: Charley Robinson <c+java.net_at_wobbals.com>
Date: Mon, 2 Aug 2010 13:08:31 -0700 (PDT)

Those logging filters are useful for inspecting transactions *per request*,
however my troubles are rooted in the failure to initialize the container,
not issue requests to it.

Given:
1) An example web resource:
@Path("/cidrblock")
public class CidrblockResource {
    @Context UriInfo uriInfo;
    @GET
    @Produces("text/plain")
    public Response getCidrblocks() {
        Response.ResponseBuilder response = Response.status(200);
        response.entity("HAI");
        return response.build();
    }
}

2) A simple test:
@Test
public void testTopLevelGet() {
        System.out.println("HIDEO");
        ClientResponse response =
resource().path("cidrblock").get(ClientResponse.class);
        logger.debug(response.toString());
        logger.debug(response.getEntity(String.class));
}

Running mvn test shows Grizzly silently failing to init/start, so the Client
GET request gets made to a port where nothing is listening:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running IpAddressJpaTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.039 sec
Running CidrblockResourceTest
Aug 2, 2010 1:06:20 PM
com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer
<init>
INFO: Creating Grizzly Web Container configured at the base URI
http://localhost:9998/
HIDEO
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.935 sec
<<< FAILURE!
Running CidrblockJpaTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec
Running NetblockJpaTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.012 sec

Results :

Tests in error:
  testTopLevelGet(CidrblockResourceTest)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

-- 
View this message in context: http://jersey.576304.n2.nabble.com/Jersey-Test-Framework-init-failures-tp5363137p5365668.html
Sent from the Jersey mailing list archive at Nabble.com.