net.sf.jameleon.data
Class IterateTag

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
                  extended by net.sf.jameleon.data.IterateTag
All Implemented Interfaces:
DataDrivable, BreakPoint, Attributable, DataDrivableResultRecordable, FunctionResultRecordable, SessionResultRecordable, DynaTag, LocationAware, Tag

public class IterateTag
extends AbstractDataDrivableTag

Iterates over all nested tags one time per object in a Collection. Sometimes you want to data-drive your test, but based on data that is defined in the application itself. This is a more generic way to data-drive your tags, based on a Collection of Objects that may be populated into the context via some other tag. For example:


 <testcase xmlns="jelly:jameleon">
   <get-data-from-somewhere toVar="listOfAccounts"/>
   <iterate varName="someVar" items="${listOfAccounts}">
     <some-session application="someApp" beginSession="true">
       <some-tag-that-uses-context-variables
           functionId="Verify successful navigation, using a different variable."
           attribute="${someVar}"/>
     </some-session>
   </iterate>
 </testcase>
 

Author:
Andrey Chernyshov, Christian Hargraves
Tag Name: <iterate>

Field Summary
protected  CollectionDataDriver dataDriver
           
protected  String id
           
protected  Collection items
           
protected  String varName
           
 
Fields inherited from class net.sf.jameleon.data.AbstractDataDrivableTag
addt, breakPoint, countRow, dataDrivableRowResult, executer, failedOnCurrentRow, log, numOfRowFailures, parentFailed, previousStateDir, resultContainer, resultRecorder, rowData, stateStorer, stopTestExecutionOnFailure, tct, vars, 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
IterateTag()
           
 
Method Summary
protected  DataDriver getDataDriver()
          Gets the DataDriver used for this tag.
protected  String getDataExceptionMessage()
          Gets an error message to be displayed when a error occurs due to the DataDriver.
protected  org.apache.log4j.Logger getLogger()
          Gets the logger used for this tag
protected  String getNewStateStoreLocation(int rowNum)
          Calculates the location of the state to be stored for any tags under this tag.
 String getTagDescription()
          Describe the tag when error messages occur.
protected  String getTagTraceMsg()
          Gets the trace message when the execution is beginning and ending.
 void setId(String id)
          This is primarily used for debugging.
 void setItems(Collection items)
           
protected  void setupDataDriver()
          Sets up the DataDriver by calling any implementation-dependent methods.
 void setVarName(String varName)
           
 
Methods inherited from class net.sf.jameleon.data.AbstractDataDrivableTag
addVariablesToRowData, createNewResult, destroyVariables, doTag, executeDrivableRow, getDataDrivableRowResult, getFailedOnCurrentRow, getKeyMapping, getResultContainer, getRowData, getTestCaseTag, getTraceKeyValuePairs, init, isBreakPoint, isCountRow, mapKeys, recordDataDrivableResult, recordFunctionResult, recordResult, recordSessionResult, recordThisResult, removeChildlessResult, setBreakPoint, setCountRow, setFailedOnCurrentRow, setResultError, setStopTestExecutionOnFailure, setUpDataDrivable, setVariablesInContext, traceMsg
 
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

dataDriver

protected CollectionDataDriver dataDriver

items

protected Collection items

varName

protected String varName

id

protected String id
Constructor Detail

IterateTag

public IterateTag()
Method Detail

getLogger

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

Specified by:
getLogger in class AbstractDataDrivableTag
Returns:
the logger used for this tag.

getDataDriver

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

Specified by:
getDataDriver in class AbstractDataDrivableTag
Returns:
the DataDriver used for this tag.

setupDataDriver

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

Specified by:
setupDataDriver in class AbstractDataDrivableTag

getTagTraceMsg

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

Specified by:
getTagTraceMsg in class AbstractDataDrivableTag
Returns:
the trace message when the execution is just beginning and ending.

getTagDescription

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

Specified by:
getTagDescription in class AbstractDataDrivableTag
Returns:
A brief description of the tag or the tag name itself.

getDataExceptionMessage

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

Specified by:
getDataExceptionMessage in class AbstractDataDrivableTag
Returns:
an error message to be displayed when a error occurs due to the DataDriver.

getNewStateStoreLocation

protected 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.

Specified by:
getNewStateStoreLocation in class AbstractDataDrivableTag
Returns:
the location of the state to be stored for any tags under this tag minus the baseDir calculation stuff.

setItems

public void setItems(Collection items)
This attribute is recognized by Jameleon
Required: true

setVarName

public void setVarName(String varName)
This attribute is recognized by Jameleon
Required: true

setId

public void setId(String id)
This is primarily used for debugging. It also provides a means to distinguish between nested IterateTag tags.

This attribute is recognized by Jameleon
Required: false


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