users@jersey.java.net

Re: [Jersey] Testing with init-params

From: Pavel Bucek <Pavel.Bucek_at_Sun.COM>
Date: Mon, 17 May 2010 10:09:19 +0200

Hello Edwin,

this is strange, it works for me. I created minimal testcase and
submitted it as GrizzlyWebInjectionTest test into
jersey-test-framework-grizzly and it passes [1]. Does it work for you too?

Regards,
Pavel

[1]
https://jersey.dev.java.net/source/browse/jersey/trunk/jersey/jersey-test-framework/jersey-test-framework-grizzly/src/test/java/com/sun/jersey/test/framework/impl/container/grizzlyweb/GrizzlyWebInjectionTest.java?rev=3677&view=markup


On 5/16/10 4:15 AM, Edwin Shin wrote:
> Hello,
>
> I'm having some trouble accessing init-params I've set in a test case.
>
> In the test case constructor, I've set the init-params as follows:
>
> public FooTest() {
> super(new WebAppDescriptor.Builder("com.example.foo")
> .contextPath("foo")
> .initParam("foo", "quux").build());
> }
>
> and then, within the actual class under test:
>
> @Context ServletConfig sc;
> public void doSomething() {
> assert sc != null;
> System.out.println(sc.getInitParam("foo"));
> }
>
> However, I get a NullPointerException on the last statement above. Same result with either jersey-test-framework-grizzly and jersey-test-framework-inmemory.
>
> I gathered from Paul's response here (https://jersey.dev.java.net/servlets/ReadMsg?list=users&msgNo=9234) that I should be able to do this. Any pointers as to what I might be doing wrong here?
>
> Thanks in advance,
> Eddie
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>