qat.parser.qaxmlparser
Class QAXMLParser

java.lang.Object
  extended byqat.parser.qaxmlparser.QAXMLParser
All Implemented Interfaces:
ParserInterface

public class QAXMLParser
extends java.lang.Object
implements ParserInterface

* This file loads a single QAT file, and will attempt to resolve all keywords in this qat file * file by first including any .INC statements, and their parent statements etc, until all neccesary files * have been included. * * @author webhiker * @version 2.3, 17 June 1999 *


Constructor Summary
QAXMLParser()
           
 
Method Summary
 void finish()
          This method indicates we are finished with this parser, and disposes * any reserved resources.
 java.lang.String[] getIncludeList()
          This should return the list of files other than standard java.util.Properties files which were * included to parse this test file.
 java.lang.String[] getKeyWords()
          This method should return all keywords associated with this test.
 java.util.Properties getProperties()
          This method returns all the properties obtained by parsing this test file.
 java.lang.String[] getPropertiesIncludeList()
          This should return the list of standard java.util.Properties files which were * included to parse this test file.
 java.lang.String getProperty(java.lang.String key)
          This method retrieves the specified property from the results of parsing this file.
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          This method retrieves the specified property from the results of parsing this file
 java.lang.String[] getSyntaxKeyWords()
          This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting.
 java.lang.String getTestAuthor()
          This method should return a test Author which will be used to display the test in * the test tree.
 java.lang.String getTestBugInfo()
          This method should return a test BugInfo which will be used for displaying the test in * the test tree.
 java.lang.String getTestDescription()
          This method should return a test Description which will be used to display the test in * the test tree.
 java.lang.String getTestName()
          This method should return a test name which will be used to display the test in * the test tree.
 java.lang.String[] getTraceList()
          This method should list all available output files produced by this test when run on the agent, * but relative to the harness.
 boolean inEvaluationMode()
           
 void interrupt()
          This method is responsible for killing any processes already started on the agents, * and immediately halt parsing any files.
static void main(java.lang.String[] args)
           
 java.io.PrintStream openPrintStream(java.lang.String fileName)
          Returns a handle to the Printstream the parser will use for any output * resulting from parsing this test.
 int parseFile()
          This method parses the specified file
 void prepare(java.lang.String projectResultsDir)
          This is called at the beginning of a parser run on * one or more tests
 void printDebug(java.lang.String msg)
           
 void processCheckAgentNode(org.w3c.dom.Node checkAgentNode)
          This tag checks if an agent is running.
 void processCleanNode(org.w3c.dom.Node cleanNode)
          This task will retrieve the traces of an executed process.
 void processCleanZipNode(org.w3c.dom.Node cleanzipNode)
          This tag is the start point for a single unit test.
 void processEchoNode(org.w3c.dom.Node echoNode)
          This tag allows you to echo traces to the harness.
 void processLoopNode(org.w3c.dom.Node loopNode)
          This tag will loop all nested tasks until the while condition evaluates to true.
 void processPrintEnvNode(org.w3c.dom.Node printEnvNode)
          This tag will print out the current environment settings.
 void processPropertyNode(org.w3c.dom.Node propertyNode)
          This tag causes a propery to be set.
 void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode)
          This tag is the start point for a single unit test.
 void processReportNode(org.w3c.dom.Node reportNode)
          This tag causes a global property to be set.
 void processRequestAgentNode(org.w3c.dom.Node requestAgentNode)
          This tag is the start point for a single unit test.
 void processSendZipNode(org.w3c.dom.Node sendzipNode)
          This tag is the start point for a single unit test.
 void processSleepNode(org.w3c.dom.Node sleepNode)
          This tag will cause execution to sleep for the specified period of time.
 void processStartNode(org.w3c.dom.Node startNode)
          This tag is the start point for a single unit test.
 void processStatusNode(org.w3c.dom.Node statusNode)
          This task will retrieve the status of an executed process.
 void processTestNode(org.w3c.dom.Node testNode)
          This processTestNode is the start point for a single unit test.
 void processTraceNode(org.w3c.dom.Node traceNode)
          This task will retrieve the traces of an executed process.
 java.lang.StringBuffer resolveVariable(java.lang.StringBuffer expression)
           
 void setEvaluationMode(boolean mode)
          If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing.
 void setPrintStream(java.io.PrintStream printStream, boolean useHtml)
          This method sets the PrintStream to use for reporting errors * and other types of output from the script.
 void setProjectRoot(java.lang.String projectRoot)
          This method sets the path to root of the current project.
 void setProperties(java.util.Properties p)
          This method sets any default properties which will be required * for parsing this file.
 void setStatusLabel(javax.swing.JLabel status)
          This is the handle to to QAT parent GUI to display which commands * the parser is processing in real-time.
 void setTestPath(java.lang.String testPath)
          This method sets the path to file file containing the syntax * which will be parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QAXMLParser

public QAXMLParser()
Method Detail

setProjectRoot

public void setProjectRoot(java.lang.String projectRoot)
This method sets the path to root of the current project.

Specified by:
setProjectRoot in interface ParserInterface

getSyntaxKeyWords

public java.lang.String[] getSyntaxKeyWords()
This method lists all the keywords supported by this syntax, for use in * the Notepad syntax highlighting. It must be declared static.

Specified by:
getSyntaxKeyWords in interface ParserInterface

setTestPath

public void setTestPath(java.lang.String testPath)
This method sets the path to file file containing the syntax * which will be parsed.

Specified by:
setTestPath in interface ParserInterface

setPrintStream

public void setPrintStream(java.io.PrintStream printStream,
                           boolean useHtml)
This method sets the PrintStream to use for reporting errors * and other types of output from the script.

Specified by:
setPrintStream in interface ParserInterface

setProperties

public void setProperties(java.util.Properties p)
This method sets any default properties which will be required * for parsing this file.

Specified by:
setProperties in interface ParserInterface

getProperties

public java.util.Properties getProperties()
This method returns all the properties obtained by parsing this test file.

Specified by:
getProperties in interface ParserInterface

setEvaluationMode

public final void setEvaluationMode(boolean mode)
If set to true, the parser does not actually make contact with the agents * but merely simulates the agent responses to allow standalone parsing.

Specified by:
setEvaluationMode in interface ParserInterface

inEvaluationMode

public final boolean inEvaluationMode()

parseFile

public int parseFile()
              throws java.lang.Exception
This method parses the specified file. * If not in evaluation mode, it should return the status of the test run : * ProtocolConstants.PASSED * ProtocolConstants.FAILED * ProtocolConstants.NOTRUN * ProtocolConstants.UNRESOLVED

Specified by:
parseFile in interface ParserInterface
Throws:
java.lang.Exception

processTestNode

public void processTestNode(org.w3c.dom.Node testNode)
This processTestNode is the start point for a single unit test.
e.g. <test
name="test name"
author="test author"
description="this is a description of the test"
buginfo="any important bug information associated with this test"/>

Parameters:
testNode - an org.w3c.dom.Node value

processPrintEnvNode

public void processPrintEnvNode(org.w3c.dom.Node printEnvNode)
This tag will print out the current environment settings.
e.g. <printenv/>


processSleepNode

public void processSleepNode(org.w3c.dom.Node sleepNode)
This tag will cause execution to sleep for the specified period of time.
e.g. <sleep
onlyif="variable"
seconds="10"
minutes="0"
hours="0"/>
At least one of the attributes must be specified, any which are missing are assumed to be zero.


processPropertyNode

public void processPropertyNode(org.w3c.dom.Node propertyNode)
This tag causes a propery to be set.
Two forms may be used :
e.g. 1) <property name="mypropertyname" value="mypropertyvalue"/>
e.g. 2) <property name="mypropertyname" refid="${someotherproperty}"/>
which will first resolve the variable references, and then set the property.


processRequestAgentNode

public void processRequestAgentNode(org.w3c.dom.Node requestAgentNode)
This tag is the start point for a single unit test.
e.g. <requestagent
onlyif="variable" (optional)
agentid="agentid" (the id of the agent you want to use)
agentworkdir="workdir"/> (optional)


processReleaseAgentNode

public void processReleaseAgentNode(org.w3c.dom.Node releaseAgentNode)
This tag is the start point for a single unit test.
e.g. <releaseagent
onlyif="variable"
agentid="agentid"/>


processCheckAgentNode

public void processCheckAgentNode(org.w3c.dom.Node checkAgentNode)
This tag checks if an agent is running.
e.g. <checkagent
result="result"
agentid="1"/>
If the agent is found to be running, result will be set to "true", and all the agent properties will be then be available in the QAXML script. If there was a problem contacting the agent, result will be set to "false". When running in evaluation mode (e.g. when reparsing the file) the agent will not actually be contacted, so the method will always return true. The environment properties of the script will be used to re-create a set of properties as would be returned by the agent.
After a succesfull call to this method, all java properties of the agent will be set locally, with a prefix of the agent id. e.g. 1.file.separator="/", 1.user.home="/home"


processLoopNode

public void processLoopNode(org.w3c.dom.Node loopNode)
This tag will loop all nested tasks until the while condition evaluates to true.
e.g. <loop
name="i"
start="0"
end="5"
inc="1"
echo message="The current value is ${i}"/>
loop/>

Which is equivalent to "for (int i = 0; i = 5; i+=1) ...." At least one of the attributes must be specified, any which are missing are assumed to be zero.


processEchoNode

public void processEchoNode(org.w3c.dom.Node echoNode)
This tag allows you to echo traces to the harness.
e.g. <echo message="A java property is ${java.home}"/>


processSendZipNode

public void processSendZipNode(org.w3c.dom.Node sendzipNode)
This tag is the start point for a single unit test.
e.g. <sendzip
onlyif="variable" (optional, execute only if variable="true")
agentid="agentid" (the id of the agent you want to send the zip to)
zipfile="zipfile"/>


processCleanZipNode

public void processCleanZipNode(org.w3c.dom.Node cleanzipNode)
This tag is the start point for a single unit test.
e.g. <cleanzip
onlyif="variable" (optional, execute only of variable="true")
agentid="agentid" (the id of the agent you want to send the zip to)
zipfile="zipfile"/>


processStartNode

public void processStartNode(org.w3c.dom.Node startNode)
This tag is the start point for a single unit test.
e.g. <start
processid="variable" (the id of the process for future reference)
agentid="agentid" (the id of the agent you want to start the process on)
command="command string" (the command you want to execute)
arguments="argument string" (the arguments to the command)
timeout="timeout" (the timeout for this command)
onlyif="variable"/> (optional - execute only if true)


processStatusNode

public void processStatusNode(org.w3c.dom.Node statusNode)
This task will retrieve the status of an executed process.
e.g. <status
processid="variable" (the id of the process for future reference)
status="result" (the status of processid will be placed in this variable)
onlyif="result"/> (optional - execute only if true)


processTraceNode

public void processTraceNode(org.w3c.dom.Node traceNode)
This task will retrieve the traces of an executed process.
e.g. <trace
processid="variable" (the processid to retrieve the trace for)
onlyif="result"/> (optional - execute only if true)


processCleanNode

public void processCleanNode(org.w3c.dom.Node cleanNode)
This task will retrieve the traces of an executed process.
e.g. <clean
processid="variable" // the processid to retrieve the trace for
onlyif="result"/> // optional - execute only if true


processReportNode

public void processReportNode(org.w3c.dom.Node reportNode)
This tag causes a global property to be set. <report status="passed, failed"/>
Note, an unresolved result can not be over-ridden.


interrupt

public void interrupt()
This method is responsible for killing any processes already started on the agents, * and immediately halt parsing any files.

Specified by:
interrupt in interface ParserInterface

getProperty

public java.lang.String getProperty(java.lang.String key)
This method retrieves the specified property from the results of parsing this file.

Specified by:
getProperty in interface ParserInterface

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
This method retrieves the specified property from the results of parsing this file. * If the value is not found, the defaultValue is returned.

Specified by:
getProperty in interface ParserInterface

getTestName

public java.lang.String getTestName()
This method should return a test name which will be used to display the test in * the test tree.

Specified by:
getTestName in interface ParserInterface

getTestAuthor

public java.lang.String getTestAuthor()
This method should return a test Author which will be used to display the test in * the test tree.

Specified by:
getTestAuthor in interface ParserInterface

getTestDescription

public java.lang.String getTestDescription()
This method should return a test Description which will be used to display the test in * the test tree.

Specified by:
getTestDescription in interface ParserInterface

getTestBugInfo

public java.lang.String getTestBugInfo()
This method should return a test BugInfo which will be used for displaying the test in * the test tree.

Specified by:
getTestBugInfo in interface ParserInterface

getKeyWords

public java.lang.String[] getKeyWords()
This method should return all keywords associated with this test. These will be used * in using the keywords to select/deselect tests in the harness.

Specified by:
getKeyWords in interface ParserInterface

getIncludeList

public java.lang.String[] getIncludeList()
This should return the list of files other than standard java.util.Properties files which were * included to parse this test file.

Specified by:
getIncludeList in interface ParserInterface

getPropertiesIncludeList

public java.lang.String[] getPropertiesIncludeList()
This should return the list of standard java.util.Properties files which were * included to parse this test file.

Specified by:
getPropertiesIncludeList in interface ParserInterface

getTraceList

public java.lang.String[] getTraceList()
This method should list all available output files produced by this test when run on the agent, * but relative to the harness.

Specified by:
getTraceList in interface ParserInterface

prepare

public void prepare(java.lang.String projectResultsDir)
This is called at the beginning of a parser run on * one or more tests. * @param projectResultsDir - the canonical pathname of * the project file, used to decide where to place * the parser trace files relative to the harness.

Specified by:
prepare in interface ParserInterface

openPrintStream

public java.io.PrintStream openPrintStream(java.lang.String fileName)
                                    throws java.io.FileNotFoundException
Returns a handle to the Printstream the parser will use for any output * resulting from parsing this test.

Specified by:
openPrintStream in interface ParserInterface
Throws:
java.io.FileNotFoundException

printDebug

public void printDebug(java.lang.String msg)
Specified by:
printDebug in interface ParserInterface

finish

public void finish()
This method indicates we are finished with this parser, and disposes * any reserved resources.

Specified by:
finish in interface ParserInterface

setStatusLabel

public void setStatusLabel(javax.swing.JLabel status)
This is the handle to to QAT parent GUI to display which commands * the parser is processing in real-time.

Specified by:
setStatusLabel in interface ParserInterface

resolveVariable

public java.lang.StringBuffer resolveVariable(java.lang.StringBuffer expression)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

main

public static final void main(java.lang.String[] args)


See QAT project for licensing details