qat.parser.junitparser
Class JUnitParser

java.lang.Object
  extended byjunit.runner.BaseTestRunner
      extended byqat.parser.junitparser.JUnitParser
All Implemented Interfaces:
ParserInterface, junit.framework.TestListener

public class JUnitParser
extends junit.runner.BaseTestRunner
implements junit.framework.TestListener, 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.

Version:
2.3, 17 June 1999
Author:
webhiker

Field Summary
 
Fields inherited from class junit.runner.BaseTestRunner
SUITE_METHODNAME
 
Constructor Summary
JUnitParser()
           
 
Method Summary
 void addError(junit.framework.Test test, java.lang.Throwable t)
           
 void addFailure(junit.framework.Test test, junit.framework.AssertionFailedError t)
           
 junit.framework.TestResult doRun(junit.framework.Test test)
           
 junit.framework.TestResult doRun(junit.framework.Test test, boolean wait)
           
 void endTest(junit.framework.Test test)
           
 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 name)
          This method retrieves the specified property from the results of parsing this file.
 java.lang.String getProperty(java.lang.String name, 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)
           
 junit.framework.TestResult run(junit.framework.Test test)
           
 void runFailed(java.lang.String msg)
           
 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.
 void startTest(junit.framework.Test test)
           
 void testEnded(java.lang.String msg)
           
 void testFailed(int i, junit.framework.Test test, java.lang.Throwable t)
           
 void testStarted(java.lang.String msg)
           
 
Methods inherited from class junit.runner.BaseTestRunner
clearStatus, elapsedTimeAsString, extractClassName, getFilteredTrace, getFilteredTrace, getLoader, getPreference, getPreference, getPreferences, getTest, inVAJava, loadSuiteClass, processArguments, savePreferences, setLoading, setPreference, setPreferences, showStackRaw, truncate, useReloadingTestSuiteLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JUnitParser

public JUnitParser()
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

getProperty

public java.lang.String getProperty(java.lang.String name)
Description copied from interface: ParserInterface
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 name,
                                    java.lang.String defaultValue)
Description copied from interface: ParserInterface
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()
Description copied from interface: ParserInterface
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()
Description copied from interface: ParserInterface
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()
Description copied from interface: ParserInterface
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()
Description copied from interface: ParserInterface
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()
Description copied from interface: ParserInterface
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.

Specified by:
prepare in interface ParserInterface
Parameters:
projectResultsDir - - the canonical pathname of the project file, used to decide where to place the parser trace files.

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

interrupt

public void interrupt()
Description copied from interface: ParserInterface
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

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

runFailed

public void runFailed(java.lang.String msg)

testFailed

public void testFailed(int i,
                       junit.framework.Test test,
                       java.lang.Throwable t)

testEnded

public void testEnded(java.lang.String msg)

testStarted

public void testStarted(java.lang.String msg)

run

public junit.framework.TestResult run(junit.framework.Test test)

doRun

public junit.framework.TestResult doRun(junit.framework.Test test)

doRun

public junit.framework.TestResult doRun(junit.framework.Test test,
                                        boolean wait)

startTest

public void startTest(junit.framework.Test test)
Specified by:
startTest in interface junit.framework.TestListener

endTest

public void endTest(junit.framework.Test test)
Specified by:
endTest in interface junit.framework.TestListener

addError

public void addError(junit.framework.Test test,
                     java.lang.Throwable t)
Specified by:
addError in interface junit.framework.TestListener

addFailure

public void addFailure(junit.framework.Test test,
                       junit.framework.AssertionFailedError t)
Specified by:
addFailure in interface junit.framework.TestListener

main

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


See QAT project for licensing details