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

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
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
PooledDatabaseConnectionFactoryImplBaseTest

public abstract class DatabaseConnectionFactoryBaseTest
extends DatabaseTest

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

Version:
$Id: DatabaseConnectionFactoryBaseTest.java,v 1.7 2007/01/07 06:14:20 bastafidli Exp $
Author:
Julian Legeny
Code reviewer:
Miro Halas
Code reviewed:
1.4 2005/09/01 05:22:03 bastafidli

Field Summary
static java.lang.String DATASOURCE_NAME_1
          Name ot the DataSource 1.
static java.lang.String DATASOURCE_NAME_2
          Name ot the DataSource 2
static java.lang.String DATASOURCE_NAME_ADMIN
          Name ot the admin DataSource.
protected  org.opensubsystems.core.persist.db.DatabaseConnectionFactory m_connectionFactory
          Database connection factory which can be used by test.
static java.lang.String USERNAME_FOR_DS_2
          Username for 2nd datasource
 
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
DatabaseConnectionFactoryBaseTest(java.lang.String strTestName)
          Create new DatabaseConnectionFactoryBaseTest.
 
Method Summary
protected  void setUp()
          Set up environment for the test case.
protected  void tearDown()
          Restore original environment after the test case.
 void testAddDataSourceWithTheSameName()
          Test for adding data source with the same name as already has been added.
 void testConnectionCountForTwoDataSources()
          Test for 2 data sources.
 void testCreatingDefaultDataSource()
          Test for request connection will create default data source if there wasn't specified.
 void testRequestConnectionByUserAndPassword()
          Test for requesting connection by user and password.
 void testRequestConnectionCount()
          Test for request connection - if there is connection requested, request counter has to increase.
 void testRequestConnectionCountByDataSource()
          Test for getting data source specified by name.
 void testRequestConnectionCountByDataSourceWithUserAndPasswd()
          Test for getting data source specified by name.
 void testRequestConnectionCountForSpecifiedDataSource()
          Test for connection count that is specified by data source
 void testRequestConnectionFromTwoDataSources()
          Test for requesting connection implicitly without specifying user name and password.
 void testRequestConnectionFromTwoDataSourcesByUserAndPassword()
          Test for requesting connection explictly by user and password.
 void testReturnConnectionCount()
          Test for return connection - if there is connection returned, request counter has to decrease.
 
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

DATASOURCE_NAME_ADMIN

public static final java.lang.String DATASOURCE_NAME_ADMIN
Name ot the admin DataSource.

See Also:
Constant Field Values

DATASOURCE_NAME_1

public static final java.lang.String DATASOURCE_NAME_1
Name ot the DataSource 1.

See Also:
Constant Field Values

DATASOURCE_NAME_2

public static final java.lang.String DATASOURCE_NAME_2
Name ot the DataSource 2

See Also:
Constant Field Values

USERNAME_FOR_DS_2

public static final java.lang.String USERNAME_FOR_DS_2
Username for 2nd datasource

See Also:
Constant Field Values

m_connectionFactory

protected org.opensubsystems.core.persist.db.DatabaseConnectionFactory m_connectionFactory
Database connection factory which can be used by test. This connection object is instantiated before every test is started by the concrete derived class.

Constructor Detail

DatabaseConnectionFactoryBaseTest

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

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 DatabaseTest
Throws:
java.lang.Exception - - an error has occured during setting up test

tearDown

protected void tearDown()
                 throws java.lang.Exception
Restore original environment after the test case.

Overrides:
tearDown in class DatabaseTest
Throws:
java.lang.Exception - - an error has occured during tearing down up test

testCreatingDefaultDataSource

public void testCreatingDefaultDataSource()
                                   throws java.lang.Exception
Test for request connection will create default data source if there wasn't specified.

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

testRequestConnectionCount

public void testRequestConnectionCount()
                                throws java.lang.Exception
Test for request connection - if there is connection requested, request counter has to increase.

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

testRequestConnectionCountForSpecifiedDataSource

public void testRequestConnectionCountForSpecifiedDataSource()
                                                      throws java.lang.Exception
Test for connection count that is specified by data source

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

testReturnConnectionCount

public void testReturnConnectionCount()
                               throws java.lang.Exception
Test for return connection - if there is connection returned, request counter has to decrease.

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

testAddDataSourceWithTheSameName

public void testAddDataSourceWithTheSameName()
                                      throws java.lang.Exception
Test for adding data source with the same name as already has been added.

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

testConnectionCountForTwoDataSources

public void testConnectionCountForTwoDataSources()
                                          throws java.lang.Exception
Test for 2 data sources. When there was requested connection from DS1, then set to DS2, then return conection (for DS1 when active is DS2), connection count will be still 1 instead of 0.

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

testRequestConnectionFromTwoDataSources

public void testRequestConnectionFromTwoDataSources()
                                             throws java.lang.Exception
Test for requesting connection implicitly without specifying user name and password. There are 2 data sources. It should be possible to switch them and retrieve connections from each one of them. Each data source has different user which creates different table and inserts some data to it and selects some data from it. These data should be different for both connections and it should not be possible to access the other table using incorrect connection.

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

testRequestConnectionFromTwoDataSourcesByUserAndPassword

public void testRequestConnectionFromTwoDataSourcesByUserAndPassword()
                                                              throws java.lang.Exception
Test for requesting connection explictly by user and password. There are 2 data sources. It should be possible to switch them and retrieve connections from each one of them. Each data source has different user which creates different table and inserts some data to it and selects some data from it. These data should be different for both connections and it should not be possible to access the other table using incorrect connection.

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

testRequestConnectionByUserAndPassword

public void testRequestConnectionByUserAndPassword()
                                            throws java.lang.Exception
Test for requesting connection by user and password. There are 2 data sources. There shoul be possible to switch them and retrieve connections from each one of them. And select some data drom DB. These data should be different for both connections.

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

testRequestConnectionCountByDataSource

public void testRequestConnectionCountByDataSource()
                                            throws java.lang.Exception
Test for getting data source specified by name. There should be not changed to default data source, only thing that will change will be maximal connection count and connection count for specified data source.

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

testRequestConnectionCountByDataSourceWithUserAndPasswd

public void testRequestConnectionCountByDataSourceWithUserAndPasswd()
                                                             throws java.lang.Exception
Test for getting data source specified by name. There should be not changed to default data source, only thing that will change will be maximal connection count and connection count for specified data source.

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


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