The surefire report simply stated there was nothing listening on the request
port (connection refused).
Incidentally, I stumbled on the solution to this problem: Overriding setUp()
and tearDown() methods as a subclass of JerseyTest takes away start/stop
control of the web container. Calling each of super.setUp() and
super.tearDown() from the overloading methods respectively fixes the
problem. Missed that one in the javadocs -- cool trick.
Thanks for your help,
--Charley
On Tue, Aug 3, 2010 at 1:30 AM, Pavel Bucek <Pavel.Bucek_at_sun.com> wrote:
>
> Did you check surefire report(s)? (./target/surefire-reports directory) It
> might contain some useful information.
>
> Can you post whole test class, or at least constructor?
>
> With logging filter on client side, you should be able at least see the
> initial request.
>
> Pavel
>
>
>
> On 8/2/10 11:41 PM, Charley Robinson wrote:
>
>
> Those logging filters are useful for inspecting transactions *per request*,
> however my troubles are rooted in the failure to start the (supposedly)
> initialized 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
>
>
> ...Compare this to the info logs of the container when running, say,
> HelloWorld 1.3:
>
> Running com.sun.jersey.samples.helloworld.MainTest
> Aug 2, 2010 1:11:26 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/
> Aug 2, 2010 1:11:27 PM
> com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer
> start
> INFO: Starting the Grizzly Web Container...
> Aug 2, 2010 1:11:27 PM com.sun.grizzly.Controller logVersion
> INFO: Starting Grizzly Framework 1.9.18-i - Mon Aug 02 13:11:27 PDT 2010
> Aug 2, 2010 1:11:27 PM com.sun.jersey.api.core.PackagesResourceConfig init
> INFO: Scanning for root resource and provider classes in the packages:
> com.sun.jersey.samples.helloworld.resources
> Aug 2, 2010 1:11:27 PM com.sun.jersey.api.core.ScanningResourceConfig
> logClasses
> INFO: Root resource classes found:
> class com.sun.jersey.samples.helloworld.resources.HelloWorldResource
>
> ...and so forth.
>
> --Charley
>
> Pavel Bucek wrote:
>
>> Hello,
>>
>> you can user client and server logging filter ([1] and [2]), and set jdk
>>
>> logging to display info messages of
>> "com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainer"
>> logger (but there are only simple messages which state starting/stopping
>> container).
>>
>>
>> Additionally, you may want to check that port localhost:9998 is not used
>> (netstat -aln or similar command for your OS).
>>
>> Or if you can share your code, I can help you with debugging.
>>
>> Regards,
>>
>> Pavel
>>
>>
>> [1] https://jersey.dev.java.net/nonav/apidocs/1.3/jersey/com/sun/jersey/api/client/filter/LoggingFilter.html
>>
>> [2] https://jersey.dev.java.net/nonav/apidocs/1.3/jersey/com/sun/jersey/api/container/filter/LoggingFilter.html
>>
>>
>>
>>
>