|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.castor.xmlctf.XMLTestCase
public abstract class XMLTestCase
This class encapsulates all the common logic to run the test patterns for Castor XML. Basically it handle the marshalling/marshalling/comparing. This is used to factor the common code for the source generator test and the mapping/introspection tests as only the setup differ in the test patterns.
This class is not complete and expects to be extended.
Field Summary | |
---|---|
protected org.exolab.castor.tests.framework.testDescriptor.Configuration |
_configuration
The Configuration the Marshalling Framework. |
protected org.exolab.castor.tests.framework.testDescriptor.FailureType |
_failure
The failure object that is not null if the test is expected to fail. |
protected boolean |
_hasDump
If true, the dumpFields() function has been implemented in the root class. |
protected java.lang.Object |
_listener
A listener for marshalling. |
protected java.lang.String |
_listenerGoldFile
Gold file for listener. |
protected org.exolab.castor.tests.framework.testDescriptor.types.TypeType |
_listenerType
Type of listener test -- Marshal, Unmarshal or Both. |
protected Mapping |
_mapping
The name of the mapping file to use in a Marshalling Framework Test Case. |
protected java.lang.String |
_name
Name of this test. |
protected java.io.File |
_outputRootFile
Place where the temporary file have to be put. |
protected static boolean |
_printStack
True if we dump the stack trace for any exception that occurs during testing. |
protected java.lang.Class |
_rootClass
The root class for this test. |
protected java.lang.String |
_rootClassName
The name of the root class for this test. |
protected boolean |
_skip
True if the test needs to be skipped. |
protected java.lang.String |
_suiteName
Name of the test suite to which this test belongs. |
protected CastorTestCase |
_test
Used only to retrieve the classloader. |
protected org.exolab.castor.tests.framework.testDescriptor.UnitTestCase |
_unitTest
The unit test case this class represent. |
static boolean |
_verbose
True if we desire a lot of info on what happen. |
Constructor Summary | |
---|---|
XMLTestCase(CastorTestCase test,
org.exolab.castor.tests.framework.testDescriptor.UnitTestCase unit)
Instantiates a new test case that represents the given UnitTestCase. |
|
XMLTestCase(java.lang.String name)
Instantiate a new XMLTestCase with the given name. |
|
XMLTestCase(java.lang.String name,
XMLTestCase tc)
Instantiates a new test cases that has the same configuration of the given test case. |
Method Summary | |
---|---|
protected java.lang.Object |
buildObjectModel(java.lang.String builderName)
Returns an instance of the object model hardcoded in the given ObjectModelBuilder. |
protected boolean |
checkExceptionWasExpected(java.lang.Exception exception,
org.exolab.castor.tests.framework.testDescriptor.types.FailureStepType checkStep)
Called when a test case throws an Exception. |
java.lang.String |
getTestSuiteName()
Returns the name of the test suite to which this test case belongs to. |
XMLContext |
getXMLContext()
|
protected void |
initializeListeners(org.exolab.castor.tests.framework.testDescriptor.ListenerType listener)
Initialize listeners for marshalling/unmarshalling |
protected java.util.List |
invokeEnumeratedMethods(java.lang.Object objectInvoked,
org.exolab.castor.tests.framework.testDescriptor.ConfigurationType config)
Invokes all requested methods on the object we are supplied. |
void |
setTestSuiteName(java.lang.String suiteName)
Sets the name of the test suite to which this test case belongs to. |
protected abstract void |
setUp()
|
void |
setXMLContext(XMLContext xmlContext)
|
protected abstract void |
tearDown()
|
protected java.io.File |
testMarshal(java.lang.Object object,
java.lang.String fileName)
Marshals the object with the configuration of the test. |
protected java.lang.Object |
testUnmarshal(java.io.File file)
Unmarshals the given file with the configuration of that test. |
protected java.lang.Object |
testUnmarshal(java.io.InputStream stream)
Unmarshals the given input stream with the configuration of that test. |
protected void |
verbose(java.lang.String message)
print the message if in verbose mode. |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, runTest, 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, failNotEquals, failNotSame, failSame |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static boolean _verbose
protected static boolean _printStack
protected java.lang.String _suiteName
protected java.lang.String _rootClassName
protected java.lang.Class _rootClass
protected boolean _hasDump
protected Mapping _mapping
protected java.lang.Object _listener
protected org.exolab.castor.tests.framework.testDescriptor.types.TypeType _listenerType
protected java.lang.String _listenerGoldFile
protected org.exolab.castor.tests.framework.testDescriptor.Configuration _configuration
protected final java.lang.String _name
protected final org.exolab.castor.tests.framework.testDescriptor.UnitTestCase _unitTest
protected final java.io.File _outputRootFile
protected final boolean _skip
protected final org.exolab.castor.tests.framework.testDescriptor.FailureType _failure
protected final CastorTestCase _test
Constructor Detail |
---|
public XMLTestCase(java.lang.String name)
name
- the name of this test case.public XMLTestCase(CastorTestCase test, org.exolab.castor.tests.framework.testDescriptor.UnitTestCase unit)
test
- the reference to the jar/directoryunit
- the UnitTestCase that wraps the configuration for this XML Test case.public XMLTestCase(java.lang.String name, XMLTestCase tc)
name
- the name of the test casetc
- the XML test case that hold the configuration for this test caseMethod Detail |
---|
protected abstract void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
protected abstract void tearDown() throws java.lang.Exception
tearDown
in class junit.framework.TestCase
java.lang.Exception
public void setXMLContext(XMLContext xmlContext)
public XMLContext getXMLContext()
public void setTestSuiteName(java.lang.String suiteName)
suiteName
- the name of the test suite.public java.lang.String getTestSuiteName()
protected boolean checkExceptionWasExpected(java.lang.Exception exception, org.exolab.castor.tests.framework.testDescriptor.types.FailureStepType checkStep)
exception
- the Exception that was throwncheckStep
- the test step that threw an Exception
protected java.io.File testMarshal(java.lang.Object object, java.lang.String fileName)
object
- the object to marshall.fileName
- the name of the file where to marshall the object.
protected java.lang.Object testUnmarshal(java.io.File file) throws java.lang.Exception
file
- the file containing the xml document to unmarshall.
java.lang.Exception
- if anything goes wrong during the testprotected java.lang.Object testUnmarshal(java.io.InputStream stream) throws java.lang.Exception
stream
- the input stream containing the xml document to unmarshall.
java.lang.Exception
- if anything goes wrong during the testprotected java.util.List invokeEnumeratedMethods(java.lang.Object objectInvoked, org.exolab.castor.tests.framework.testDescriptor.ConfigurationType config) throws java.lang.Exception
objectInvoked
- the object on which to invoke the methodsconfig
- configuration object listing the methods we are to call
java.lang.Exception
- if anything goes wrong during the testprotected void initializeListeners(org.exolab.castor.tests.framework.testDescriptor.ListenerType listener) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException
listener
- the listener to initialize
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
protected java.lang.Object buildObjectModel(java.lang.String builderName) throws java.lang.Exception
builderName
- the name of the class used as a builder
java.lang.Exception
- if anything goes wrong during the testprotected void verbose(java.lang.String message)
message
- the message to print
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |