users@jersey.java.net

Re: [Jersey] Jersey Test Framework

From: Naresh <Srinivas.Bhimisetty_at_Sun.COM>
Date: Mon, 14 Sep 2009 13:52:07 +0530

Hi Yogesh,

Yogesh kumar wrote:
>
> I am using "GrizzlyWebTestContainerFactory
> (jersey-test-framework-1.1.2-ea.jar)" to write testcases for my jersey
> service which uses *session* variable.
>
> *I am not sure how to make available session objects through test
> framework?*
>
> Tried to set session objects using filterClass
> (WebAppDescriptor.Builder) but it shows me null pointer exception
> while starting container. I gone through the src code and found this
> chunk causing error:
>
> try {
> servletInstance = (Servlet) servletClass.newInstance();
> } catch (InstantiationException ex) {
> throw new TestContainerException(ex);
> } catch (IllegalAccessException ex) {
>
> It always excepting servletClass and when I setting filter class this
> code snippet sets *this.servletClass = null* and *one more thing test
> framework not using filter class anywhere*.

the framework not using the filter class was indeed a bug in the
implementation, which was overseen during the development. However, we
have identified this after the release of 1.1.2-ea, and fixed it in
1.1.3-ea-SNAPSHOT. Can you please try using the 1.1.3-ea-SNAPSHOT version?

One more thing is, by design we have made the use of servlet or filter
mutually exclusive.

Please let us know, if things are working for you with the current
implementation or not.

-Naresh

>
> try {
> servletInstance = (Servlet) servletClass.newInstance();
> } catch (InstantiationException ex) {
> throw new TestContainerException(ex);
> } catch (IllegalAccessException ex) {public Builder
> filterClass(Class<? extends Filter> filterClass)
> throws IllegalArgumentException {
> if (filterClass == null)
> throw new IllegalArgumentException("The filter class
> must not be null");
> this.filterClass = filterClass;
> this.servletClass = null;
> return this;
> }
>
> Thanks,
> Yogesh