users@jersey.java.net

[Jersey] Adding Servlet instances to GrizzlyWebTestContainer

From: James Shaw <js102_at_zepler.net>
Date: Tue, 16 Oct 2012 21:48:21 +0100

As far as I know, you can only add servlet class names to
WebAppDescriptors, although Grizzly itself permits registration of
javax.servlet.Servlet instances.

I'm asking because I want to share a Spring ApplicationContext between
an integration test and the web container in some integration tests.
I've got this working by writing my own version of
GrizzlyWebTestContainer to accept a Servlet instance rather than just
a class name. Then I can extend SpringServlet to return the test's
ApplicationContext, and pass that servlet to the test container.

A couple questions:
* Is there a better way to do this in Jersey 1?
* How might this work in Jersey 2? (or is it too early to talk about
Spring integration?)