com.ail.coretest
Class TestCoreXMLMapping

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

public class TestCoreXMLMapping
extends junit.framework.TestCase
implements CoreUser, ConfigurationOwner

Test the core system's XML data mapping facilities.

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

Constructor Summary
TestCoreXMLMapping(java.lang.String name)
          Constructs a test case with the given name.
 
Method Summary
 Configuration getConfiguration()
          Method demanded by the ConfigurationOwner interface.
 java.lang.String getConfigurationNamespace()
          Method demanded by the ConfigurationOwner interface.
 java.security.Principal getSecurityPrincipal()
          Get the security principal associated with this instance.
 VersionEffectiveDate getVersionEffectiveDate()
          Method demanded by the CoreUser interface.
static void main(java.lang.String[] args)
           
 void resetConfiguration()
          Method demanded by the ConfigurationOwner interface.
 void setConfiguration(Configuration config)
          Method demanded by the ConfigurationOwner interface.
 void setConfigurationNamespace(java.lang.String configurationNamespace)
           
static junit.framework.Test suite()
           
 void testEmbeddedObject()
          Test to ensure that nested types marshal as expected.
 void testSimpleFromXML()
          Test the fromXml service with a simple object.
 void testSimpleToXML()
          Ensure that a simple object can be converted into XML.
 void testSimpleToXMLPerformance()
          Run a simple performace test on the toXml service.
 
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

TestCoreXMLMapping

public TestCoreXMLMapping(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)

getVersionEffectiveDate

public VersionEffectiveDate getVersionEffectiveDate()
Method demanded by the CoreUser interface.

Specified by:
getVersionEffectiveDate in interface CoreUser
Returns:
A date to use to selecte the corrent version of config info.

getSecurityPrincipal

public java.security.Principal getSecurityPrincipal()
Get the security principal associated with this instance.

Specified by:
getSecurityPrincipal in interface CoreUser
Returns:
The associated security principal - if defined, null otherwise.

setConfiguration

public void setConfiguration(Configuration config)
Method demanded by the ConfigurationOwner interface.

Specified by:
setConfiguration in interface ConfigurationOwner
Parameters:
config - Configuration to use from now on.

getConfiguration

public Configuration getConfiguration()
Method demanded by the ConfigurationOwner interface.

Specified by:
getConfiguration in interface ConfigurationOwner
Returns:
The current configuration (at versionEffectiveDate).

getConfigurationNamespace

public java.lang.String getConfigurationNamespace()
Method demanded by the ConfigurationOwner interface.

Specified by:
getConfigurationNamespace in interface CoreUser
Returns:
The configuration namespace we're using

setConfigurationNamespace

public void setConfigurationNamespace(java.lang.String configurationNamespace)

resetConfiguration

public void resetConfiguration()
Method demanded by the ConfigurationOwner interface.

Specified by:
resetConfiguration in interface ConfigurationOwner

testSimpleToXML

public void testSimpleToXML()
                     throws java.lang.Exception
Ensure that a simple object can be converted into XML. The XML databinding facilities of the core allow the mapping of XML to/ from objects to be defined. This test ensures that ToXML'ing an instance of Version generated the correct results.
  1. Use the factory to create an instance of Version
  2. Pass version into the core's toXml server
  3. Compare the string returned from the service with a hard coded sample.
  4. Fail if any exceptions are thrown.

Throws:
java.lang.Exception

testSimpleToXMLPerformance

public void testSimpleToXMLPerformance()
                                throws java.lang.Exception
Run a simple performace test on the toXml service. This test ensures that the toXml service responds in a reasonable time.
  1. Create an instance of a Version object.
  2. Invoke the core's toXml service once to load classes etc.
  3. Record the start time
  4. Invoke the service 100 times with the same object.
  5. Record the end time
  6. Calculate the time taken for each call.
  7. Fail if the time is > 2ms
  8. Fail if any exceptions are thrown.

Throws:
java.lang.Exception

testSimpleFromXML

public void testSimpleFromXML()
                       throws java.lang.Exception
Test the fromXml service with a simple object.
  1. Create a hard coded string representing a valid Version object.
  2. Pass the string into the FromXml service.
  3. Fail if the object returned is not an instance of Version.
  4. Fail if the values of properties on the instance don't match those defined in the hard coded string.

Throws:
java.lang.Exception

testEmbeddedObject

public void testEmbeddedObject()
                        throws java.lang.Exception
Test to ensure that nested types marshal as expected.
  1. Create an instance of History, and of a Version
  2. Populate Version with test data
  3. Add Version to History
  4. Pass the History object into core.toXML()
  5. Fail if any of Version's populated fields fail to appear in the result
  6. Fail if any exception occure
    1. Throws:
      java.lang.Exception