JUnit Tests against a class that uses Tomcat Connection Pools
Posted on 2006-11-14
I've got a class that normally executes from within Tomcat which uses a MySQL database connection pool..
I'd like to set up some JUnit tests to test this external to Tomcat.
Currently, if I execute the test, I get the following exception:
ERROR: Unable to get a connection from jdbc/portalDb
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
I've read up on the jndi.properties file. But the examples are horrible, I'm not sure what to set the java.naming.factory.initial property to, let alone how to define a connection to the MySQL database.
How do I get these tests to work?