ch.elca.el4j.tests.tcpforwarder
Class TcpForwarderTest

java.lang.Object
  extended by ch.elca.el4j.tests.tcpforwarder.TcpForwarderTest

public class TcpForwarderTest
extends Object

This class is a TestSuite for the TCP Forwarder Module. It tests 1) Wheter a store call to a database (using hibernate) is forwarded to the right port. 2) The Application Context can be created and the Dao retrieved with the connection to the database cut.

Author:
David Stefan (DST)
File-location:
TcpForwarderTest
Last check-in date:
2009-08-04 15:48:31 +0200 (Di, 04. Aug 2009) by swismer for revision 3884

Field Summary
private static String[] CONFIG_LOCATIONS
          Config locations.
(package private) static int DELAY
          Delay between the single test steps (in milliseconds).
(package private) static int DERBY_DEST_PORT
          Port of the Derby database.
(package private) static int INPUT_PORT
          New input port -> Forwarder between INPUT_PORT and target port resp.
private  ConfigurableApplicationContext m_appContext
          Application context to load beans.
private  ConvenienceGenericHibernateDao<Name,Integer> m_dao
          Data Access Object.
private  TcpForwarder m_forwarder
          The TCP Forwarder.
private  boolean m_isDB2
          Are we executing the tests on a DB2 database?
(package private) static int ORACLE_DEST_PORT
          Port of the Oracle database.
(package private) static String ORACLE_SERVER_NAME
          Original domain name of the Oracle database server.
private static org.slf4j.Logger s_logger
          Private logger.
 
Constructor Summary
TcpForwarderTest()
           
 
Method Summary
private  void executeFirstInsert()
          Execute store of data object to test database.
private  void executeSecondInsert()
          Execute the second store, which is supposed to fail, because the TCP fowarder is unplugged.
private  void executeThirdInsert()
          Execute third store to check if database connection works after we have plugged it again.
private  ApplicationContext getApplicationContext()
           
private  ConvenienceGenericHibernateDao<Name,Integer> getDao()
           
 void setUp()
          
 void tearDown()
          
 void testForwarder()
          This test uses a tcp forwarder to connect to a databse and verifies that this connection has been established, then cuts the connection to the database and verifies that there is no connectivity to the database any more, then reconnects to the database again and tests whether the connection has been re-established.
 void testSpringWithoutDBConnection()
          This test tries to start Spring when there is no connection to a database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELAY

static final int DELAY
Delay between the single test steps (in milliseconds).

See Also:
Constant Field Values

INPUT_PORT

static final int INPUT_PORT
New input port -> Forwarder between INPUT_PORT and target port resp. target server.

See Also:
Constant Field Values

DERBY_DEST_PORT

static final int DERBY_DEST_PORT
Port of the Derby database.

See Also:
Constant Field Values

ORACLE_DEST_PORT

static final int ORACLE_DEST_PORT
Port of the Oracle database.

See Also:
Constant Field Values

ORACLE_SERVER_NAME

static final String ORACLE_SERVER_NAME
Original domain name of the Oracle database server.

See Also:
Constant Field Values

CONFIG_LOCATIONS

private static final String[] CONFIG_LOCATIONS
Config locations.


s_logger

private static org.slf4j.Logger s_logger
Private logger.


m_appContext

private ConfigurableApplicationContext m_appContext
Application context to load beans.


m_isDB2

private boolean m_isDB2
Are we executing the tests on a DB2 database?


m_forwarder

private TcpForwarder m_forwarder
The TCP Forwarder.


m_dao

private ConvenienceGenericHibernateDao<Name,Integer> m_dao
Data Access Object.

Constructor Detail

TcpForwarderTest

public TcpForwarderTest()
Method Detail

setUp

public void setUp()


tearDown

public void tearDown()


testForwarder

public void testForwarder()
                   throws Exception
This test uses a tcp forwarder to connect to a databse and verifies that this connection has been established, then cuts the connection to the database and verifies that there is no connectivity to the database any more, then reconnects to the database again and tests whether the connection has been re-established.

Throws:
Exception

testSpringWithoutDBConnection

public void testSpringWithoutDBConnection()
                                   throws Exception
This test tries to start Spring when there is no connection to a database.

Throws:
Exception

getApplicationContext

private ApplicationContext getApplicationContext()
Returns:
Returns the applicationContext.

getDao

private ConvenienceGenericHibernateDao<Name,Integer> getDao()
Returns:
The DAO for the inserts

executeFirstInsert

private void executeFirstInsert()
                         throws InterruptedException
Execute store of data object to test database.

Throws:
InterruptedException

executeSecondInsert

private void executeSecondInsert()
Execute the second store, which is supposed to fail, because the TCP fowarder is unplugged.


executeThirdInsert

private void executeThirdInsert()
Execute third store to check if database connection works after we have plugged it again.



Copyright © 2005-2011 ELCA. All Rights Reserved.