|
||||||||
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 Configuration |
_configuration
The Configuration the Marshalling Framework. |
protected 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 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 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,
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,
FailureStepType checkStep)
Called when a test case throws an Exception. |
(package private) static java.lang.String |
cleanup(java.lang.String name)
Returns a version of the input name that is suitable for JUnit test case or test suite use. |
java.lang.String |
getTestSuiteName()
Returns the name of the test suite to which this test case belongs to. |
protected void |
initializeListeners(ListenerType listener)
Initialize listeners for marshalling/unmarshalling |
protected java.util.List |
invokeEnumeratedMethods(java.lang.Object objectInvoked,
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 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, setUp, 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, 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 TypeType _listenerType
protected java.lang.String _listenerGoldFile
protected Configuration _configuration
protected final java.lang.String _name
protected final UnitTestCase _unitTest
protected final java.io.File _outputRootFile
protected final boolean _skip
protected final 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, 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 |
---|
static java.lang.String cleanup(java.lang.String name)
We also translate all whitespace to blanks, remove all leading and trailing whitespace, and collapse consecutive whitespace to a single blank.
name
- the input name
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, 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, 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(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 |