net.sf.jameleon
Class SessionTag

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.SessionTag
All Implemented Interfaces:
Attributable, DataDrivableResultRecordable, FunctionResultRecordable, Storable, DynaTag, LocationAware, Tag
Direct Known Subclasses:
JUnitSessionTag

public abstract class SessionTag
extends JameleonTagSupport
implements Storable, FunctionResultRecordable, DataDrivableResultRecordable

A Session is the state of an application from one functional point to the next. In order to allow for independent functional points, a handle on the application's state must be kept between functional points. This handle is implemented differently for each application interface technology. Some examples of interfaces might be a GUI application implemented in Swing or .NET, an HTTP application or even a SQL inteface to the database.

A SessionTag is required for every interface, even those that don't require a handle on the application to be shared across the many functional points. There should still be a generic way to start and stop the application. A SessionTag is also a means to use only variables defined in Applications.properties that are pertinent to a particular application and it helps separate the autogenerated docs when accessing several applications in a test.

Implementing an interface-specific SessionTag includes implementing the following methods:

If the application type being tested supplies some kind of handle, then the SessionTag is the appropriate place to keep it. Create an instance variable representing the application's handle and provide a public get and set method for it. The abstract function tag will then get an instance of this SessionTag and get the handle off the application.

This base class is interface agnostic and implements all Jameleon-specific behavior. The following is a list of supported attributes supported by this class:


Field Summary
protected  AbstractDataDrivableTag addt
           
protected  String application
          The name of the application being run according to the *-TestCaseTag.properties file
protected  boolean beginSession
          Starts the applicattion and gets it to the state defined in the $testEnviroment-Applications.properties.
protected static org.apache.log4j.Logger log
           
protected  String organization
          The organization (affiliate or company name) this application will be tested against.
protected  boolean postcondition
           
protected  Properties props
           
protected  long sessionDelay
          Sets the tag to delay x milliseconds before anything else is executed.
protected  SessionResult sessionResults
           
protected  TestCaseTag tc
           
 
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
SessionTag()
          Default constructor.
 
Method Summary
protected  void delaySession()
           
 void doTag(XMLOutput out)
          A TagSupport specific method.
protected  void findParentTestCase()
           
 String getApplication()
          The name of the application being run according to the *-TestCaseTag.properties file
 String getOrganization()
           
 SessionResult getSessionResult()
           
 String getStoreToFileName(int event)
          Gets the filename to store the state of the application to.
protected  void init()
          Grabs information about the application and the organization from the test case.
 void recordDataDrivableResult(DataDrivableResultContainer result)
          Records a DataDrivableResultContainer 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)
           
protected  void removeChildlessResult()
          Removes the current result from its parent if it has no children, meaning the tags weren't actually run
 void setOrganization(String organization)
           
 void setSessionDelay(long sessionDelay)
           
 void setUpSession()
          Is called before anything else specific to the interface is called.
 void startApplication()
          Used for the plug-in to implement if something special is required during the session setup.
 void store(String filename, int event)
           Stores the current state of the object to a given File.
protected  void tearDown()
           
protected  void tearDownSession()
          Called when the session tag is closed.
protected  void trace(String msg)
          Deprecated. - use traceMsg instead.
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

sessionResults

protected SessionResult sessionResults

application

protected String application
The name of the application being run according to the *-TestCaseTag.properties file

This attribute is recognized by Jameleon

organization

protected String organization
The organization (affiliate or company name) this application will be tested against.

This attribute is recognized by Jameleon

postcondition

protected boolean postcondition
This attribute is recognized by Jameleon

sessionDelay

protected long sessionDelay
Sets the tag to delay x milliseconds before anything else is executed.

This attribute is recognized by Jameleon
Default Value: 0

log

protected static org.apache.log4j.Logger log

props

protected Properties props

tc

protected TestCaseTag tc

addt

protected AbstractDataDrivableTag addt

beginSession

protected boolean beginSession
Starts the applicattion and gets it to the state defined in the $testEnviroment-Applications.properties. DEFAULTS to false

This attribute is recognized by Jameleon
Constructor Detail

SessionTag

public SessionTag()
Default constructor. Currently it does nothing.

Method Detail

getOrganization

public String getOrganization()
Returns:
the organization (affiliate or company name) this application will be tested against. This would used for when there is one application for many different datasources like a shopping being installed against several different customers. This is also important because the URLs change between organizations as well.

setOrganization

public void setOrganization(String organization)

getApplication

public String getApplication()
The name of the application being run according to the *-TestCaseTag.properties file

Returns:
the name of the application being run under this session.

setSessionDelay

public void setSessionDelay(long sessionDelay)

doTag

public void doTag(XMLOutput out)
           throws MissingAttributeException,
                  JellyTagException
A TagSupport specific method. This method calls any or all sub element tags ( like function point tags ).

Specified by:
doTag in interface Tag
Throws:
MissingAttributeException
JellyTagException

tearDown

protected void tearDown()

trace

protected void trace(String msg)
Deprecated. - use traceMsg instead.

Used for the trace functionality. Only sends info to the log if trace is enabled.


traceMsg

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


store

public void store(String filename,
                  int event)
           throws IOException

Stores the current state of the object to a given File. The default implementation of this method does nothing. Override this method to implement plug-in specific behavior. Some examples might be:

A listener is already registered for each function tag. All that is required is implementing this method.

Specified by:
store in interface Storable
Parameters:
filename - the name of the if the file to store the contents to.
event - The event that occured (error, state change ...).
Throws:
IOException - If the state of the object could not be stored in File f.

getStoreToFileName

public String getStoreToFileName(int event)
Gets the filename to store the state of the application to. The default implementation is to simply use timestamps. If this is not the desired behavior, override this method.

Specified by:
getStoreToFileName in interface Storable
Parameters:
event - - the StateStorer Event
Returns:
the appropriate filename which starts with ERROR- if the StateStorer Event was an Error

tearDownSession

protected void tearDownSession()
Called when the session tag is closed. This should clean up all plug-in specific resources created by this session.


findParentTestCase

protected void findParentTestCase()

init

protected void init()
             throws MissingAttributeException
Grabs information about the application and the organization from the test case. Adds the test case results to the session results so that overall statistics will be kept in the test case results.

Throws:
MissingAttributeException

getSessionResult

public SessionResult getSessionResult()
Returns:
The results of this session. This should contain all environment variables used as well as all of the asserts.

setUpSession

public void setUpSession()
Is called before anything else specific to the interface is called. This method should create all resources required for this session to begin. The default behavior is to do nothing.


startApplication

public void startApplication()
Used for the plug-in to implement if something special is required during the session setup. The properties from the CSV and testEnvironment.properties are setup before this method is called. The default implementation does nothing.


delaySession

protected void delaySession()

removeChildlessResult

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


recordResult

protected void recordResult(JameleonTestResult 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 -

recordDataDrivableResult

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

Specified by:
recordDataDrivableResult in interface DataDrivableResultRecordable
Parameters:
result -


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