net.sf.jameleon
Class TestCaseTag

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

public class TestCaseTag
extends AbstractCsvTag

Every test case script must have at least one testcase tag containing all other Jameleon tags.

Some of this tags attribute may affect every nested Jameleon tag. Many of the attributes in this tag can be set globally via a jameleon.conf file.

The order of setting variables in the context follows:

  1. Load the CSV file variables and put them in the context.
  2. Load the $testEnvironment-Applications.properties and then Applications.properties and only set the variables that aren't set in the previous files. In other words, if there are variables that are going to be the same ( like the page title ) across multiple test cases, then first variable set wins.
  3. Execute the function tag and set the attributes in the context. If you want key/values in the CSV and properties files to override the script attribute, then the function point author uses the setDefaultVariableValue() method in the set method for that attribute.
  4. If the function point is using a map-variable, then override all settings to set the variable to the mapFrom variable name.

Tag Name: <testcase>
Tag Name: <test-case>

Field Summary
protected static String APPLICATIONS_PROPERTIES
           
protected  String assertGreaterThanLevel
           
protected  String assertLessThanLevel
           
protected  String assertLevel
           
protected  String assertLevels
           
protected  File baseDir
          The baseDir where everything else is based
protected  String bugTrackerUrl
           
protected  String csvValueSeparator
           
protected  DataDrivableRowResult ddRowResult
           
protected static int DEFAULT_ROW
           
protected static String DEFAULT_VALUE_SEPARATOR
           
protected  boolean enableSslCertCheck
          Enable/disable validity checking for SSL certificates.
protected  TestCaseEventHandler eventHandler
           
protected  boolean executeTestCase
           
protected  boolean failedOnDataDriver
          Used to flag if a CSV file is not found.
protected  boolean failOnCSVFileNotFound
          DEFAULT - true.
protected  boolean genTestCaseDocs
           
protected  String genTestCaseDocsEncoding
           
protected  String jameleonConfigName
          The name of the Jameleon configuration file.
protected  ArrayList keysSet
           
protected  long maxExecutionTime
           
protected  String organization
           
protected  String propsName
           
protected  TestCaseResult results
          The test case results which are a complete set of results for every tag executed.
protected  File resultsDir
          The directory name to store the results to.
protected  File resultsFile
           
protected  CountableDataDrivableResultContainer rowResultContainer
           
protected  long startTime
           
protected  boolean storeDisplayOnError
          Only store the displayed screen being tested to a file on an error.
protected  boolean storeEveryDisplay
          Store all displayed screens to a file..
protected  TestCase testCase
           
protected  String testCaseMainPageTemplate
           
protected  String testCaseResultDataRowTemplate
           
protected  String testCaseResultFunctionTemplate
           
protected  String testCaseResultSessionTemplate
           
protected  String testCaseResultSummaryTemplate
           
protected  String testCaseResultTemplate
           
protected  String testCaseSummaryTemplate
           
protected  String testEnvironment
           
protected  File timestampedResultsDir
          The timestamped directory to store the results to.
protected  boolean trace
           
protected  boolean useCSV
           
 
Fields inherited from class net.sf.jameleon.AbstractCsvTag
csv, csvFileName, name
 
Fields inherited from class net.sf.jameleon.data.AbstractFileDrivableTag
charset, dataDir, fileName
 
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
TestCaseTag()
           
 
Method Summary
protected  void addValuesFromResourceBundle(ResourceBundle props, Properties p, String startOfKey, boolean overrideValue)
           
 void addVariablesToRowData(Map vars)
          Used to add key/values to a local context for multiple variable substitution.
protected  JellyTagException createExceptionFromResult(JameleonTestResult jtr)
           
protected  JellyTagException createExceptionFromResult(String message, JameleonTestResult jtr)
           
 void doTag(XMLOutput out)
          This method executes the tags inside the test-case tag.
protected  void executeBody(Runnable r)
           
 void executeDrivableRow(int rowNum)
          A CsvExecutable implementation method that gets called once for every row in the csv file.
protected  void executeNoCSV()
           
 String getAssertGreaterThanLevel()
           
 String getAssertLessThanLevel()
           
 String getAssertLevel()
           
protected  int getAssertLevelFromString(String assertLevel)
           
 String getAssertLevels()
           
 File getBaseDir()
           
 String getBugTrackerUrl()
          Sets the url of the bugtracking tool used so the bug's listed for the test case are linked.
 File getCsvDir(boolean calculate)
          Gets the directory of where csv files should be read from, given the environment settings.
 DataDrivableRowResult getDdResult()
           
 String getGenTestCaseDocsEncoding()
           
 String getJameleonConfigName()
           
 List getKeySet()
           
protected  org.apache.log4j.Logger getLogger()
          Gets the logger used for this tag
 long getMaxExecutionTime()
          Gets the maximum execution time before the test case fails
 String getOrganization()
           
 Properties getPropertiesForApplication(String applicationName)
          This method creates a new Properties Object populated only with the properties for application desired.
 String getPropsName()
          Gets the name of the properties file (minus the .properties) to read in into the context
 TestCaseResult getResults()
           
 File getResultsDir()
          Gets the directory where the results will be written to.
 File getResultsDir(boolean includeName)
          Gets the directory where the results will be written to.
protected  File getResultsDir(int rowCount)
           
 File getResultsFile()
          Gets the results file that represents the test case execution.
 StateStorer getStateStorer()
           
 String getTagDescription()
          Describe the tag when error messages occur.
protected  String getTagTraceMsg()
          Gets the trace message when the execution is beginning and ending.
 TestCase getTestCase()
           
 String getTestCaseMainPageTemplate()
          Gets the template to be used to generate the main page of the results..
 String getTestCaseResultDataRowTemplate()
          Gets the data row template to be used to generate the data drivable result.
 String getTestCaseResultFunctionTemplate()
          Gets the template to be used to generate the function result.
 String getTestCaseResultSessionTemplate()
          Gets the session template to be used to generate the session result.
 String getTestCaseResultSummaryTemplate()
          Gets the template to be used to generate the test case result summary page.
 String getTestCaseResultTemplate()
          Gets the template to be used to generate the test case result page.
 String getTestCaseSummaryTemplate()
          Gets the template to be used to generate the test case summary page of the results..
protected  TestCaseTag getTestCaseTag()
          Gets the TestCaseTag for this tag.
 String getTestEnvironment()
           
 File getTimestampedResultsDir()
          Gets the timestamped results directory where the test case result documentation will be stored.
 boolean getTrace()
          Gets whether a std out message should be sent before and after the execution of a functional point.
protected  void initResults()
           
 void invokeChildren(int rowNum, JameleonTestResult result)
          Execute the rest of the test script.
 boolean isEnableSslCertCheck()
          Query whether SSL cert validity checking is enabled.
 boolean isExecuteTestCase()
           
 boolean isGenTestCaseDocs()
           
protected  boolean isValidateAssertLevel(String level)
           
protected  ResourceBundle loadApplicationProperties()
          Loads the properties for all applications.
protected  void loadJameleonConfig()
          Loads the properties for all applications.
protected  void logError(Throwable t)
          Logs an error in XML format for easy interpreting later.
protected  String[] parseAssertLevels()
           
protected  void recordResult(JameleonTestResult result)
          Records a child result.
 void setAssertGreaterThanLevel(String assertGreaterThanLevel)
           
 void setAssertLessThanLevel(String assertLessThanLevel)
           
 void setAssertLevel(String assertLevel)
           
protected  void setAssertLevels()
           
 void setAssertLevels(String assertLevels)
          Sets the level of the asserts to run that are equal to this list of numbers.
 void setBaseDir(File baseDir)
          Sets the base directory of the project
 void setBugTrackerUrl(String bugTrackerUrl)
          Sets the url of the bugtracking tool used so the bug's listed for the test case are linked.
 void setEnableSslCertCheck(boolean enable)
          Enable or disable validity checking of SSL certificates.
 void setExecuteTestCase(boolean executeTestCase)
          Sets the test case to be executed or not.
 void setFailedOnDataDriver(boolean failedOnDataDriver)
          Used internally to mark whether the DataDrivable had a problem.
 void setFailOnCSVFileNotFound(boolean failOnCSVFileNotFound)
          Sets the failOnCSVFileNotFound property
protected  void setFileFromEnvironment(Configurator config, String key)
           
 void setGenTestCaseDocs(boolean genTestCaseDocs)
          Sets the test case to generate the test case docs based on the javadocs of the functional points and the functionId's of the functional points in the test case.
 void setGenTestCaseDocsEncoding(String encoding)
          Sets the charset encoding.
 void setJameleonConfigName(String configName)
          Sets the configuration file Jameleon uses to configure itself.
protected  void setLocationAware(LocationAware la)
           
 void setMaxExecutionTime(long maxExecutionTime)
          Sets the maximum execution time before the test case fails
 void setOrganization(String organization)
          Sets the organziation or company that this test will be run against.
 void setPropsName(String propsName)
          Sets the name of the properties file (minus the .properties) to read in into the context
 void setResults(TestCaseResult results)
           
 void setResultsDir(File resultsDir)
          Sets the directory where the results will be written to.
protected  void setStateStoreOptions()
           
 void setStoreStateEvent(String event)
          Sets the test case to record the state of the application at a defined event
 void setStoreStateNever(boolean none)
          Sets the test case to never record the state of the application.
 void setStoreStateOnChange(boolean all)
          Sets the test case to record the state of the application whenever the application's state changes.
 void setStoreStateOnError(boolean onError)
          Sets the test case to record the state of the application on errors.
 void setTestCaseMainPageTemplate(String testCaseMainPageTemplate)
          Sets the template to be used to generate the main page of the results..
 void setTestCaseResultDataRowTemplate(String testCaseResultDataRowTemplate)
          Sets the data row template to be used to generate the data drivable result.
 void setTestCaseResultFunctionTemplate(String testCaseResultFunctionTemplate)
          Sets the function result template to be used to generate the test case result.
 void setTestCaseResultSessionTemplate(String testCaseResultSessionTemplate)
          Sets the session template to be used to generate the session result.
 void setTestCaseResultSummaryTemplate(String testCaseResultSummaryTemplate)
          Sets the template to be used to generate the test case result summary page.
 void setTestCaseResultTemplate(String testCaseResultTemplate)
          Sets the template to be used to generate the test case result summary page.
 void setTestCaseSummaryTemplate(String testCaseSummaryTemplate)
          Sets the template to be used to generate the test case summary page of the results.
 void setTestEnvironment(String testEnvironment)
          Sets the environment to which testing system the testcase will be run in.
 void setTimestampedResultsDir(File timestampedResultsDir)
          Sets the timestamped results directory where the test case result documentation will be stored.
 void setTrace(boolean trace)
          Sets whether a std out message should be sent before and after the execution of a functional point.
 void setUp()
          Set up the test environment.
 void setUseCSV(boolean useCSV)
          Sets whether a CSV file should be used for this testcase or not.
protected  void setValueFromEnvironment(Configurator config, String key)
           
protected  void spanCSV()
          useCSV is set to true, data-drive this CSV file.
 void substituteKeyValues()
          Do variable subsitution on values stored from data file.
protected  void substituteValues(Properties p)
          Do variable substition based on keys in the iterator.
 void tearDown()
          Clean things up after the test case has been executed.
protected  void validateAttributes()
          Validate the parameters
 
Methods inherited from class net.sf.jameleon.AbstractCsvTag
getCsvCharset, getCsvDir, getCsvFile, getCsvFileName, getCsvValueSeparator, getDataDriver, getDataExceptionMessage, getName, getNewStateStoreLocation, setCsvCharset, setCsvDir, setCsvFileName, setCsvValueSeparator, setName, setupDataDriver
 
Methods inherited from class net.sf.jameleon.data.AbstractFileDrivableTag
getDataDir, getDataDir, setCharset, setDataDir, setFile
 
Methods inherited from class net.sf.jameleon.data.AbstractDataDrivableTag
createNewResult, destroyVariables, getDataDrivableRowResult, getFailedOnCurrentRow, getKeyMapping, getResultContainer, getRowData, getTraceKeyValuePairs, init, isBreakPoint, isCountRow, mapKeys, recordDataDrivableResult, recordFunctionResult, 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

maxExecutionTime

protected long maxExecutionTime

assertGreaterThanLevel

protected String assertGreaterThanLevel

assertLessThanLevel

protected String assertLessThanLevel

assertLevel

protected String assertLevel

assertLevels

protected String assertLevels

testEnvironment

protected String testEnvironment

organization

protected String organization

csvValueSeparator

protected String csvValueSeparator

bugTrackerUrl

protected String bugTrackerUrl

genTestCaseDocsEncoding

protected String genTestCaseDocsEncoding

propsName

protected String propsName

useCSV

protected boolean useCSV

trace

protected boolean trace

genTestCaseDocs

protected boolean genTestCaseDocs

executeTestCase

protected boolean executeTestCase

testCaseResultDataRowTemplate

protected String testCaseResultDataRowTemplate

testCaseResultSessionTemplate

protected String testCaseResultSessionTemplate

testCaseResultFunctionTemplate

protected String testCaseResultFunctionTemplate

testCaseMainPageTemplate

protected String testCaseMainPageTemplate

testCaseSummaryTemplate

protected String testCaseSummaryTemplate

testCaseResultSummaryTemplate

protected String testCaseResultSummaryTemplate

testCaseResultTemplate

protected String testCaseResultTemplate

eventHandler

protected TestCaseEventHandler eventHandler

startTime

protected long startTime

resultsFile

protected File resultsFile

rowResultContainer

protected CountableDataDrivableResultContainer rowResultContainer

failOnCSVFileNotFound

protected boolean failOnCSVFileNotFound
DEFAULT - true. If set to false, then don't error and don't even log the test case. If a file is found, then go ahead and log test case results


failedOnDataDriver

protected boolean failedOnDataDriver
Used to flag if a CSV file is not found. This is used only when failOnCSVFileNotFound is set to false


results

protected TestCaseResult results
The test case results which are a complete set of results for every tag executed.


ddRowResult

protected DataDrivableRowResult ddRowResult

keysSet

protected ArrayList keysSet

testCase

protected TestCase testCase

storeDisplayOnError

protected boolean storeDisplayOnError
Only store the displayed screen being tested to a file on an error.


storeEveryDisplay

protected boolean storeEveryDisplay
Store all displayed screens to a file..


baseDir

protected File baseDir
The baseDir where everything else is based


resultsDir

protected File resultsDir
The directory name to store the results to. Defaults to ./jameleon_test_results


timestampedResultsDir

protected File timestampedResultsDir
The timestamped directory to store the results to.


jameleonConfigName

protected String jameleonConfigName
The name of the Jameleon configuration file. (default is defined in Configurator)


enableSslCertCheck

protected boolean enableSslCertCheck
Enable/disable validity checking for SSL certificates. Default is true (enabled). Set to false to prevent exceptions from being thrown for invalid SSL certs.


APPLICATIONS_PROPERTIES

protected static final String APPLICATIONS_PROPERTIES
See Also:
Constant Field Values

DEFAULT_ROW

protected static final int DEFAULT_ROW
See Also:
Constant Field Values

DEFAULT_VALUE_SEPARATOR

protected static final String DEFAULT_VALUE_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

TestCaseTag

public TestCaseTag()
Method Detail

getDdResult

public DataDrivableRowResult getDdResult()

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.

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.

getTestCaseTag

protected TestCaseTag getTestCaseTag()
Description copied from class: AbstractDataDrivableTag
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.

Overrides:
getTestCaseTag in class AbstractDataDrivableTag
Returns:
the TestCaseTag this tag is nested in.

addVariablesToRowData

public void addVariablesToRowData(Map vars)
Used to add key/values to a local context for multiple variable substitution. Since a test case can have multiple sessions and sessions are application specific, then variables with ${varName} in them can be different values depending on the application settings in the Applications.properties.

Specified by:
addVariablesToRowData in interface DataDrivable
Overrides:
addVariablesToRowData in class AbstractDataDrivableTag
Parameters:
vars - - A map of key-value pairs.

getTestCaseResultSessionTemplate

public String getTestCaseResultSessionTemplate()
Gets the session template to be used to generate the session result. This is searched for in the classpath.

Returns:
the session template to be used to generate the test case docs.

setTestCaseResultSessionTemplate

public void setTestCaseResultSessionTemplate(String testCaseResultSessionTemplate)
Sets the session template to be used to generate the session result. This is searched for in the classpath.

Parameters:
testCaseResultSessionTemplate - the session template to be used to generate the test case docs.This attribute is recognized by Jameleon

getTestCaseResultDataRowTemplate

public String getTestCaseResultDataRowTemplate()
Gets the data row template to be used to generate the data drivable result. This is searched for in the classpath.

Returns:
the data-drivable template to be used to generate the test case docs.

setTestCaseResultDataRowTemplate

public void setTestCaseResultDataRowTemplate(String testCaseResultDataRowTemplate)
Sets the data row template to be used to generate the data drivable result. This is searched for in the classpath.

Parameters:
testCaseResultDataRowTemplate - the data-drivable template to be used to generate the test case docs.This attribute is recognized by Jameleon

getTestCaseResultFunctionTemplate

public String getTestCaseResultFunctionTemplate()
Gets the template to be used to generate the function result. This is searched for in the classpath.

Returns:
the entry leaf template to be used to generate the test case docs.

setTestCaseResultFunctionTemplate

public void setTestCaseResultFunctionTemplate(String testCaseResultFunctionTemplate)
Sets the function result template to be used to generate the test case result. This is searched for in the classpath.

Parameters:
testCaseResultFunctionTemplate - The entry leaf template to be used to generate the test case docs.This attribute is recognized by Jameleon

getTestCaseMainPageTemplate

public String getTestCaseMainPageTemplate()
Gets the template to be used to generate the main page of the results.. This is searched for in the classpath.

Returns:
the template to be used to generate the test case main page.

setTestCaseMainPageTemplate

public void setTestCaseMainPageTemplate(String testCaseMainPageTemplate)
Sets the template to be used to generate the main page of the results.. This is searched for in the classpath.

Parameters:
testCaseMainPageTemplate - The template.This attribute is recognized by Jameleon

getTestCaseSummaryTemplate

public String getTestCaseSummaryTemplate()
Gets the template to be used to generate the test case summary page of the results.. This is searched for in the classpath.

Returns:
the template to be used to generate the test case summary docs.

setTestCaseSummaryTemplate

public void setTestCaseSummaryTemplate(String testCaseSummaryTemplate)
Sets the template to be used to generate the test case summary page of the results. This is searched for in the classpath.

Parameters:
testCaseSummaryTemplate - The template to be used to generate the test case summary docs.This attribute is recognized by Jameleon

getTestCaseResultSummaryTemplate

public String getTestCaseResultSummaryTemplate()
Gets the template to be used to generate the test case result summary page. This is searched for in the classpath.

Returns:
The template to be used to generate the test case result summary page.

setTestCaseResultTemplate

public void setTestCaseResultTemplate(String testCaseResultTemplate)
Sets the template to be used to generate the test case result summary page. This is searched for in the classpath.

Parameters:
testCaseResultTemplate - The template to be used to generate the test case result page.This attribute is recognized by Jameleon

getTestCaseResultTemplate

p