users@jersey.java.net

[Jersey] Re: Jersey test framework with JNDI resources

From: Mike Key <mikey_at_zenbitz.com>
Date: Wed, 19 Jan 2011 07:51:37 -0700

Thanks Paul, that is exactly what I had setup before trying out the
Jersey test framework. Unless someone else is working on it, when I
have some time I may try to add Jetty to the test framework as an option
and see what comes of it. I appreciate everyones great feedback on this
issue!

Mike

> ------------------------------------------------------------------------
>
> Paul Sandoz <mailto:Paul.Sandoz_at_oracle.com>
> January 19, 2011 2:21 AM
>
>
>
>
>
> It's is not possible using Grizzly because it does not support the
> JNDI semantics of a EE web container. Jetty might. In such cases using
> war deployment (exploded or otherwise) might be the best option. The
> test framework with external deployment where maven starts/stops Jetty
> could work for you.
>
> Paul.
>
>
>
> ------------------------------------------------------------------------
>
> Mike Key <mailto:mikey_at_zenbitz.com>
> January 18, 2011 9:53 PM
>
>
> Thanks Ryan, I did consider both of these ideas and they are good
> ones. I was trying to get an environment as close to a real
> deployment would be for these tests, which the use of grizzly should
> have initially flagged as already missing my own point. I have headed
> down this path now, but am still curious if it is/will ever be
> possible to do so with the Jersey Test Framework.
>
> Thanks again for the ideas.
>
> Mike
>
> ------------------------------------------------------------------------
>
> Ryan Stewart <mailto:zzantozz_at_gmail.com>
> January 18, 2011 7:54 PM
>
>
> I'm not sure about getting a real JNDI registry into the test
> framework, but here's a couple of ideas to get around needing it:
> 1) Move your JNDI lookup into a separate spring context file and
> substitute a different file defining a bean with the same id for
> tests. In other words, in src/main/resources you have your "main.xml"
> which includes the JAX-RS resource beans and all supporting beans plus
> a "jndi.xml" containing your <jee:jndi-lookup id="connectionFactory"
> .../>. Then in src/main/tests, you have a jndi-test.xml with <bean
> id="connectionFactory" .../> which just defines some real or mock
> connection factory suitable for your tests. So in your test class, use
> main.xml and jndi-test.xml and leave out the JNDI lookup entirely.
> 2) I'm not sure about the jee:jndi-lookup convenience call, but the
> JndiObjectFactoryBean which backs it has a setDefaultObject method,
> which sets the object to be returned if the JNDI lookup fails. Perhaps
> you could use this somehow to inject something suitable for your tests.
>
>
> ------------------------------------------------------------------------
>
> Mike Key <mailto:mikey_at_zenbitz.com>
> January 18, 2011 8:21 AM
>
>
> Based on lack of response from such a good community I am assuming
> nobody has done/tried this with Jersey Test Framework. Can anyone
> tell me if it at least *should* be possible to use JNDI resources when
> loading a webapp into the Jersey Test Framework? I am using a simple
> configuration which leverages the Grizzly server. The test bootstraps
> properly but then fails as it cannot find the JNDI resource it is
> looking for (see below for Spring section it is looking for).
>
> Thanks for any direction.
>
> Mike Key
>
> ------------------------------------------------------------------------
>
> Mike Key <mailto:mikey_at_zenbitz.com>
> January 16, 2011 4:48 PM
>
>
> I am trying to use the Jersey test framework with a web application
> that includes some JMS resources normally looked up through JNDI. For
> example I have the following in my spring config:
>
> <jee:jndi-lookup id="connectionFactory"
> jndi-name="jms/connectionFactory"
> resource-ref="true"/>
>
> I am struggling to figure out how to add a JNDI configuration to the
> grizzly configuration. Can someone point me to or lead me in the
> right direction on how to setup JNDI resources in a Jersey test
> framework setup?
>
> Thanks in advance.
>
> Mike Key