Hi Kristof,
On Sun, Oct 24, 2010 at 11:57 PM, Kristof <kr_adr_at_yahoo.co.uk> wrote:
> 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?
>
Did you try using the "filterClass()" or "addFilter()" methods?
Please refer the jersey-guice-filter sample [1].
>
> Or is there a way to point the JerseyTest class to the web.xml and use that
> instead of configuring it through code?
>
I do not think this is there yet. Probably, Pavel can give you more update.
[1]
http://download.java.net/maven/2/com/sun/jersey/samples/guicefilter-webapp/1.4/guicefilter-webapp-1.4-project.zip
- Naresh
>
>
> Thanks,
> Kristof
>
>