users@jersey.java.net

JerseyTest and Guice

From: Kristof <kr_adr_at_yahoo.co.uk>
Date: Sun, 24 Oct 2010 19:27:34 +0100 (BST)

Hi all,
I'm trying to get a unit test running which extends the JerseyTest class and which is configured to use Guice for dependency injection.
I'm setting up the JerseyTest by using the constructor which takes a AppDescriptor object which I build using the WebAppDescriptor.Builder functionality.  
When debugging my test I see that my context listener which configures the Guice Injector with my Guice modules is executed but I think the GuiceFilter is not executed.
When I execute my test it fails with an error message stating that no root resource classes are found. I am however binding my Resource in my Guice module like in the examples. eg:
bind(HelloWorldResource.class); serve("/*").with(GuiceContainer.class);
I'm using the GrizzlyWebTestContainer.
It could be that I'm not correctly configuring the GuiceFilter. In a web.xml you defined the name of the filter and the class and also the filter-mapping to the url-pattern for the filter. I don't know how exactly to configure this using the WebAppDescriptor.Builder?
Or is there a way to point the JerseyTest class to the web.xml and use that instead of configuring it through code?

Thanks,Kristof