|Re: [jetty-users] Testing with JNDI|
Benjamin, You can have a look at the junit tests for jetty-jndi, specifically this one: https://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-jndi/src/test/java/org/eclipse/jetty/jndi/java/TestJNDI.java As long as you've got a Thread context classloader set, you can call lookup on java:comp and if it doesn't exist it will create it. You can then make your own env subcontext. cheers Jan On 18 September 2013 04:05, Benjamin Zuill-Smith <bzuillsmith@xxxxxxxxx> wrote: > I want to run some JUnit tests that involve a JNDI Resource. This Resource > is setup with server scope as the server starts in my test. However, I can't > create a webapp-like context for Jetty to setup the JNDI subcontexts like > java:comp/env. Is that only done when using a WebappContext? Are there other > Context classes that can be used for testing to achieve this? > > I can't use WebappContext because my war is not created in the testing phase > and I also would rather not have test web.xml and jetty-xml descriptors, > etc. > > For now, I put into my tests an explicit Resource at the java:comp/env > context but it I would like to be able to test with code as close to the > production as possible and avoid painful tests down the road. > > Anyone have suggestions? > > -- > Benjamin Zuill-Smith > > _______________________________________________ > jetty-users mailing list > jetty-users@xxxxxxxxxxx > https://dev.eclipse.org/mailman/listinfo/jetty-users > -- Jan Bartel <janb@xxxxxxxxxxx> www.webtide.com 'Expert Jetty/CometD developer,production,operations advice'
Back to the top