net.sf.jameleon.data
Class AbstractDataDrivableTag

java.lang.Object
  extended by org.apache.commons.jelly.TagSupport
      extended by net.sf.jameleon.LocationAwareTagSupport
          extended by net.sf.jameleon.JameleonTagSupport
              extended by net.sf.jameleon.data.AbstractDataDrivableTag
All Implemented Interfaces:
DataDrivable, BreakPoint, Attributable, DataDrivableResultRecordable, FunctionResultRecordable, SessionResultRecordable, DynaTag, LocationAware, Tag
Direct Known Subclasses:
AbstractFileDrivableTag, IterateTag, SqlTag

public abstract class AbstractDataDrivableTag
extends JameleonTagSupport
implements DataDrivable, BreakPoint, DataDrivableResultRecordable, FunctionResultRecordable, SessionResultRecordable

This is a basic implementation of DataDrivable. This is data source independent as possible for now.


Field Summary
protected  AbstractDataDrivableTag addt
           
protected  boolean breakPoint
           
protected  boolean countRow
           
protected  DataDrivableRowResult dataDrivableRowResult
           
protected  DataExecuter executer
           
protected  boolean failedOnCurrentRow
           
protected  org.apache.log4j.Logger log
           
protected  int numOfRowFailures
           
protected  boolean parentFailed
           
protected  File previousStateDir
           
protected  DataDrivableResultContainer resultContainer
           
protected  DataDrivableResultRecordable resultRecorder
           
protected  Map rowData
           
protected  StateStorer stateStorer
           
protected  boolean stopTestExecutionOnFailure
           
protected  TestCaseTag tct
           
protected  Map vars
           
protected  XMLOutput xmlOut
           
 
Fields inherited from class net.sf.jameleon.JameleonTagSupport
attributes, broker, contextVars, fp, unsupportedAttributes
 
Fields inherited from class net.sf.jameleon.LocationAwareTagSupport
columnNumber, elementTagName, lineNumber, scriptFileName
 
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
 
Constructor Summary
AbstractDataDrivableTag()
           
 
Method Summary
 void addVariablesToRowData(Map rowData)
          Used to keep track of the variables and their original values.
protected  DataDrivableRowResult createNewResult()
           
 void destroyVariables(Set keys)
          Removes the keys from the context and the variable set in addVariablesToRowData()
 void doTag(XMLOutput out)
          This method executes the tags inside the csv tag one time for every row in the CSV file used.
 void executeDrivableRow(int rowNum)
          A DataDrivable implementation method that gets called once for every row in the data source.
 DataDrivableRowResult getDataDrivableRowResult()
           
protected abstract  DataDriver getDataDriver()
          Gets the DataDriver used for this tag.
protected abstract  String getDataExceptionMessage()
          Gets an error message to be displayed when a error occurs due to the DataDriver.
 boolean getFailedOnCurrentRow()
           
protected  Map getKeyMapping()
          Gets the new names of the desired context names.
protected abstract  org.apache.log4j.Logger getLogger()
          Gets the logger used for this tag
protected abstract  String getNewStateStoreLocation(int rowNum)
          Calculates the location of the state to be stored for any tags under this tag.
 DataDrivableResultContainer getResultContainer()
           
 Map getRowData()
           
abstract  String getTagDescription()
          Describe the tag when error messages occur.
protected abstract  String getTagTraceMsg()
          Gets the trace message when the execution is beginning and ending.
protected  TestCaseTag getTestCaseTag()
          Gets the TestCaseTag for this tag.
 String getTraceKeyValuePairs(Set keys, Map rowData)
          Traces the key value pairs to screen for debugging purposes This should get called after the key substition is done
 void init()
           
 boolean isBreakPoint()
          Tells if this class is supposed to pause
 boolean isCountRow()
          Gets whether each row in the data source should be considered a separate test case or not.
 void mapKeys(Map vars)
          Maps the keys to the keys returned from getKeyMapping() This method is called from executeDrivableRow(HashMap vars, int rowNum) and is used to allow subclasses to map the variable names defined as the keys in the vars Map to new keys which will then in turn be stored in the context.
 void recordDataDrivableResult(DataDrivableResultContainer result)
          Records a DataDrivableRowResult to the tag's results
 void recordFunctionResult(FunctionResult result)
          Records a FunctionResult to the tag's results and sets the FunctionResult's parent result to itself
protected  void recordResult(JameleonTestResult result)
          Records a child result.
 void recordSessionResult(SessionResult result)
          Removes a FunctionResult from the list of recorded results
protected  void recordThisResult()
           
protected  void removeChildlessResult(DataDrivableRowResult rowResult)
          Removes the current rowResult from its parent if it has no children, meaning the tags weren't actually run
 void setBreakPoint(boolean breakPoint)
          Sets a pause point to this class.
 void setCountRow(boolean countRow)
          Sets the DataDrivable tag to increment the number of times the test case was executed for each row executed.
 void setFailedOnCurrentRow(boolean failedOnCurrentRow)
           
protected  void setResultError(Exception e)
           
 void setStopTestExecutionOnFailure(boolean stopTestExecutionOnFailure)
          To continue on a normal execution path even though an error occurs, set this to false
 void setUpDataDrivable()
          This method is used to set up anything the tag may need and gets called after all set methods have been called.
protected abstract  void setupDataDriver()
          Sets up the DataDriver by calling any implementation-dependent methods.
 void setVariablesInContext(Map vars)
          Places the given variables in the context
protected  void traceMsg(String msg)
          Used for the trace functionality.
 
Methods inherited from class net.sf.jameleon.JameleonTagSupport
cleanVariablesInContext, createAttributes, describeAttributes, getAttributeBroker, getAttributes, getAttributeType, getClassAttributes, getFunctionalPoint, getUnsupportedAttributes, loadFunctionalPoint, resetFunctionalPoint, setAttribute, setVariableInContext, testForUnsupportedAttributesCaught
 
Methods inherited from class net.sf.jameleon.LocationAwareTagSupport
getColumnNumber, getElementName, getFileName, getLineNumber, setColumnNumber, setElementName, setFileName, setLineNumber
 
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.jelly.Tag
getBody, getContext, getParent, invokeBody, setBody, setContext, setParent
 

Field Detail

tct

protected TestCaseTag tct

addt

protected AbstractDataDrivableTag addt

executer

protected DataExecuter executer

xmlOut

protected XMLOutput xmlOut

rowData

protected Map rowData

vars

protected Map vars

resultContainer

protected DataDrivableResultContainer resultContainer

dataDrivableRowResult

protected DataDrivableRowResult dataDrivableRowResult

countRow

protected boolean countRow

stateStorer

protected StateStorer stateStorer

previousStateDir

protected File previousStateDir

numOfRowFailures

protected int numOfRowFailures

failedOnCurrentRow

protected boolean failedOnCurrentRow

stopTestExecutionOnFailure

protected boolean stopTestExecutionOnFailure

parentFailed

protected boolean parentFailed

breakPoint

protected boolean breakPoint

resultRecorder

protected DataDrivableResultRecordable resultRecorder

log

protected final org.apache.log4j.Logger log
Constructor Detail

AbstractDataDrivableTag

public AbstractDataDrivableTag()
Method Detail

getLogger

protected abstract org.apache.log4j.Logger getLogger()
Gets the logger used for this tag

Returns:
the logger used for this tag.

getDataDriver

protected abstract DataDriver getDataDriver()
Gets the DataDriver used for this tag.

Returns:
the DataDriver used for this tag.

setupDataDriver

protected abstract void setupDataDriver()
Sets up the DataDriver by calling any implementation-dependent methods.


getTagTraceMsg

protected abstract String getTagTraceMsg()
Gets the trace message when the execution is beginning and ending. The message displayed will already start with BEGIN: or END:

Returns:
the trace message when the execution is just beginning and ending.

getTagDescription

public abstract String getTagDescription()
Describe the tag when error messages occur. The most appropriate message might be the tag name itself.

Returns:
A brief description of the tag or the tag name itself.

getDataExceptionMessage

protected abstract String getDataExceptionMessage()
Gets an error message to be displayed when a error occurs due to the DataDriver.

Returns:
an error message to be displayed when a error occurs due to the DataDriver.

getNewStateStoreLocation

protected abstract String getNewStateStoreLocation(int rowNum)
Calculates the location of the state to be stored for any tags under this tag. The result should be a relative path that simply has the row number in it along with some unique indentifier for this tag like the handle name or something.

Returns:
the location of the state to be stored for any tags under this tag minus the baseDir calculation stuff.

getTestCaseTag

protected TestCaseTag getTestCaseTag()
Gets the TestCaseTag for this tag. The default implementation searches for it as an ancestor and throws a ClassCastException if it can't find it.

Returns:
the TestCaseTag this tag is nested in.
Throws:
ClassCastException - if the parent TestCaseTag can not be found.

isCountRow

public boolean isCountRow()
Gets whether each row in the data source should be considered a separate test case or not.

Specified by:
isCountRow in interface DataDrivable
Returns:
true if each row in the data source should be considered a separate test case.

setCountRow

public void setCountRow(boolean countRow)
Sets the DataDrivable tag to increment the number of times the test case was executed for each row executed.

Parameters:
countRow - - Set to true to increment the test case results for every row executedThis attribute is recognized by Jameleon
Default Value: false

setFailedOnCurrentRow

public void setFailedOnCurrentRow(boolean failedOnCurrentRow)

getFailedOnCurrentRow

public boolean getFailedOnCurrentRow()

destroyVariables

public void destroyVariables(Set keys)
Removes the keys from the context and the variable set in addVariablesToRowData()

Specified by:
destroyVariables in interface DataDrivable
Parameters:
keys - - A Set of variable names to clean up.

addVariablesToRowData

public void addVariablesToRowData(Map rowData)
Used to keep track of the variables and their original values. This is mostly used for variable substitution.

Specified by:
addVariablesToRowData in interface DataDrivable
Parameters:
rowData - - A map of key-value pairs.

setUpDataDrivable

public void setUpDataDrivable()
This method is used to set up anything the tag may need and gets called after all set methods have been called.


mapKeys

public void mapKeys(Map vars)
Maps the keys to the keys returned from getKeyMapping() This method is called from executeDrivableRow(HashMap vars, int rowNum) and is used to allow subclasses to map the variable names defined as the keys in the vars Map to new keys which will then in turn be stored in the context.

Parameters:
vars - - the original map read from the DataDriver

getKeyMapping

protected Map getKeyMapping()
Gets the new names of the desired context names. The map should contain a key-value pair where the key is the original key and the value is the new key desired. The default implementation returns null.

Returns:
a key-value pair representing the new variable names.

executeDrivableRow

public void executeDrivableRow(int rowNum)
A DataDrivable implementation method that gets called once for every row in the data source.

Specified by:
executeDrivableRow in interface DataDrivable
Parameters:
rowNum - - The row number being executed

getResultContainer

public DataDrivableResultContainer getResultContainer()

setStopTestExecutionOnFailure

public void setStopTestExecutionOnFailure(boolean stopTestExecutionOnFailure)
To continue on a normal execution path even though an error occurs, set this to false

This attribute is recognized by Jameleon

setVariablesInContext

public void setVariablesInContext(Map vars)
Places the given variables in the context


getTraceKeyValuePairs

public String getTraceKeyValuePairs(Set keys,
                                    Map rowData)
Traces the key value pairs to screen for debugging purposes This should get called after the key substition is done


traceMsg

protected void traceMsg(String msg)
Used for the trace functionality. Only sends info to the log if trace is enabled.


init

public void init()
          throws MissingAttributeException
Throws:
MissingAttributeException

recordThisResult

protected void recordThisResult()

doTag

public void doTag(XMLOutput out)
           throws MissingAttributeException,
                  JellyTagException
This method executes the tags inside the csv tag one time for every row in the CSV file used.

Specified by:
doTag in interface Tag
Throws:
MissingAttributeException
JellyTagException

removeChildlessResult

protected void removeChildlessResult(DataDrivableRowResult rowResult)
Removes the current rowResult from its parent if it has no children, meaning the tags weren't actually run

Parameters:
rowResult - - The rowResult to remove

setResultError

protected void setResultError(Exception e)

createNewResult

protected DataDrivableRowResult createNewResult()

getRowData

public Map getRowData()

getDataDrivableRowResult

public DataDrivableRowResult getDataDrivableRowResult()

recordResult

protected void recordResult(JameleonTestResult result)
Records a child result. Used as a helper method for the ResultRecordable implementation methods.

Parameters:
result - - the result to record

recordDataDrivableResult

public void recordDataDrivableResult(DataDrivableResultContainer result)
Records a DataDrivableRowResult to the tag's results

Specified by:
recordDataDrivableResult in interface DataDrivableResultRecordable
Parameters:
result -

recordFunctionResult

public void recordFunctionResult(FunctionResult result)
Records a FunctionResult to the tag's results and sets the FunctionResult's parent result to itself

Specified by:
recordFunctionResult in interface FunctionResultRecordable
Parameters:
result -

recordSessionResult

public void recordSessionResult(SessionResult result)
Removes a FunctionResult from the list of recorded results

Specified by:
recordSessionResult in interface SessionResultRecordable
Parameters:
result - - the result to remove

setBreakPoint

public void setBreakPoint(boolean breakPoint)
Sets a pause point to this class.

Parameters:
breakPoint - - Set to false to enable debug mode.This attribute is recognized by Jameleon

isBreakPoint

public boolean isBreakPoint()
Tells if this class is supposed to pause

Specified by:
isBreakPoint in interface BreakPoint
Returns:
true if class should pause and wait for user interaction.


Copyright © 2003-2008 Christian Hargraves. All Rights Reserved.