users@jersey.java.net

Re: [Jersey] Testing jersey

From: Naresh <bsnaresh_at_sun.com>
Date: Thu, 16 Apr 2009 19:34:39 +0530

Hi Tarjei,

the Jersey-Test-Framework is a JUnit based test framework which allows
you to test your application against multiple containers.
  
It currently allows running tests on any of the following three light
weight containers:
1. Embedded GlassFish
2. Grizzly Web Server
3. Light-weight HTTP Server

It is easy to get started using the framework. If you are using a maven
based project, put the following dependency in your pom.xml:

<dependency>
            <groupId>com.sun.jersey.test.framework</groupId>
            <artifactId>jersey-test-framework</artifactId>
            <version>1.0.3</version>
            <scope>test</scope>
 </dependency>

Make your unit test class extend the class JerseyTest, and pass some
parameters related to the application like the root resource class name,
etc.

You might want to have a look at the following samples, which are using
the test framework:
1. helloworld
2. helloworld-webapp
3. extended-wadl-webapp
4. entity-provider
5. simple-console
6. jsonp
7. jaxb

         They can be downloaded from the samples zip file -
http://download.java.net/maven/2/com/sun/jersey/samples/jersey-samples/1.0.3/jersey-samples-1.0.3-project.zip.

Running the tests against these supported containers is simple. Set a
system property called "container.type" with one of the following values:
1. EmbeddedGF --> for running tests against Embedded GlassFish
2. GrizzlyWeb --> for running tests against Grizzly Web Server
3. HTTPServer --> for running tests against Simple HTTP Server

   The framework also allows you to see the request and response on
wire. Just set the system property "enableLogging".

For ex: To run the tests against Embedded GlassFish for the sample
"helloworld", execute the command-

  mvn clean test -Dcontainer.type=EmbeddedGF -DenableLogging

If you browse through the files of the sample, you can see that it
doesn't have a deployment descriptor. The test framework generates a
deployment descriptor on the fly, based on some parameters set by the
test. This makes the application testable on Embedded GlassFish though
it doesn't have a deployment descriptor.

If the "container.type" property is not set, the tests will be run on
the Grizzly Web Server, which is the default container.

I shall update the README file with instructions on how the test
framework could be used.

We are working on enhancing the framework by-
1. Adding support for external containers like GlassFish v2 and
GlassFish v3.
2. Providing an option for specifying the unsupported containers for a
particular test.

Please let us know if you see any issues, or see any areas of improvement.

Thanks,
Naresh




tarjei wrote:
> Hi, I saw that a new testing framework got released as part of 1.0.3.
> Is there a howto somewhere for using this framework?
>
> I'm looking for a way to automate testing of resources and their
> annotations.
>
> Kind regards,
> Tarjei
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>