junit.extensions.jfcunit.xml
Class XMLRecorder

java.lang.Object
  extended byjunit.extensions.xml.elements.AbstractTagHandler
      extended byjunit.extensions.xml.elements.SaveTagHandler
          extended byjunit.extensions.jfcunit.xml.XMLRecorder
All Implemented Interfaces:
EventDataConstants, java.util.EventListener, JFCEventDataListener, JFCXMLConstants, XMLConstants

public class XMLRecorder
extends SaveTagHandler
implements JFCEventDataListener, JFCXMLConstants

Title: class XMLRecorder.

Description:

Copyright: Copyright (c) 2002

Company: Hewlett-Packard Company

Version:
1.0 Attributes: terminator=8 sets the terminator to ctrl-h improved parsing to be added later.
Author:
Kevin Wilson

Field Summary
private  int m_compIndex
          Index of next generated component.
private  org.w3c.dom.Document m_doc
          Document of the recording.
private  java.lang.String m_indent
          Indent string for each node.
private  boolean m_paused
          Paused State.
private  org.w3c.dom.Element m_root
          Root element of the recording.
private  JFCKeyStroke[] m_terminator
          Terminator keystroke.
private static boolean s_replay
          Replay mode.
 
Fields inherited from class junit.extensions.xml.elements.AbstractTagHandler
 
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
XMLRecorder(org.w3c.dom.Element element, IXMLTestCase testCase)
          Constructor for the XML Recorder.
 
Method Summary
 java.lang.String generateFind(java.awt.Component comp)
          Generate the finder node(s) to find the component.
private  java.lang.String generateMenuFind(java.awt.Component comp)
          Generate the XML elements to locate a menu item.
private  java.lang.String generateWindowFind(java.awt.Component w)
          Generate the XML Nodes to find the window given.
private  int getComponentIndex()
          Get the component index.
protected  JFCKeyStroke[] getDefaultTerminator()
          Get the default terminator.
 JFCKeyStroke[] getTerminator()
          Get the current record Terminator.
 void handleEvent(AbstractEventData evtData)
          Handle the event data by generating XML.
private  void insertNode(org.w3c.dom.Node e)
          Insert the node into the tree.
private  void pause()
          Pause the recording.
 void processElement()
          Save the data to the filename given.
private  void record()
          Start the recording.
static void setReplay(boolean value)
          If the replay mode is set then the record elements are ignored.
 void setTerminator(JFCKeyStroke[] stroke)
          Set the terminator to be used to end the recording session.
private  void stop()
          Stop the recording.
 void validateElement()
          Insure that the file attribute is specified.
 
Methods inherited from class junit.extensions.xml.elements.SaveTagHandler
 
Methods inherited from class junit.extensions.xml.elements.AbstractTagHandler
checkAtLeastOneRequiredAttribute, checkAtLeastOneRequiredAttribute, checkElementTagName, checkOneRequiredAttribute, checkOneRequiredAttribute, checkRequiredAttribute, checkRequiredAttribute, getBoolean, getBoolean, getBoolean, getBoolean, getElement, getInt, getInt, getLong, getLong, getPoint, getPoint, getString, getString, getString, getString, getTagName, getTest, getTestCase, getXMLTestCase, getXMLTestSuite, resolveVariables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_replay

private static boolean s_replay
Replay mode.


m_doc

private org.w3c.dom.Document m_doc
Document of the recording.


m_root

private org.w3c.dom.Element m_root
Root element of the recording.


m_indent

private java.lang.String m_indent
Indent string for each node.


m_terminator

private JFCKeyStroke[] m_terminator
Terminator keystroke.


m_paused

private volatile boolean m_paused
Paused State.


m_compIndex

private int m_compIndex
Index of next generated component.

Constructor Detail

XMLRecorder

public XMLRecorder(org.w3c.dom.Element element,
                   IXMLTestCase testCase)
Constructor for the XML Recorder.

Parameters:
element - element to be recorded.
testCase - Test Case for the recording.
Method Detail

setReplay

public static void setReplay(boolean value)
If the replay mode is set then the record elements are ignored.

Parameters:
value - true if the record elements are to be ignored.

setTerminator

public void setTerminator(JFCKeyStroke[] stroke)
Set the terminator to be used to end the recording session.

Parameters:
stroke - Stroke to end the recording.

getTerminator

public JFCKeyStroke[] getTerminator()
Get the current record Terminator.

Returns:
JFCKeyStroke which terminates the session.

generateFind

public java.lang.String generateFind(java.awt.Component comp)
Generate the finder node(s) to find the component.

Parameters:
comp - Component to be found.
Returns:
Name of the component.

handleEvent

public void handleEvent(AbstractEventData evtData)
Handle the event data by generating XML.

Specified by:
handleEvent in interface JFCEventDataListener
Parameters:
evtData - event date generated.

processElement

public void processElement()
                    throws XMLException
Description copied from class: SaveTagHandler
Save the data to the filename given.

Overrides:
processElement in class SaveTagHandler
Throws:
XMLException - is thrown if the element cannot be understood.
See Also:
AbstractTagHandler.processElement().

validateElement

public void validateElement()
                     throws XMLException
Description copied from class: SaveTagHandler
Insure that the file attribute is specified.

Overrides:
validateElement in class SaveTagHandler
Throws:
XMLException - if the required elements are not present.
See Also:
AbstractTagHandler.validateElement().

getDefaultTerminator

protected JFCKeyStroke[] getDefaultTerminator()
Get the default terminator.

Returns:
JFCKeyStroke used to terminate the record session.

getComponentIndex

private int getComponentIndex()
Get the component index.

Returns:
int index of component.

generateMenuFind

private java.lang.String generateMenuFind(java.awt.Component comp)
Generate the XML elements to locate a menu item.

Parameters:
comp - Component to be located.
Returns:
Name of the component.

generateWindowFind

private java.lang.String generateWindowFind(java.awt.Component w)
Generate the XML Nodes to find the window given.

Parameters:
w - Window to be located.
Returns:
Name of the window.

insertNode

private void insertNode(org.w3c.dom.Node e)
Insert the node into the tree.

Parameters:
e - The node to be inserted.

pause

private void pause()
Pause the recording.


record

private void record()
Start the recording.


stop

private void stop()
Stop the recording.



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