junit.extensions.jfcunit.xml
Class JFCXMLTestCase

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byjunit.extensions.jfcunit.JFCTestCase
              extended byjunit.extensions.jfcunit.xml.JFCXMLTestCase
All Implemented Interfaces:
EventDataConstants, IXMLTest, IXMLTestCase, JFCXMLConstants, junit.framework.Test, XMLConstants

public class JFCXMLTestCase
extends JFCTestCase
implements IXMLTestCase, JFCXMLConstants

This class will handle the processing of <test> nodes.

Description

This tag handler invokes the test case given.

Attributes

Attribute Description Required Default Values
name name of the test case Yes N/A Alpha Numeric Name
robot Use a robot or send events directly to AWT Event queue. No false true if events are to be sent via the Robot
assertexit Assert the System.exit() command, ExitException will be thrown by the security manager and the application will not exit. No false true if the system exist should be asserted.

Example

 <test name="Login">
 ...
 </test>
 <test name="Logout" assertexit="true">
 ...
 </test>
 

The above runs the defined testcase.

Author:
Kevin Wilson

Nested Class Summary
 
Nested classes inherited from class junit.extensions.jfcunit.JFCTestCase
 
Field Summary
private  org.w3c.dom.Element m_element
          The element to be processed.
private  java.lang.String m_filename
          The name of the test xml script file - found from the classpath.
private  junit.framework.Test m_parent
          Parent test case.
private  XMLObjectCache m_procedures
          Map of procedures.
private  XMLObjectCache m_properties
          A Map of all objects that have been found - keyed by the string name.
 
Fields inherited from class junit.extensions.jfcunit.JFCTestCase
 
Fields inherited from class junit.framework.TestCase
 
Fields inherited from interface junit.extensions.jfcunit.xml.JFCXMLConstants
ALT, ALTGR, AMOUNT, ASSERTEXIT, AWTTHREAD, BUTTON1, BUTTON2, BUTTON3, CASEINDEPENDENT, CLASS, CLICK, CLICKS, CODE, CONTAINER, CONTAINS, CTRL, DESTINATION, DOWN, DRAG, DURATION, EDITOR, ENDSWITH, EQUALS, FIND, FINDER, FLUSH, ICONDESCRIPTION, ICONFILE, INDEXDELIMITER, INDEXES, KEY, LABEL, MATCH, META, MODIFIERS, NODEVALUE, OPERATION, PATH, PATHDELIMITER, PAUSE, POINT, POPUPTRIGGER, POSITION, RECORDING, REFERENCE, RESUME, ROBOT, ROTATION, SHIFT, SHOW, SLEEP, SLEEPTIME, SOURCE, STARTSWITH, STRING, SUBCOMPONENT, TERMINATOR, TITLE, UP, WAIT
 
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
 
Fields inherited from interface junit.extensions.jfcunit.eventdata.EventDataConstants
CENTER, CUSTOM, DEFAULT_HOLDTIME, DEFAULT_ISPOPUPTRIGGER, DEFAULT_KEY_MODIFIERS, DEFAULT_MOUSE_MODIFIERS, DEFAULT_NUMBEROFCLICKS, DEFAULT_POPUP_MODIFIERS, DEFAULT_POSITION, DEFAULT_SCROLL_AMOUNT, DEFAULT_SLEEPTIME, DEFAULT_WHEEL_ROTATION, DOWN_ARROW_SUBCOMPONENT, EAST, EDITOR_SUBCOMPONENT, INVALID_SUBCOMPONENT, INVALID_TEXT_OFFSET, NORTH, NORTH_EAST, NORTH_WEST, OFFSET, PERCENT, POSITIONSTRINGS, SOUTH, SOUTH_EAST, SOUTH_WEST, UP_ARROW_SUBCOMPONENT, WEST
 
Constructor Summary
JFCXMLTestCase(java.lang.String filename, org.w3c.dom.Element element)
          The default constructor that is needed to createa a test case.
 
Method Summary
 void addProcedure(IXMLProcedure proc)
          Add a procedure to the test case.
 void addProperty(java.lang.String name, java.lang.Object obj)
          Add each found object into the cache map.
 void callProcedure(java.lang.String name, org.w3c.dom.Element callElement)
          Call the procedure with the given name.
 void clearProperties()
          For each test (method) element, the found objects has to be cleared.
 boolean getDebug()
          Get the debug state.
 IXMLProcedure getProcedure(java.lang.String name)
          Get the procedure withthe given name.
 XMLObjectCache getProcedureCache()
          Returns the cahce of procedures.
 java.lang.Object getProperty(java.lang.String name)
          Retrieve the object that was found previously.
 XMLObjectCache getPropertyCache()
          Get the property cache.
 java.lang.String getPropertyName(java.lang.Object comp)
          Get the name of a component which has been found.
 java.lang.String[] getPropertyNames()
          Get the names of the properties.
private  void loadProcedures(org.w3c.dom.Element element)
          Process the child XML elements.
 void processChildren(org.w3c.dom.Element element)
          Process the child XML elements.
 void removeProperty(java.lang.String name)
          Remove the property with the name given.
 java.lang.String resolveProperties(java.lang.String s)
          Resolve embeded property names withing a string.
protected  void runTest()
          Executes a test.
 void runXMLTest()
          This method is the one that actually performs the test by processing the elements.
 void setParent(IXMLTest parent)
          Set the parent test case.
protected  void setUp()
          Default setUp which does nothing.
static junit.framework.Test suite()
          Returns an empty suite.
protected  void tearDown()
          Default tearDown which does nothing.
 
Methods inherited from class junit.extensions.jfcunit.JFCTestCase
awtSleep, awtSleep, createNoExitSecurityManager, flushAWT, getAssertExit, getError, getHelper, getLockWait, hasError, isAWTRunning, pause, pauseAWT, resetError, resetForcedWait, resetSleepTime, resumeAWT, runBare, runCode, setAssertExit, setError, setForcedWait, setHelper, setLockWait, setSleepTime, sleep
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface junit.extensions.xml.IXMLTestCase
getName, setName
 
Methods inherited from interface junit.framework.Test
countTestCases, run
 

Field Detail

m_element

private org.w3c.dom.Element m_element
The element to be processed.


m_filename

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


m_parent

private junit.framework.Test m_parent
Parent test case.


m_procedures

private XMLObjectCache m_procedures
Map of procedures.


m_properties

private XMLObjectCache m_properties
A Map of all objects that have been found - keyed by the string name.

Constructor Detail

JFCXMLTestCase

public JFCXMLTestCase(java.lang.String filename,
                      org.w3c.dom.Element element)
The default constructor that is needed to createa a test case.

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

getDebug

public final boolean getDebug()
Get the debug state.

Specified by:
getDebug in interface IXMLTest
Returns:
boolean true if debugging has been enabled.

setParent

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

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

getProcedure

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

Specified by:
getProcedure in interface IXMLTest
Parameters:
name - Name of the procedure to return.
Returns:
IXMLProcedure referenced by name.

getProcedureCache

public final XMLObjectCache getProcedureCache()
Returns the cahce of procedures.

Specified by:
getProcedureCache in interface IXMLTest
Returns:
XMLObjectCache cache of procedures.

getProperty

public final java.lang.Object getProperty(java.lang.String name)
Retrieve the object that was found previously.

Specified by:
getProperty in interface IXMLTest
Parameters:
name - The name of the object that was found
Returns:
The object to be retrieved

getPropertyCache

public final XMLObjectCache getPropertyCache()
Get the property cache.

Specified by:
getPropertyCache in interface IXMLTest
Returns:
XMLObjectCache used to hold the properties.

getPropertyName

public final java.lang.String getPropertyName(java.lang.Object comp)
Get the name of a component which has been found.

Specified by:
getPropertyName in interface IXMLTest
Parameters:
comp - Component to locate
Returns:
The name of the component.

getPropertyNames

public final java.lang.String[] getPropertyNames()
Get the names of the properties.

Specified by:
getPropertyNames in interface IXMLTest
Returns:
array containing the names of the properties.

addProcedure

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

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

callProcedure

public final void callProcedure(java.lang.String name,
                                org.w3c.dom.Element callElement)
                         throws XMLException
Call the procedure with the given name.

Specified by:
callProcedure in interface IXMLTestCase
Parameters:
name - Name of the procedure.
callElement - Element which contains the attributes to be passed to the procedures.
Throws:
XMLException - is thrown if the element cannot be understood.

processChildren

public final void processChildren(org.w3c.dom.Element element)
                           throws XMLException
Process the child XML elements.

Specified by:
processChildren in interface IXMLTestCase
Parameters:
element - Element which contains the children to be processed.
Throws:
XMLException - may be thrown.

runXMLTest

public final void runXMLTest()
                      throws java.lang.Exception
This method is the one that actually performs the test by processing the elements.

Throws:
java.lang.Exception - An instance of java.lang.Exception can be thrown.

suite

public static junit.framework.Test suite()
                                  throws java.lang.Exception
Returns an empty suite.

Returns:
Test An empty XMLTestSuite is returned by default
Throws:
java.lang.Exception - An instance of java.lang.Exception can be thrown.

addProperty

public final void addProperty(java.lang.String name,
                              java.lang.Object obj)
Add each found object into the cache map.

Specified by:
addProperty in interface IXMLTest
Parameters:
name - The name of the found object
obj - The actual object that was found

clearProperties

public final void clearProperties()
For each test (method) element, the found objects has to be cleared.

Specified by:
clearProperties in interface IXMLTest

removeProperty

public final void removeProperty(java.lang.String name)
Remove the property with the name given.

Specified by:
removeProperty in interface IXMLTest
Parameters:
name - Name of the object 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.

setUp

protected void setUp()
              throws java.lang.Exception
Default setUp which does nothing. Override this to set up the environment for your test

Overrides:
setUp in class JFCTestCase
Throws:
java.lang.Exception - An instance of java.lang.Exception can be thrown
See Also:
TestCase.setUp()

runTest

protected void runTest()
                throws java.lang.Throwable
Executes a test.

Overrides:
runTest in class JFCTestCase
Throws:
java.lang.Throwable - exceptions thrown by code.

tearDown

protected void tearDown()
                 throws java.lang.Exception
Default tearDown which does nothing. Override this to tear down the environment for your test.

Overrides:
tearDown in class JFCTestCase
Throws:
java.lang.Exception - An instance of java.lang.Exception can be thrown
See Also:
TestCase.setUp()

loadProcedures

private void loadProcedures(org.w3c.dom.Element element)
                     throws XMLException
Process the child XML elements.

Parameters:
element - Element which contains the children to be processed.
Throws:
XMLException - is thrown if the element cannot be understood.


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