users@jersey.java.net

Re: [Jersey] How to Create Jersey Unit Tests

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 27 Jan 2010 12:02:03 +0100

Hi John,

A more details search presented this:

http://markmail.org/message/5mwnybcbthpxe47w?q=list:net.java.dev.jersey.users+mock

The key is to override the SpringServlet and SpringComponentProvider.

Paul.

On Jan 26, 2010, at 10:35 AM, Paul Sandoz wrote:

> Hi John,
>
> We do have a simple unit-test-based framework to aid testing:
>
> https://jersey.dev.java.net/nonav/apidocs/latest/jersey-test-framework/index.html
>
> The spring annotations sample uses this framework:
>
> http://download.java.net/maven/2/com/sun/jersey/samples/spring-annotations/1.1.5/spring-annotations-1.1.5-project.zip
>
> I am not sure about the mocking up side of things. I know other
> developers have done this, you might want to search the list:
>
> http://markmail.org/message/aeccbev3e3h4zk7l#query:Jersey%20JAX-RS
> %20Mockito+page:1+mid:gpjzij4epreb5kl2+state:results
> http://markmail.org/search/?q=list%3Anet.java.dev.jersey.users
>
> Hth,
> Paul.
>
> On Jan 22, 2010, at 6:05 PM, JohnM_Gallagher_at_timeinc.com wrote:
>
>> I am developing a project with jersey and spring. I am trying to
>> work out a good way to run unit tests. What I would like to do is
>> to load my jersey class within a spring context, but I would like
>> all of the spring injected members of the jersey class to be
>> mocked. Then some kind of web based testing framework, such as
>> HttpUnit, JWebUnit, or Jetty would call the Jersey object. How
>> could I do this? Thank you.
>