com.ail.coretest
Class TestCoreXMLBinding

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

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

The tests defined here exercise the Core system's factory. They use the Core class as a Service or core client would. Note: These tests assume that the JDBCConfigurationLoader is being used.

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

Constructor Summary
TestCoreXMLBinding(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 testAttributeInAttributeXpathTest()
          Test how stacked attributes are interpreted and that xpath works on them.
 void testSimpleFromXML()
          Check that the core corrently converts a string of XML into the corresponding object.
 void testSimpleToXML()
          This text checks that XMLBinding correctly converts an object into an XMLString.
 void testXsiTypeDetection()
          The XMLString class offers some help in determining the java type represented by an XML string - assuming that string has an xsi:type attribute in the root element.
 
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

TestCoreXMLBinding

public TestCoreXMLBinding(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()
This text checks that XMLBinding correctly converts an object into an XMLString.
  1. Create an instance of 'Version', and populate it with values.
  2. Convert the version object into XML using the core.
  3. Check the resulting XML against a hard coded result.
  4. Fail if the strings do not match.
  5. Fail if any exceptions are thrown.


testSimpleFromXML

public void testSimpleFromXML()
Check that the core corrently converts a string of XML into the corresponding object.


testXsiTypeDetection

public void testXsiTypeDetection()
                          throws java.lang.Exception
The XMLString class offers some help in determining the java type represented by an XML string - assuming that string has an xsi:type attribute in the root element. These tests check that the detection is working correctly.

Throws:
java.lang.Exception

testAttributeInAttributeXpathTest

public void testAttributeInAttributeXpathTest()
                                       throws java.lang.Exception
Test how stacked attributes are interpreted and that xpath works on them. The Type class has the notion of attributes - i.e. a collection of name value pairs what may itself contain other sub-collections. This test checks that these nested attribute collections can be converted from String to type, and that the type can be XPath'ed.
  1. Create an XML string representing a type (Version will do) containing attributes
  2. Use the core's fromXML method to translate the string into an instance of Version
  3. Use XPath queries to return attribute value and check them to be correct
  4. Fail if any exceptions are thrown
  5. Fail if any of the value are not correct

Throws:
java.lang.Exception