users@jersey.java.net

Re: [Jersey] testing Jersey web-service

From: Srinivas Naresh Bhimisetty <Srinivas.Bhimisetty_at_Sun.COM>
Date: Tue, 25 Nov 2008 10:24:17 +0530

Hi John,

     you could use one of the light-weight containers to do what you
want. In fact, most of the Jersey samples have unit tests where the
resources are deployed to light-weight containers like
EmbeddedGlassfish, Grizzly or HTTPServer.

You might want to have a look at these samples [1], or a bundle of these
samples is available at
[1] https://jersey.dev.java.net/source/browse/jersey/trunk/jersey/samples/
[2]
http://download.java.net/maven/2/com/sun/jersey/samples/jersey-samples/1.0/jersey-samples-1.0-project.zip

    The helloworld-webapp sample uses the "EmbeddedGlassfish" for
deployments.

    Also, the development of a test framework is going on. This
framework could be used to run the tests on a set of light-weight
containers.

Hope this helps,
Naresh

John O'Conner wrote:
> Now that I have a couple GET methods implemented, I would like to
> create JUnit tests. I'd like to run these tests without deploying the
> entire ws to JBoss. Does anyone have any suggestions for how to test a
> Jersey web service without actually deploying? I'm also using
> Spring....I've heard about mock classes with Spring...maybe that can
> help me mock the db connection, maybe the app server too?
>
> Regards,
> John O'Conner
>