Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.hibernate.test.connections
Class ConnectionManagementTestCase  view ConnectionManagementTestCase download ConnectionManagementTestCase.java

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.hibernate.test.TestCase
              extended byorg.hibernate.test.connections.ConnectionManagementTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AggressiveReleaseTest, BasicConnectionProviderTest, SuppliedConnectionTest, ThreadLocalCurrentSessionTest

public abstract class ConnectionManagementTestCase
extends org.hibernate.test.TestCase

Common test cases relating to session management and how the sessions manages its underlying jdbc connection across different config scenarios. The different config scenarios are controlled by the individual test subclasses.

In general, all the tests required are defined here in templated fashion. Subclassed then override various hook methods specific to their given scneario being tested.


Field Summary
 
Fields inherited from class org.hibernate.test.TestCase
SKIP_LOG
 
Fields inherited from class junit.framework.TestCase
 
Constructor Summary
ConnectionManagementTestCase(java.lang.String name)
           
 
Method Summary
protected  void checkDeserializedState(org.hibernate.Session session)
          Check the state of a fixture session after deserialization, as well as validate the environmental state after session deserialization.
protected  void checkSerializedState(org.hibernate.Session session)
          Check the state of a fixture session after serialization, as well as validate the environmental state after session serialization.
protected  void configure(org.hibernate.cfg.Configuration cfg)
           
protected  void done()
          Used to cleanup the environment after testing (e.g., ending a JTA transaction or closing a user-supplied connection).
protected  java.lang.String[] getMappings()
           
protected abstract  org.hibernate.Session getSessionUnderTest()
          Used to get a session configured based on the config scenario being tested.
protected  void prepare()
          Used to prepare the environment for testing (e.g., starting a JTA transaction or obtaining a user-supplied connection).
protected abstract  void reconnect(org.hibernate.Session session)
          Perform any steps needed to reconnect a fixture session.
protected  void release(org.hibernate.Session session)
          Used to release a fixture session 55 .
 void testBasicSessionUsage()
          Test that the basic session usage template works in all environment scenarios.
 void testConnectedSerialization()
          Tests to validate that a session holding JDBC resources will not be allowed to serialize.
 void testManualDisconnectChain()
          Test that the legacy manual disconnect()/reconnect() chain works as expected in the given environment.
 void testManualDisconnectedSerialization()
          Test that a session which has been manually disconnected will be allowed to serialize.
 void testManualDisconnectWithOpenResources()
          Test that the legacy manual disconnect()/reconnect() chain works as expected in the given environment.
 void testSessionClosedProtections()
          Test that session-closed protections work properly in all environments.
 
Methods inherited from class org.hibernate.test.TestCase
afterSessionFactoryBuilt, appliesTo, assertClassAssignability, assertElementTypeAssignability, dialectIsCaseSensitive, dialectSupportsEmptyInList, dropAfterFailure, fullTestName, getBaseForMappings, getCacheConcurrencyStrategy, getCfg, getDialect, getExtraProperties, getSessions, openSession, openSession, overrideCacheStrategy, readCommittedIsolationMaintained, recreateSchema, reportSkip, reportSkip, runTest, setCfg, setUp, sfi
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, setName, tearDown, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectionManagementTestCase

public ConnectionManagementTestCase(java.lang.String name)
Method Detail

getMappings

protected final java.lang.String[] getMappings()

configure

protected void configure(org.hibernate.cfg.Configuration cfg)

prepare

protected void prepare()
                throws java.lang.Throwable
Used to prepare the environment for testing (e.g., starting a JTA transaction or obtaining a user-supplied connection).


done

protected void done()
             throws java.lang.Throwable
Used to cleanup the environment after testing (e.g., ending a JTA transaction or closing a user-supplied connection).


getSessionUnderTest

protected abstract org.hibernate.Session getSessionUnderTest()
                                                      throws java.lang.Throwable
Used to get a session configured based on the config scenario being tested.


release

protected void release(org.hibernate.Session session)
Used to release a fixture session 55 . Overridden to perform session releasing/testing specific to the given config scenario being tested.


reconnect

protected abstract void reconnect(org.hibernate.Session session)
                           throws java.lang.Throwable
Perform any steps needed to reconnect a fixture session.


checkSerializedState

protected void checkSerializedState(org.hibernate.Session session)
Check the state of a fixture session after serialization, as well as validate the environmental state after session serialization.


checkDeserializedState

protected void checkDeserializedState(org.hibernate.Session session)
Check the state of a fixture session after deserialization, as well as validate the environmental state after session deserialization.


testConnectedSerialization

public final void testConnectedSerialization()
                                      throws java.lang.Throwable
Tests to validate that a session holding JDBC resources will not be allowed to serialize.


testManualDisconnectedSerialization

public final void testManualDisconnectedSerialization()
                                               throws java.lang.Throwable
Test that a session which has been manually disconnected will be allowed to serialize.


testManualDisconnectChain

public final void testManualDisconnectChain()
                                     throws java.lang.Throwable
Test that the legacy manual disconnect()/reconnect() chain works as expected in the given environment.


testManualDisconnectWithOpenResources

public final void testManualDisconnectWithOpenResources()
                                                 throws java.lang.Throwable
Test that the legacy manual disconnect()/reconnect() chain works as expected in the given environment. Similiar to testManualDisconnectChain() 55 expect that here we force the session to acquire and hold JDBC resources prior to disconnecting.


testBasicSessionUsage

public void testBasicSessionUsage()
                           throws java.lang.Throwable
Test that the basic session usage template works in all environment scenarios.


testSessionClosedProtections

public void testSessionClosedProtections()
                                  throws java.lang.Throwable
Test that session-closed protections work properly in all environments.