org.specrunner.plugins.core
Class AbstractPlugin

java.lang.Object
  extended by org.specrunner.parameters.core.ParameterHolder
      extended by org.specrunner.plugins.core.AbstractPlugin
All Implemented Interfaces:
IParameterHolder, IActionType, IParalelPlugin, IPlugin, ISleepPlugin, ITestPlugin, ITimedPlugin, IWaitPlugin
Direct Known Subclasses:
AbstractPluginNamed, AbstractPluginResource, PluginAssertion, PluginCompareTree, PluginFor, PluginInclude, PluginNop, PluginPause, PluginReplacer, PluginReplacerMap, PluginSentence

public abstract class AbstractPlugin
extends ParameterHolder
implements IPlugin, ITestPlugin, IWaitPlugin, ISleepPlugin, ITimedPlugin, IParalelPlugin

Adapter for plugins.

Author:
Thiago Santos

Field Summary
static String FEATURE_CONDITION
          Default conditional feature.
static String FEATURE_NORMALIZED
          Feature to set normalized state.
static String FEATURE_SLEEP
          Default sleep time feature.
static String FEATURE_THREADSAFE
          Default threadsafe feature.
static String FEATURE_TIMEOUT
          Default timeout time feature.
static String FEATURE_WAIT
          Default wait time feature.
 
Constructor Summary
AbstractPlugin()
          Default constructor.
 
Method Summary
 IPlugin copy(IContext context)
          Creates a copy of this plugin.
 void doEnd(IContext context, IResultSet result)
          The end action. i.e. after a loop specification perform something in a newly generated table.
 ENext doStart(IContext context, IResultSet result)
          Performs the start action. i.e. create a database schema.
 Boolean getCondition()
          Get the plugin execution condition.
 IModel<Boolean> getConditionModel()
          Get the plugin execution condition model.
 Boolean getNormalized()
          If normalized is false, the expected and received String are not compared using their normalized version (trim+remove extra spaces).
 String getNormalized(String str)
          Get the normalized version of a string.
 IPluginFactory getParent()
          Get the plugin factory source.
 Long getSleep()
          The plugin timeout.
 IModel<Long> getSleepModel()
          Return the sleep based on a model.
 Boolean getThreadsafe()
          The plugin thread safe status.
 Long getTimeout()
          The plugin timeout.
 IModel<Long> getTimeoutModel()
          Model for timeout testing.
 Long getWait()
          The plugin wait time.
 IModel<Long> getWaitModel()
          Return the wait based on a model.
 void initialize(IContext context)
          Initialize the plugin.
 void setCondition(Boolean condition)
          Set plugin condition.
 void setConditionModel(IModel<Boolean> conditionModel)
          Set plugin condition model.
 void setNormalized(Boolean normalized)
          Set the normalized state.
 void setParent(IPluginFactory parent)
          Set the plugin factory (where it came from).
 void setSleep(Long sleep)
          Gets time to sleep in milliseconds after test action.
 void setSleepModel(IModel<Long> sleepModel)
          Set sleep model object.
 void setThreadsafe(Boolean threadsafe)
          Set the thread safe status.
 void setTimeout(Long timeout)
          Set the plugin timeout.
 void setTimeoutModel(IModel<Long> timeoutModel)
          Set the model.
 void setWait(Long wait)
          Gets time to sleep in milliseconds before test action.
 void setWaitModel(IModel<Long> waitModel)
          Set wait model object.
 String toString()
           
 
Methods inherited from class org.specrunner.parameters.core.ParameterHolder
getParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.specrunner.parameters.IParameterHolder
getParameters, setParameters
 
Methods inherited from interface org.specrunner.plugins.IActionType
getActionType
 

Field Detail

FEATURE_CONDITION

public static final String FEATURE_CONDITION
Default conditional feature.


FEATURE_WAIT

public static final String FEATURE_WAIT
Default wait time feature.


FEATURE_SLEEP

public static final String FEATURE_SLEEP
Default sleep time feature.


FEATURE_TIMEOUT

public static final String FEATURE_TIMEOUT
Default timeout time feature.


FEATURE_THREADSAFE

public static final String FEATURE_THREADSAFE
Default threadsafe feature.


FEATURE_NORMALIZED

public static final String FEATURE_NORMALIZED
Feature to set normalized state.

Constructor Detail

AbstractPlugin

public AbstractPlugin()
Default constructor.

Method Detail

getParent

public IPluginFactory getParent()
Description copied from interface: IPlugin
Get the plugin factory source.

Specified by:
getParent in interface IPlugin
Returns:
The plugin.

setParent

public void setParent(IPluginFactory parent)
Description copied from interface: IPlugin
Set the plugin factory (where it came from).

Specified by:
setParent in interface IPlugin
Parameters:
parent - The factory.

initialize

public void initialize(IContext context)
                throws PluginException
Description copied from interface: IPlugin
Initialize the plugin. Performed after set parameters.

Specified by:
initialize in interface IPlugin
Parameters:
context - The test context.
Throws:
PluginException - On initialization errors.

doStart

public ENext doStart(IContext context,
                     IResultSet result)
              throws PluginException
Description copied from interface: IPlugin
Performs the start action. i.e. create a database schema. Performed after initialization.

Specified by:
doStart in interface IPlugin
Parameters:
context - The context.
result - The result set.
Returns:
SKIP, to skip node, DEEP, to go deep into the node.
Throws:
PluginException - On execution errors.

doEnd

public void doEnd(IContext context,
                  IResultSet result)
           throws PluginException
Description copied from interface: IPlugin
The end action. i.e. after a loop specification perform something in a newly generated table. Performed after doStart().

Specified by:
doEnd in interface IPlugin
Parameters:
context - The context.
result - The result set.
Throws:
PluginException - On execution errors.

copy

public IPlugin copy(IContext context)
             throws PluginException
Description copied from interface: IPlugin
Creates a copy of this plugin.

Specified by:
copy in interface IPlugin
Parameters:
context - The context.
Returns:
A copy.
Throws:
PluginException - On copy errors.

getCondition

public Boolean getCondition()
Description copied from interface: ITestPlugin
Get the plugin execution condition.

Specified by:
getCondition in interface ITestPlugin
Returns:
The condition is some expression which returns true, or false.

setCondition

public void setCondition(Boolean condition)
Description copied from interface: ITestPlugin
Set plugin condition.

Specified by:
setCondition in interface ITestPlugin
Parameters:
condition - The plugin condition.

getConditionModel

public IModel<Boolean> getConditionModel()
Description copied from interface: ITestPlugin
Get the plugin execution condition model.

Specified by:
getConditionModel in interface ITestPlugin
Returns:
The condition is some expression which returns true, or false.

setConditionModel

public void setConditionModel(IModel<Boolean> conditionModel)
Description copied from interface: ITestPlugin
Set plugin condition model.

Specified by:
setConditionModel in interface ITestPlugin
Parameters:
conditionModel - The plugin condition model.

getWait

public Long getWait()
Description copied from interface: IWaitPlugin
The plugin wait time.

Specified by:
getWait in interface IWaitPlugin
Returns:
The wait time.

setWait

public void setWait(Long wait)
Description copied from interface: IWaitPlugin
Gets time to sleep in milliseconds before test action. This wait can be programatically added as a 'wait' attribute. The use of wait can be used for example, to overcome JavaScript problems, for example you can set wait to '4000' which means ISpecRunner will wait this time before go on.

Specified by:
setWait in interface IWaitPlugin
Parameters:
wait - Wait time.

getWaitModel

public IModel<Long> getWaitModel()
Description copied from interface: IWaitPlugin
Return the wait based on a model.

Specified by:
getWaitModel in interface IWaitPlugin
Returns:
A model.

setWaitModel

public void setWaitModel(IModel<Long> waitModel)
Description copied from interface: IWaitPlugin
Set wait model object.

Specified by:
setWaitModel in interface IWaitPlugin
Parameters:
waitModel - The model.

getSleep

public Long getSleep()
Description copied from interface: ISleepPlugin
The plugin timeout.

Specified by:
getSleep in interface ISleepPlugin
Returns:
The timeout.

setSleep

public void setSleep(Long sleep)
Description copied from interface: ISleepPlugin
Gets time to sleep in milliseconds after test action. This sleep can be programatically added as a 'sleep' attribute. The use of sleep can be used for example, to overcome JavaScript problems, for example you can set sleep to '4000' which means the action will wait this time before leaving the ISpecRunner go on.

Specified by:
setSleep in interface ISleepPlugin
Parameters:
sleep - Sleep time.

getSleepModel

public IModel<Long> getSleepModel()
Description copied from interface: ISleepPlugin
Return the sleep based on a model.

Specified by:
getSleepModel in interface ISleepPlugin
Returns:
A model.

setSleepModel

public void setSleepModel(IModel<Long> sleepModel)
Description copied from interface: ISleepPlugin
Set sleep model object.

Specified by:
setSleepModel in interface ISleepPlugin
Parameters:
sleepModel - The model.

getTimeout

public Long getTimeout()
Description copied from interface: ITimedPlugin
The plugin timeout.

Specified by:
getTimeout in interface ITimedPlugin
Returns:
The timeout.

setTimeout

public void setTimeout(Long timeout)
Description copied from interface: ITimedPlugin
Set the plugin timeout.

Specified by:
setTimeout in interface ITimedPlugin
Parameters:
timeout - The plugin timeout.

getTimeoutModel

public IModel<Long> getTimeoutModel()
Description copied from interface: ITimedPlugin
Model for timeout testing.

Specified by:
getTimeoutModel in interface ITimedPlugin
Returns:
The timeout model.

setTimeoutModel

public void setTimeoutModel(IModel<Long> timeoutModel)
Description copied from interface: ITimedPlugin
Set the model.

Specified by:
setTimeoutModel in interface ITimedPlugin
Parameters:
timeoutModel - A time model.

getThreadsafe

public Boolean getThreadsafe()
Description copied from interface: IParalelPlugin
The plugin thread safe status.

Specified by:
getThreadsafe in interface IParalelPlugin
Returns:
The thread safe status.

setThreadsafe

public void setThreadsafe(Boolean threadsafe)
Description copied from interface: IParalelPlugin
Set the thread safe status.

Specified by:
setThreadsafe in interface IParalelPlugin
Parameters:
threadsafe - The plugin thread safe flag.

getNormalized

public Boolean getNormalized()
If normalized is false, the expected and received String are not compared using their normalized version (trim+remove extra spaces).

Returns:
If normalized is enable or not.

setNormalized

public void setNormalized(Boolean normalized)
Set the normalized state.

Parameters:
normalized - true, to normalize, false, otherwise.

getNormalized

public String getNormalized(String str)
Get the normalized version of a string.

Parameters:
str - The string to be normalized.
Returns:
The normalized version of the string, if normalized=true.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014. All rights reserved.