|
||||||||||
| 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 Object |
_listener
A listener for marshalling. |
protected 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 String |
_name
Name of this test. |
protected 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 Class |
_rootClass
The root class for this test. |
protected String |
_rootClassName
The name of the root class for this test. |
protected boolean |
_skip
True if the test needs to be skipped. |
protected 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(String name)
Instantiate a new XMLTestCase with the given name. |
|
XMLTestCase(String name,
XMLTestCase tc)
Instantiates a new test cases that has the same configuration of the given test case. |
|
| Method Summary | |
|---|---|
protected Object |
buildObjectModel(String builderName)
Returns an instance of the object model hardcoded in the given ObjectModelBuilder. |
protected boolean |
checkExceptionWasExpected(Exception exception,
FailureStepType checkStep)
Called when a test case throws an Exception. |
String |
getTestSuiteName()
Returns the name of the test suite to which this test case belongs to. |
XMLContext |
getXMLContext()
|
protected void |
initializeListeners(ListenerType listener)
Initialize listeners for marshalling/unmarshalling |
protected List |
invokeEnumeratedMethods(Object objectInvoked,
ConfigurationType config)
Invokes all requested methods on the object we are supplied. |
void |
setTestSuiteName(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 File |
testMarshal(Object object,
String fileName)
Marshals the object with the configuration of the test. |
protected Object |
testUnmarshal(File file)
Unmarshals the given file with the configuration of that test. |
protected Object |
testUnmarshal(InputStream stream)
Unmarshals the given input stream with the configuration of that test. |
protected void |
verbose(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, format |
| 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 String _suiteName
protected String _rootClassName
protected Class _rootClass
protected boolean _hasDump
protected Mapping _mapping
protected Object _listener
protected TypeType _listenerType
protected String _listenerGoldFile
protected Configuration _configuration
protected final String _name
protected final UnitTestCase _unitTest
protected final File _outputRootFile
protected final boolean _skip
protected final FailureType _failure
protected final CastorTestCase _test
| Constructor Detail |
|---|
public XMLTestCase(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(String name,
XMLTestCase tc)
name - the name of the test casetc - the XML test case that hold the configuration for this test case| Method Detail |
|---|
protected abstract void setUp()
throws Exception
setUp in class junit.framework.TestCaseException
protected abstract void tearDown()
throws Exception
tearDown in class junit.framework.TestCaseExceptionpublic void setXMLContext(XMLContext xmlContext)
public XMLContext getXMLContext()
public void setTestSuiteName(String suiteName)
suiteName - the name of the test suite.public String getTestSuiteName()
protected boolean checkExceptionWasExpected(Exception exception,
FailureStepType checkStep)
exception - the Exception that was throwncheckStep - the test step that threw an Exception
protected File testMarshal(Object object,
String fileName)
object - the object to marshall.fileName - the name of the file where to marshall the object.
protected Object testUnmarshal(File file)
throws Exception
file - the file containing the xml document to unmarshall.
Exception - if anything goes wrong during the test
protected Object testUnmarshal(InputStream stream)
throws Exception
stream - the input stream containing the xml document to unmarshall.
Exception - if anything goes wrong during the test
protected List invokeEnumeratedMethods(Object objectInvoked,
ConfigurationType config)
throws Exception
objectInvoked - the object on which to invoke the methodsconfig - configuration object listing the methods we are to call
Exception - if anything goes wrong during the test
protected void initializeListeners(ListenerType listener)
throws ClassNotFoundException,
IllegalAccessException,
InstantiationException
listener - the listener to initialize
ClassNotFoundException
IllegalAccessException
InstantiationException
protected Object buildObjectModel(String builderName)
throws Exception
builderName - the name of the class used as a builder
Exception - if anything goes wrong during the testprotected void verbose(String message)
message - the message to print
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||