I want to test some new functionality which is part of an internal web app. This new code uses a database connection normally provided by an app server (tomcat).
I do no
With TomcatJNDI you can access every JNDI resource you configured within Tomcat as used to do in your web application. The code to achieve it is simple and looks like
TomcatJNDI tomcatJNDI = new TomcatJNDI();
tomcatJNDI.processContextXml(contextXmlFile);
tomcatJNDI.start();
DataSource ds = (DataSource) InitialContext.doLookup("java:comp/env/path/to/datasource")
Go here to read more about it.