org.opensubsystems.core.persist.db.connectionpool
Class PooledDatabaseConnectionFactoryImplBaseTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.opensubsystems.core.persist.db.DatabaseTest
              extended by org.opensubsystems.core.persist.db.connectionpool.DatabaseConnectionFactoryBaseTest
                  extended by org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImplBaseTest
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
C3P0DatabaseConnectionFactoryTest.C3P0DatabaseConnectionFactoryTestInternal, DBCPDatabaseConnectionFactoryTest.DBCPDatabaseConnectionFactoryTestInternal, ProxoolDatabaseConnectionFactoryTest.ProxoolDatabaseConnectionFactoryTestInternal, XAPoolDatabaseConnectionFactoryTest.XAPoolDatabaseConnectionFactoryTestInternal

public abstract class PooledDatabaseConnectionFactoryImplBaseTest
extends DatabaseConnectionFactoryBaseTest

Base class containing tests for general concepts of pooled database connection factories, which every pooled database connection factory should support.

Version:
$Id: PooledDatabaseConnectionFactoryImplBaseTest.java,v 1.4 2007/01/07 06:14:20 bastafidli Exp $
Author:
Julian Legeny
Code reviewer:
Miro Halas
Code reviewed:
1.14 2004/10/05 07:39:53 bastafidli

Field Summary
protected static int ALL_CONNECTION_COUNT
          Constant defining MAX POOL SIZE - maximal number of connections in the pool
protected static int POOL_WAIT_PERIOD
          Constant defining POOL WAIT PERIOD - how long the pool will be waiting when there are used all connections in the pool.
 
Fields inherited from class org.opensubsystems.core.persist.db.connectionpool.DatabaseConnectionFactoryBaseTest
DATASOURCE_NAME_1, DATASOURCE_NAME_2, DATASOURCE_NAME_ADMIN, m_connectionFactory, USERNAME_FOR_DS_2
 
Fields inherited from class org.opensubsystems.core.persist.db.DatabaseTest
DEFAULT_DB_PASSWORD, DEFAULT_DB_USER, DEFAULT_PROPERTY_FILE, m_connection, m_iRequestedConnectionCount, m_transaction
 
Constructor Summary
PooledDatabaseConnectionFactoryImplBaseTest(java.lang.String strTestName)
          Create new PooledDatabaseConnectionFactoryImplBaseTest.
 
Method Summary
protected  java.lang.Object addItem(java.sql.Connection cActualConnection)
          Method returns item that will be added to the list.
protected abstract  boolean containsConnection(java.util.List lstConnections, java.sql.Connection newConnection)
          Method results if new connection is contained within the list of first time requested connections.
protected  void setUp()
          Set up environment for the test case.
 void testRequestOneMoreCanGrow()
          Test for request X+1 connections when there is possible to grow pool (CAN GROW flag = TRUE or particular pool supports it) This method is the same as testRequestOneMoreCannotGrow() but we need to have two methods with different names because we need to set different value for CAN GROW property.
 void testRequestOneMoreCannotGrow()
          Test for request X+1 connections when there is not possible to grow pool (CAN GROW flag = FALSE or particular pool doesn't support it).
 void testRequestXReturnX()
          Test if I configure the factory to return at most X connections and block then I cannot retrieve more.
 
Methods inherited from class org.opensubsystems.core.persist.db.connectionpool.DatabaseConnectionFactoryBaseTest
tearDown, testAddDataSourceWithTheSameName, testConnectionCountForTwoDataSources, testCreatingDefaultDataSource, testRequestConnectionByUserAndPassword, testRequestConnectionCount, testRequestConnectionCountByDataSource, testRequestConnectionCountByDataSourceWithUserAndPasswd, testRequestConnectionCountForSpecifiedDataSource, testRequestConnectionFromTwoDataSources, testRequestConnectionFromTwoDataSourcesByUserAndPassword, testReturnConnectionCount
 
Methods inherited from class org.opensubsystems.core.persist.db.DatabaseTest
addDataSource, addDataSource, getDataSourceName, setDataSourceName
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL_CONNECTION_COUNT

protected static final int ALL_CONNECTION_COUNT
Constant defining MAX POOL SIZE - maximal number of connections in the pool

See Also:
Constant Field Values

POOL_WAIT_PERIOD

protected static final int POOL_WAIT_PERIOD
Constant defining POOL WAIT PERIOD - how long the pool will be waiting when there are used all connections in the pool. Time is specified in miliseconds c3p0 is executing lots of operations asynchronously and if this is too low (e.g. 2000) you may get message that it cannto acquire connection even though connection is available. Solution is to keep this high enough.

See Also:
Constant Field Values
Constructor Detail

PooledDatabaseConnectionFactoryImplBaseTest

public PooledDatabaseConnectionFactoryImplBaseTest(java.lang.String strTestName)
Create new PooledDatabaseConnectionFactoryImplBaseTest.

Parameters:
strTestName - - name of the test
Method Detail

setUp

protected void setUp()
              throws java.lang.Exception
Set up environment for the test case.

Overrides:
setUp in class DatabaseConnectionFactoryBaseTest
Throws:
java.lang.Exception - - an error has occured during setting up test

testRequestXReturnX

public void testRequestXReturnX()
                         throws java.lang.Exception
Test if I configure the factory to return at most X connections and block then I cannot retrieve more.

Throws:
java.lang.Exception - - an error has occured during test

testRequestOneMoreCannotGrow

public void testRequestOneMoreCannotGrow()
                                  throws java.lang.Exception
Test for request X+1 connections when there is not possible to grow pool (CAN GROW flag = FALSE or particular pool doesn't support it). This method is the same as testRequestOneMoreCanGrow() but we need to have two methods with different names because we need to set different value for CAN GROW property.

Throws:
java.lang.Exception - - an error has occured during test

testRequestOneMoreCanGrow

public void testRequestOneMoreCanGrow()
                               throws java.lang.Exception
Test for request X+1 connections when there is possible to grow pool (CAN GROW flag = TRUE or particular pool supports it) This method is the same as testRequestOneMoreCannotGrow() but we need to have two methods with different names because we need to set different value for CAN GROW property.

Throws:
java.lang.Exception - - an error has occured during test

containsConnection

protected abstract boolean containsConnection(java.util.List lstConnections,
                                              java.sql.Connection newConnection)
                                       throws org.opensubsystems.core.error.OSSException
Method results if new connection is contained within the list of first time requested connections.

Parameters:
lstConnections - - list of first time requested connections
newConnection - - just new requested connection (requested second time)
Returns:
true - if newConnection is contained in the list false - if newConnection is not contained in the list
Throws:
org.opensubsystems.core.error.OSSException - - exception occured during comparing 2 connections

addItem

protected java.lang.Object addItem(java.sql.Connection cActualConnection)
                            throws org.opensubsystems.core.error.OSSInternalErrorException
Method returns item that will be added to the list. The item should uniquely represent the connection or the underlying connection so that it can be compared with different connections.

Parameters:
cActualConnection - - actual connection
Returns:
Object - object that will be added to the list
Throws:
org.opensubsystems.core.error.OSSInternalErrorException - - an error has occured


Copyright © 2003 - 2006 OpenSubsystems s.r.o.