junit.extensions.xml
Class XMLTestSuite

java.lang.Object
  extended byjunit.framework.TestSuite
      extended byjunit.extensions.xml.XMLTestSuite
All Implemented Interfaces:
IXMLTest, IXMLTestSuite, junit.framework.Test, XMLConstants
Direct Known Subclasses:
XMLRoot

public class XMLTestSuite
extends junit.framework.TestSuite
implements IXMLTestSuite, XMLConstants

Test Case for running XML Script based testing.

Author:
Kevin Wilson

Field Summary
private  org.w3c.dom.Element m_element
          Element for this test suite.
private  java.lang.String m_fileName
          The name of the test xml script file - found from the classpath.
private  IXMLTest m_parent
          Parent Test Suite.
private  XMLObjectCache m_procedures
          Collection of valid procedures for the test case.
private  XMLPropertyCache m_propertyCache
          Object cahce used to hold globals set by the test case.
 
Fields inherited from class junit.framework.TestSuite
 
Fields inherited from interface junit.extensions.xml.XMLConstants
ACTION, ACTUALOBJ, ACTUALREFID, ADD, ASSERTENABLED, ASSERTEQUALS, ASSERTNOTEQUALS, ASSERTNOTNULL, ASSERTNOTSAME, ASSERTNULL, ASSERTSAME, CALL, CASE, CHOOSE, CLASSNAME, COLUMN, CONFIRM, DEBUG, DEFAULT, DELIMITER, DIALOG, DUMP, ECHO, ENABLED, ENCODING, EVALUATE, EXPECTEDOBJ, EXPECTEDREFID, FAIL, FILE, FOCUS, FOREACH, ID, INDEX, JFCFILELOC, LESSTHAN, LISTITEM, LOG, MARK, MESSAGE, METHOD, MODE, NAME, OTHERWISE, PATHREFID, PROCEDURE, PROPERTY, RECURSIVE, REFID, RELATIVE, REMOVE, ROW, SAVE, STDERR, STDOUT, STOPWATCH, SUITE, SWITCH, TABLECELL, TAGHANDLERS, TAGNAME, TEST, TYPE, USERE, VALUE, WHEN, WHILE
 
Constructor Summary
XMLTestSuite()
          A no-argument constructor to support junit 3.8.
XMLTestSuite(java.lang.String fileName)
          A constructor accepting the name of the test script file.
XMLTestSuite(java.lang.String fileName, org.w3c.dom.Element element)
          A constructor accepting the name of the test script file and the element to be processed.
XMLTestSuite(java.lang.String name, java.io.InputStream stream)
          A constructor accepting the name of the test script file.
 
Method Summary
 void addFile(java.lang.String xmlFileName)
          Add the given XML file to the TestSuite.
 void addProcedure(IXMLProcedure proc)
          Add a procedure to the test suite.
 void addProperty(java.lang.String name, java.lang.Object value)
          Adds a found object to the cache.
 void addTest(junit.framework.Test test)
          Add a test to the test suite.
 void clearProperties()
          Clear the properties.
 boolean getDebug()
          Get the debug state.
 java.lang.String getFileName()
          Returns the filename.
 IXMLProcedure getProcedure(java.lang.String name)
          Get the procedure by the given name.
 XMLObjectCache getProcedureCache()
          Get the procedure cache.
 java.lang.Object getProperty(java.lang.String name)
          Get the value of a property.
 XMLObjectCache getPropertyCache()
          Get the found object cache.
 java.lang.String getPropertyName(java.lang.Object value)
          Reverse lookup the property name from the value of the property.
 java.lang.String[] getPropertyNames()
          Get the property names.
private  void processChildren(org.w3c.dom.Element e)
          Process the children of the test suite.
 void removeProperty(java.lang.String name)
          Remove a property.
 java.lang.String resolveProperties(java.lang.String s)
          Resolve embeded property names withing a string.
 void setParent(IXMLTest parent)
          Set the parent of this test case.
 
Methods inherited from class junit.framework.TestSuite
addTestSuite, countTestCases, createTest, getName, getTestConstructor, run, runTest, setName, testAt, testCount, tests, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface junit.framework.Test
countTestCases, run
 

Field Detail

m_element

private org.w3c.dom.Element m_element
Element for this test suite.


m_parent

private IXMLTest m_parent
Parent Test Suite.


m_fileName

private java.lang.String m_fileName
The name of the test xml script file - found from the classpath.


m_procedures

private final XMLObjectCache m_procedures
Collection of valid procedures for the test case.


m_propertyCache

private XMLPropertyCache m_propertyCache
Object cahce used to hold globals set by the test case.

Constructor Detail

XMLTestSuite

public XMLTestSuite()
A no-argument constructor to support junit 3.8.


XMLTestSuite

public XMLTestSuite(java.lang.String fileName)
A constructor accepting the name of the test script file.

Parameters:
fileName - The name of the test script file (found from the classpath)

XMLTestSuite

public XMLTestSuite(java.lang.String name,
                    java.io.InputStream stream)
A constructor accepting the name of the test script file.

Parameters:
name - A dummy name for the file
stream - The contents of the test script file

XMLTestSuite

public XMLTestSuite(java.lang.String fileName,
                    org.w3c.dom.Element element)
A constructor accepting the name of the test script file and the element to be processed.

Parameters:
fileName - The name of the test script file (found from the classpath)
element - The element to be processed.
Method Detail

getDebug

public boolean getDebug()
Get the debug state.

Specified by:
getDebug in interface IXMLTest
Returns:
true if debug is enabled.

setParent

public final void setParent(IXMLTest parent)
Set the parent of this test case.

Specified by:
setParent in interface IXMLTest
Parameters:
parent - Parent test.

getFileName

public java.lang.String getFileName()
Returns the filename.

Specified by:
getFileName in interface IXMLTestSuite
Returns:
String The name of the test xml script file

getProcedure

public IXMLProcedure getProcedure(java.lang.String name)
Get the procedure by the given name.

Specified by:
getProcedure in interface IXMLTest
Parameters:
name - The name of the procedure to be returned.
Returns:
XMLProcedure matching the name or null if it does not exist.

getProcedureCache

public XMLObjectCache getProcedureCache()
Get the procedure cache.

Specified by:
getProcedureCache in interface IXMLTest
Returns:
procedure cache for this test case.

getProperty

public java.lang.Object getProperty(java.lang.String name)
Get the value of a property.

Specified by:
getProperty in interface IXMLTest
Parameters:
name - Name of the property to be returned.
Returns:
Value of the property.

getPropertyCache

public XMLObjectCache getPropertyCache()
Get the found object cache.

Specified by:
getPropertyCache in interface IXMLTest
Returns:
Object cache for this test case.

getPropertyName

public java.lang.String getPropertyName(java.lang.Object value)
Reverse lookup the property name from the value of the property.

Specified by:
getPropertyName in interface IXMLTest
Parameters:
value - Value to be looked up.
Returns:
First property with the same value.

getPropertyNames

public java.lang.String[] getPropertyNames()
Get the property names.

Specified by:
getPropertyNames in interface IXMLTest
Returns:
Get a array of property names

addFile

public void addFile(java.lang.String xmlFileName)
Add the given XML file to the TestSuite.

Specified by:
addFile in interface IXMLTestSuite
Parameters:
xmlFileName - The name of the test script file to be added.

addProcedure

public void addProcedure(IXMLProcedure proc)
Add a procedure to the test suite.

Specified by:
addProcedure in interface IXMLTest
Parameters:
proc - Procedure to be added.

addProperty

public void addProperty(java.lang.String name,
                        java.lang.Object value)
Adds a found object to the cache.

Specified by:
addProperty in interface IXMLTest
Parameters:
name - Name of the object.
value - Value of the object.

addTest

public void addTest(junit.framework.Test test)
Add a test to the test suite.

Specified by:
addTest in interface IXMLTestSuite
Parameters:
test - Test to be added.

clearProperties

public void clearProperties()
Clear the properties.

Specified by:
clearProperties in interface IXMLTest

removeProperty

public void removeProperty(java.lang.String name)
Remove a property.

Specified by:
removeProperty in interface IXMLTest
Parameters:
name - Name of the property to be removed.

resolveProperties

public java.lang.String resolveProperties(java.lang.String s)
Resolve embeded property names withing a string.

Specified by:
resolveProperties in interface IXMLTest
Parameters:
s - String to be resolved.
Returns:
String without property names.

processChildren

private void processChildren(org.w3c.dom.Element e)
Process the children of the test suite.

Parameters:
e - Element which contains the children to be processed.


Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999