com.mockrunner.mock.jdbc
Class JDBCMockObjectFactory

java.lang.Object
  extended by com.mockrunner.mock.jdbc.JDBCMockObjectFactory

public class JDBCMockObjectFactory
extends java.lang.Object

Used to create all types of JDBC mock objects. Maintains the necessary dependencies between the mock objects. If you use the mock objects returned by this factory in your tests you can be sure that they are all up to date. Please note, that this class removes all drivers from the JDBC DriverManager and registers the MockDriver. All drivers are preserved and can be restored with restoreDrivers().


Constructor Summary
JDBCMockObjectFactory()
          Creates a new set of mock objects.
 
Method Summary
 MockConnection createMockConnection()
          Creates the MockConnection using new.
 MockDataSource createMockDataSource()
          Creates the MockDataSource using new.
 MockDriver createMockDriver()
          Creates the MockDriver using new.
 MockConnection getMockConnection()
          Returns the MockConnection.
 MockDataSource getMockDataSource()
          Returns the MockDataSource.
 MockDriver getMockDriver()
          Returns the MockDriver.
 void registerMockDriver()
          Removes all JDBC drivers from the DriveManager and registers the mock driver.
 void restoreDrivers()
          Since JDBCMockObjectFactory removes all the drivers from the DriveManager (so the MockDriver is guaranteed to be the only one) you can use this method to restore the original drivers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCMockObjectFactory

public JDBCMockObjectFactory()
Creates a new set of mock objects.

Method Detail

registerMockDriver

public void registerMockDriver()
Removes all JDBC drivers from the DriveManager and registers the mock driver. The removed drivers are preserved and can be restored with restoreDrivers().


restoreDrivers

public void restoreDrivers()
Since JDBCMockObjectFactory removes all the drivers from the DriveManager (so the MockDriver is guaranteed to be the only one) you can use this method to restore the original drivers. Automatically called by BaseTestCase.tearDown().


createMockConnection

public MockConnection createMockConnection()
Creates the MockConnection using new. This method can be overridden to return a subclass of MockConnection.

Returns:
the MockConnection

createMockDriver

public MockDriver createMockDriver()
Creates the MockDriver using new. This method can be overridden to return a subclass of MockDriver.

Returns:
the MockDriver

createMockDataSource

public MockDataSource createMockDataSource()
Creates the MockDataSource using new. This method can be overridden to return a subclass of MockDataSource.

Returns:
the MockDataSource

getMockDataSource

public MockDataSource getMockDataSource()
Returns the MockDataSource.

Returns:
the MockDataSource

getMockDriver

public MockDriver getMockDriver()
Returns the MockDriver.

Returns:
the MockDriver

getMockConnection

public MockConnection getMockConnection()
Returns the MockConnection.

Returns:
the MockConnection