com.ail.coretest
Class TestCoreHibernatePersistence

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.ail.coretest.CoreUserTestCase
              extended by com.ail.coretest.TestCoreHibernatePersistence
All Implemented Interfaces:
ConfigurationOwner, CoreUser, java.io.Serializable, junit.framework.Test

public class TestCoreHibernatePersistence
extends CoreUserTestCase

Version:
$Revision: 1.5 $
See Also:
Serialized Form

Constructor Summary
TestCoreHibernatePersistence(java.lang.String name)
          Constructs a test case with the given name.
 
Method Summary
static void main(java.lang.String[] args)
           
static junit.framework.Test suite()
           
 void testAttributesWithinAttributes()
           
 void testCorePersistenceMethods()
          The Core exposes persistence methods in an easy-to-use form.
 void testDeepTypeHierarchy()
          Test the persistence of a deep hierarchy.
 void testHibernateCreateDirectAccess()
           
 void testHibernateCreateFailMissingObject()
           
 void testHibernateCreateFailPredifnedSerialVersion()
           
 void testHibernateCreateSuccess()
           
 void testHibernateLoadSuccess()
          Test that a persisted object can be retrieved using the Load service.
 void testHibernateQuerySuccess()
          Test that a persisted object can be retrieved using the Query service.
 void testHibernateRemoteCreateSuccess()
           
 void testHibernateUpdateFailMissingObject()
          Test direct access to the validator
 void testHibernateUpdateFailWrongSerialVersion()
           Create a record Update the record Update the record using the same serialVersionId - this update should fail
 void testHibernateUpdateSuccess()
           
 
Methods inherited from class com.ail.coretest.CoreUserTestCase
getConfiguration, getConfigurationNamespace, getCore, getSecurityPrincipal, getVersionEffectiveDate, resetConfiguration, setConfiguration, setCore, setupSystemProperties, setVersionEffectiveDate
 
Methods inherited from class junit.framework.TestCase
countTestCases, getName, run, run, runBare, 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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestCoreHibernatePersistence

public TestCoreHibernatePersistence(java.lang.String name)
Constructs a test case with the given name.

Method Detail

suite

public static junit.framework.Test suite()

main

public static void main(java.lang.String[] args)

testHibernateCreateDirectAccess

public void testHibernateCreateDirectAccess()
                                     throws java.lang.Exception
Throws:
java.lang.Exception

testHibernateCreateFailPredifnedSerialVersion

public void testHibernateCreateFailPredifnedSerialVersion()
                                                   throws java.lang.Exception
Throws:
java.lang.Exception

testHibernateCreateSuccess

public void testHibernateCreateSuccess()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testHibernateCreateFailMissingObject

public void testHibernateCreateFailMissingObject()
                                          throws java.lang.Exception
Throws:
java.lang.Exception

testHibernateUpdateSuccess

public void testHibernateUpdateSuccess()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testHibernateUpdateFailWrongSerialVersion

public void testHibernateUpdateFailWrongSerialVersion()
                                               throws java.lang.Exception
  1. Create a record
  2. Update the record
  3. Update the record using the same serialVersionId - this update should fail

Throws:
java.lang.Exception

testHibernateUpdateFailMissingObject

public void testHibernateUpdateFailMissingObject()
                                          throws java.lang.Exception
Test direct access to the validator

Throws:
java.lang.Exception

testHibernateLoadSuccess

public void testHibernateLoadSuccess()
                              throws java.lang.Exception
Test that a persisted object can be retrieved using the Load service.
  1. Create an instance of TestCoreHibernatePersistenceTestObject (id=1, value="Test Object")
  2. Persist the instance (Using the TestCreateService).
  3. Create an instance of the TestLoadService command.
  4. Set the command to locate an instance of TestCoreHibernatePersistenceTestObject with an id of 32.
  5. Invoke the command.
  6. Check that the result returned is an instance of TestCoreHibernatePersistenceTestObject
  7. Check that the result has an id of 32
  8. Check that the result has a value of "Test Object"
  9. Fail if any checks fail
  10. Fail if any exceptions are thrown

Throws:
java.lang.Exception

testHibernateQuerySuccess

public void testHibernateQuerySuccess()
                               throws java.lang.Exception
Test that a persisted object can be retrieved using the Query service.
  1. Create an instance of TestCoreHibernatePersistenceTestObject (id=1, value="Test Object")
  2. Persist the instance (Using the TestCreateService).
  3. Create an instance of the TestLoadService command.
  4. Set the command to locate an instance of TestCoreHibernatePersistenceTestObject with an id of 32.
  5. Invoke the command.
  6. Check that the result returned is an instance of TestCoreHibernatePersistenceTestObject
  7. Check that the result has an id of 32
  8. Check that the result has a value of "Test Object"
  9. Fail if any checks fail
  10. Fail if any exceptions are thrown

Throws:
java.lang.Exception

testCorePersistenceMethods

public void testCorePersistenceMethods()
                                throws java.lang.Exception
The Core exposes persistence methods in an easy-to-use form. This test runs through some simple scenarios using those methods.

Throws:
java.lang.Exception

testAttributesWithinAttributes

public void testAttributesWithinAttributes()

testDeepTypeHierarchy

public void testDeepTypeHierarchy()
Test the persistence of a deep hierarchy. Actually not all that deep, but deep enough to proove the point. The configure system defines a class hierarchy which is used to hold configurations. It's more or less a copy-book implementation of the composite pattern. We'll play with two types here: Parameter and Group; Both extend Component, and Component extends Type in common with all other model types in the system. Group contains a list of Parameters, and a list of Groups.
  1. Create an in memory instance of a Group, with on Parameter in it.
  2. Create a persistence session, store the instance, get it's id, close the session.
  3. Create a new session, load the object using it's id, check the content of the instance, close the session.
  4. Create another session, load the object again, and delete it, then close the session
  5. Create a session, try to load the object using it's id again and try to check it's content. close the session. Fail if this works!
  6. Fail if any exceptions are thrown from the above steps (except the last one).


testHibernateRemoteCreateSuccess

public void testHibernateRemoteCreateSuccess()
                                      throws java.lang.Exception
Throws:
java.lang.Exception