com.javaranch.unittest.helper.sql.pool
Class JNDIUnitTestHelper

java.lang.Object
  |
  +--com.javaranch.unittest.helper.sql.pool.JNDIUnitTestHelper

public class JNDIUnitTestHelper
extends java.lang.Object

Title: JNDIUnitTestHelper

Description: Simple class used to simulate a JNDI DataSource for use in UnitTests

Usage is Simple in setUp for your UnitTest:
if(JNDIUnitTestHelper.notInitialized()){
JNDIUnitTestHelper.init("jndi_unit_test_helper.properties");
}
 

Requires the following properties be set by this example:
com.javaranch.unittest.helper.sql.pool.JNDIName=java/TestDB
com.javaranch.unittest.helper.sql.pool.dbDriver=org.gjt.mm.mysql.Driver
com.javaranch.unittest.helper.sql.pool.dbServer=jdbc:mysql://localhost/jugsoft
com.javaranch.unittest.helper.sql.pool.DbConnectionBrokerPool.dbLogin=juguser
com.javaranch.unittest.helper.sql.pool.DbConnectionBrokerPool.dbPassword=jugsoft

Copyright: Copyright (c) 2002

- - - - - - - - - - - - - - - - -

You are welcome to do whatever you want to with this source file provided that you maintain this comment fragment (between the dashed lines). Modify it, change the package name, change the class name ... personal or business use ... sell it, share it ... add a copyright for the portions you add ...

My goal in giving this away and maintaining the copyright is to hopefully direct developers back to JavaRanch.

The original source can be found at JavaRanch

- - - - - - - - - - - - - - - - -

Company: JavaRanch


Method Summary
static java.lang.String getJndiName()
          Gets the name of the datasource, useful in test because this is configurable for the tests ran.
static void init(java.lang.String fileName)
          Intializes the pool and sets it in the InitialContext
static boolean notInitialized()
          determines if the pool was successfully initialized or not.
static void shutdown()
          shutdowns down the pool and ends the Thread that DbConnectionBroker starts.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static void init(java.lang.String fileName)
                 throws java.io.IOException,
                        javax.naming.NamingException
Intializes the pool and sets it in the InitialContext
Parameters:
fileName - Name of the properties file
Throws:
java.io.IOException -  

notInitialized

public static boolean notInitialized()
determines if the pool was successfully initialized or not.

shutdown

public static void shutdown()
                     throws javax.naming.NamingException
shutdowns down the pool and ends the Thread that DbConnectionBroker starts.
Throws:
javax.naming.NamingException -  

getJndiName

public static java.lang.String getJndiName()
Gets the name of the datasource, useful in test because this is configurable for the tests ran.