com.dtrules.testsupport
Class ATestHarness

java.lang.Object
  extended by com.dtrules.testsupport.ATestHarness
All Implemented Interfaces:
ITestHarness

public abstract class ATestHarness
extends Object
implements ITestHarness


Field Summary
protected  AutoDataMap autoDataMap
           
protected  String currentfile
           
protected  DataMap datamap
           
protected  int filecnt
           
 
Constructor Summary
ATestHarness()
           
 
Method Summary
 void changeReportXML(OutputStream report)
          Generate a change report xml to the given output stream.
 String compareNodes(XMLTree.Node thisResult, XMLTree.Node oldResult)
          Returns a message about the difference between the nodes.
 void compareTestResults()
          Compare our new results with a set of past result files.
 PrintStream compareTestResultsReport()
          Returns standard out by default.
 boolean Console()
          Do you want to print the report data to the Console as well as to the report file?
 boolean coverageReport()
          By default, we will produce a coverage report as long as you have trace turned on.
 String entrypoint()
          Returns "default" as the assumed entry point.
 void executeDecisionTables(IRSession session)
          Called to execute the Decision Tables.
 AutoDataMap getAutoDataMap()
          Returns the autoDataMap (or null if there is no autoDataMap)
 String getCurrentFile()
          Returns the filename of the test set currently under test.
 DataMap getDataMap()
           
 String getDecisionTableName()
          An implementation must implement either this method, or getDecsionTableNames().
 String[] getDecisionTableNames()
          By default we do not have a list of Decision Table names.
 File[] getFiles()
          Returns the set of files to run as part of the test, in the order provided.
 String getOutputDirectory()
          This is where we are going to put the trace files, report files, etc.
 String getReportFileName()
          The name of the report file.
 String getResultDirectory()
          By default, we will look for a directory:

/results
 String getRulesDirectoryFile()
          Default Rules directory file name is DTRules.xml.
 String getTestDirectory()
          Default directory with all the test files.
 String getXMLDirectory()
          Path to the XML Directory holding all the XML files for this Rule Set
 int harnessVersion()
          Returns the TestHarness Version.
 void loadData(IRSession session, String path, String dataset)
          Provides a way for a project to manage how data is loaded into a session.
 String mapName()
          Return the map Name for this Rule Set.
 boolean numbered()
          If numbered, we will number the files generated (result files, trace files, etc.)
 void printReport(int runNumber, IRSession session, PrintStream out)
          By default, we will simply dump the entities as the report file.
 String referencePath()
          Path to the Alternate Configuration File (generally the deployed rule set) to use as a basis to produce a change report XML
 String referenceRulesDirectoryFile()
          Alternate Configuration File (generally the deployed rule set) to use as a basis to produce a change report XML
 void removeIds(XMLTree.Node node)
           
 String runfile(RulesDirectory rd, RuleSet rs, int dfcnt, String path, String dataset)
          Returns the error if an error is thrown.
 void runTests()
          Runs all the test files in the TestDirectory;
 boolean Trace()
          By default, we will trace your code.
 boolean Verbose()
          If verbose, we are going to print the EDD before we run the rules as well as after we run the rules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.dtrules.testsupport.ITestHarness
getPath, getRulesDirectoryPath, getRuleSetName
 

Field Detail

datamap

protected DataMap datamap

autoDataMap

protected AutoDataMap autoDataMap

currentfile

protected String currentfile

filecnt

protected int filecnt
Constructor Detail

ATestHarness

public ATestHarness()
Method Detail

harnessVersion

public int harnessVersion()
Description copied from interface: ITestHarness
Returns the TestHarness Version. At this point we have the following versions:

1 -- Use the dataMap interface 2 -- Use the autoDataMap interface

Specified by:
harnessVersion in interface ITestHarness
Returns:

mapName

public String mapName()
Return the map Name for this Rule Set. Override this method if your map needed for your test isn't named "default".

Specified by:
mapName in interface ITestHarness
Returns:

getCurrentFile

public String getCurrentFile()
Description copied from interface: ITestHarness
Returns the filename of the test set currently under test.

Specified by:
getCurrentFile in interface ITestHarness
Returns:

executeDecisionTables

public void executeDecisionTables(IRSession session)
                           throws RulesException
Description copied from interface: ITestHarness
Called to execute the Decision Tables. Some Test Harnesses might need to make multiple Decision Table Calls

Specified by:
executeDecisionTables in interface ITestHarness
Throws:
RulesException

getDecisionTableName

public String getDecisionTableName()
An implementation must implement either this method, or getDecsionTableNames(). The later is preferred.

Specified by:
getDecisionTableName in interface ITestHarness
Returns:

entrypoint

public String entrypoint()
Returns "default" as the assumed entry point. Override if you need to test your decision tables from some other defined entry point. The entry point for your Rule Set is defined in your Rules Engine configuration file (DTRules.xml).

Specified by:
entrypoint in interface ITestHarness
Returns:

getDecisionTableNames

public String[] getDecisionTableNames()
By default we do not have a list of Decision Table names. The implementation can either implement this method, or the method getDecisionTableName();

Specified by:
getDecisionTableNames in interface ITestHarness
Returns:

getDataMap

public DataMap getDataMap()
Specified by:
getDataMap in interface ITestHarness

getAutoDataMap

public AutoDataMap getAutoDataMap()
Returns the autoDataMap (or null if there is no autoDataMap)

Returns:

getXMLDirectory

public String getXMLDirectory()
Path to the XML Directory holding all the XML files for this Rule Set


getRulesDirectoryFile

public String getRulesDirectoryFile()
Default Rules directory file name is DTRules.xml.

Specified by:
getRulesDirectoryFile in interface ITestHarness
Returns:

getTestDirectory

public String getTestDirectory()
Default directory with all the test files.

Specified by:
getTestDirectory in interface ITestHarness
Returns:

getOutputDirectory

public String getOutputDirectory()
This is where we are going to put the trace files, report files, etc.

Specified by:
getOutputDirectory in interface ITestHarness
Returns:

Console

public boolean Console()
Do you want to print the report data to the Console as well as to the report file? If so, this method should return true.

Specified by:
Console in interface ITestHarness
Returns:

Verbose

public boolean Verbose()
If verbose, we are going to print the EDD before we run the rules as well as after we run the rules.

Specified by:
Verbose in interface ITestHarness
Returns:

numbered

public boolean numbered()
If numbered, we will number the files generated (result files, trace files, etc.)

Specified by:
numbered in interface ITestHarness
Returns:
By default we do not number generated files.

Trace

public boolean Trace()
By default, we will trace your code.

Specified by:
Trace in interface ITestHarness
Returns:

coverageReport

public boolean coverageReport()
By default, we will produce a coverage report as long as you have trace turned on. (No use if you don't, because we generate the coverage report from the trace files)

Specified by:
coverageReport in interface ITestHarness
Returns:

getReportFileName

public String getReportFileName()
The name of the report file.

Specified by:
getReportFileName in interface ITestHarness
Returns:

getFiles

public File[] getFiles()
Description copied from interface: ITestHarness
Returns the set of files to run as part of the test, in the order provided. By overriding this method, a test routine can be written to avoid certain files, repeat the execution of files, or run files in a different order.

Specified by:
getFiles in interface ITestHarness
Returns:

runTests

public void runTests()
Description copied from interface: ITestHarness
Runs all the test files in the TestDirectory;

Specified by:
runTests in interface ITestHarness

loadData

public void loadData(IRSession session,
                     String path,
                     String dataset)
              throws Exception
Description copied from interface: ITestHarness
Provides a way for a project to manage how data is loaded into a session.

Specified by:
loadData in interface ITestHarness
Throws:
Exception

runfile

public String runfile(RulesDirectory rd,
                      RuleSet rs,
                      int dfcnt,
                      String path,
                      String dataset)
Returns the error if an error is thrown. Otherwise, a null.

Parameters:
rd -
rs -
dfcnt -
path -
dataset -
Returns:

printReport

public void printReport(int runNumber,
                        IRSession session,
                        PrintStream out)
                 throws Exception
By default, we will simply dump the entities as the report file. In general, we usually print a valid XML file as a report, but nothing says you have to.

Specified by:
printReport in interface ITestHarness
Parameters:
runNumber - the number of the test being run
session - the session of the Rules Engine to use as the basis of the report
Throws:
Exception

referenceRulesDirectoryFile

public String referenceRulesDirectoryFile()
Description copied from interface: ITestHarness
Alternate Configuration File (generally the deployed rule set) to use as a basis to produce a change report XML

Specified by:
referenceRulesDirectoryFile in interface ITestHarness
Returns:

referencePath

public String referencePath()
Description copied from interface: ITestHarness
Path to the Alternate Configuration File (generally the deployed rule set) to use as a basis to produce a change report XML

Specified by:
referencePath in interface ITestHarness
Returns:

changeReportXML

public void changeReportXML(OutputStream report)
Description copied from interface: ITestHarness
Generate a change report xml to the given output stream.

Specified by:
changeReportXML in interface ITestHarness

compareNodes

public String compareNodes(XMLTree.Node thisResult,
                           XMLTree.Node oldResult)
Returns a message about the difference between the nodes. If there is no difference, a null is returned.

Specified by:
compareNodes in interface ITestHarness
Returns:
null if the nodes are equal, or a String detailing the differences if the Nodes are not the same.

removeIds

public void removeIds(XMLTree.Node node)

compareTestResults

public void compareTestResults()
                        throws Exception
Description copied from interface: ITestHarness
Compare our new results with a set of past result files.

Specified by:
compareTestResults in interface ITestHarness
Throws:
Exception

getResultDirectory

public String getResultDirectory()
By default, we will look for a directory:

/results

Specified by:
getResultDirectory in interface ITestHarness
Returns:

compareTestResultsReport

public PrintStream compareTestResultsReport()
                                     throws Exception
Returns standard out by default.

Specified by:
compareTestResultsReport in interface ITestHarness
Returns:
Throws:
Exception


Copyright © 2011 DTrules Inc. All Rights Reserved.