Package org.apache.jmeter.testelement
Class AbstractTestElement
- java.lang.Object
-
- org.apache.jmeter.testelement.AbstractTestElement
-
- All Implemented Interfaces:
Serializable,Cloneable,Searchable,TestElement
- Direct Known Subclasses:
AbstractJDBCTestElement,AbstractListenerElement,AbstractSampler,AbstractScopedTestElement,AbstractThreadGroup,AnchorModifier,Argument,Authorization,BackendListener,BeanShellTestElement,CompareAssertion,ConfigTestElement,ConstantThroughputTimer,ConstantTimer,Cookie,CounterConfig,DataSourceElement,DebugPostProcessor,GenericController,Header,HTMLAssertion,HTTPFileArg,HttpMirrorControl,JMSProperties,JMSProperty,LDAPArgument,MailerModel,MD5HexAssertion,MonitorStats,OnErrorTestElement,ParamMask,ParamModifier,RegExUserParameters,RemoteListenerWrapper,RemoteSampleListenerWrapper,RemoteTestListenerWrapper,RemoteThreadsListenerWrapper,ResultSaver,ScriptingTestElement,SMIMEAssertionTestElement,SubstitutionElement,Summariser,SyncTimer,TestPlan,URLRewritingModifier,UserParameters,WorkBench,XMLAssertion,XMLSchemaAssertion
public abstract class AbstractTestElement extends Object implements TestElement, Serializable, Searchable
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.apache.jmeter.testelement.TestElement
COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS
-
-
Constructor Summary
Constructors Constructor Description AbstractTestElement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddPropertiesValues(List<String> result, Set<String> propertyNames)Add to result the values of propertyNamesprotected voidaddProperty(JMeterProperty property)Add property to test element without cloning itprotected voidaddProperty(JMeterProperty property, boolean clone)Add property to test elementvoidaddTestElement(TestElement el)booleancanRemove()Called by Remove to determine if it is safe to remove the element.voidclear()Clear the TestElement of all data.protected voidclearTemporary(JMeterProperty property)Remove property from temporaryPropertiesvoidclearTestElementChildren()This method should clear any test element properties that are merged byTestElement.addTestElement(TestElement).Objectclone()protected voidemptyTemporary()Clears temporaryPropertiesbooleanequals(Object o)StringgetComment()StringgetName()Get the name of this test elementJMeterPropertygetProperty(String key)Get the named property.booleangetPropertyAsBoolean(String key)Return a property as a boolean value.booleangetPropertyAsBoolean(String key, boolean defaultVal)Return a property as a boolean value or a default value if no property could be found.doublegetPropertyAsDouble(String key)Return a property as a double value.floatgetPropertyAsFloat(String key)Return a property as a float value.intgetPropertyAsInt(String key)Return a property as an int value.intgetPropertyAsInt(String key, int defaultValue)Return a property as an int value or a default value if no property could be found.longgetPropertyAsLong(String key)Return a property as a long value.longgetPropertyAsLong(String key, long defaultValue)Return a property as a long value or a default value if no property could be found.StringgetPropertyAsString(String key)Return a property as a string value.StringgetPropertyAsString(String key, String defaultValue)Return a property as an string value or a default value if no property could be found.List<String>getSearchableTokens()Get a list of all tokens that should be visible to searchingJMeterContextgetThreadContext()StringgetThreadName()inthashCode()booleanisEnabled()Check if ENABLED property is present and true ; defaults to truebooleanisRunningVersion()Returns the runningVersion.booleanisTemporary(JMeterProperty property)Test whether a given property is only a temporary resident of the TestElementprotected voidlogProperties()Log the properties of the test elementprotected voidmergeIn(TestElement element)Add to this the properties of element (by reference)PropertyIteratorpropertyIterator()Get a Property Iterator for the TestElements properties.voidrecoverRunningVersion()Tells the test element to return to the state it was in when setRunningVersion(true) was called.voidremoveProperty(String key)Remove property stored under thekeyvoidsetComment(String comment)Associates a comment with this elementvoidsetEnabled(boolean enabled)Set the enabled status of the test elementvoidsetName(String name)voidsetProperty(String name, boolean value)voidsetProperty(String name, boolean value, boolean dflt)Create a boolean property - but only if it is not the default.voidsetProperty(String name, int value)voidsetProperty(String name, int value, int dflt)Create an int property - but only if it is not the default.voidsetProperty(String name, long value)voidsetProperty(String name, long value, long dflt)Create a long property - but only if it is not the default.voidsetProperty(String name, String value)voidsetProperty(String name, String value, String dflt)Create a String property - but only if it is not the default.voidsetProperty(JMeterProperty property)Sets and overwrites a property in the TestElement.voidsetRunningVersion(boolean runningVersion)Sets the runningVersion.voidsetTemporary(JMeterProperty property)Indicate that the given property should be only a temporary property in the TestElementvoidsetThreadContext(JMeterContext inthreadContext)voidsetThreadName(String inthreadName)voidtraverse(TestElementTraverser traverser)Convenient way to traverse a test element.protected voidtraverseCollection(CollectionProperty col, TestElementTraverser traverser)protected voidtraverseMap(MapProperty map, TestElementTraverser traverser)protected voidtraverseProperty(TestElementTraverser traverser, JMeterProperty value)
-
-
-
Method Detail
-
clone
public Object clone()
- Specified by:
clonein interfaceTestElement- Overrides:
clonein classObject
-
clear
public void clear()
Clear the TestElement of all data.- Specified by:
clearin interfaceTestElement
-
clearTestElementChildren
public void clearTestElementChildren()
This method should clear any test element properties that are merged byTestElement.addTestElement(TestElement).Default implementation - does nothing
- Specified by:
clearTestElementChildrenin interfaceTestElement
-
removeProperty
public void removeProperty(String key)
Remove property stored under thekey- Specified by:
removePropertyin interfaceTestElement- Parameters:
key- name of the property to be removed
-
addTestElement
public void addTestElement(TestElement el)
- Specified by:
addTestElementin interfaceTestElement
-
setName
public void setName(String name)
- Specified by:
setNamein interfaceTestElement- Parameters:
name- of this element
-
getName
public String getName()
Description copied from interface:TestElementGet the name of this test element- Specified by:
getNamein interfaceTestElement- Returns:
- name of this element
-
setComment
public void setComment(String comment)
Description copied from interface:TestElementAssociates a comment with this element- Specified by:
setCommentin interfaceTestElement- Parameters:
comment- to be associated
-
getComment
public String getComment()
- Specified by:
getCommentin interfaceTestElement- Returns:
- comment associated with this element
-
getProperty
public JMeterProperty getProperty(String key)
Get the named property. If it doesn't exist, a new NullProperty object is created with the same name and returned.- Specified by:
getPropertyin interfaceTestElement- Parameters:
key- the name of the property to get- Returns:
JMeterPropertystored under the name, orNullPropertyif no property can be found
-
traverse
public void traverse(TestElementTraverser traverser)
Description copied from interface:TestElementConvenient way to traverse a test element.- Specified by:
traversein interfaceTestElement- Parameters:
traverser- The traverser that is notified of the contained elements
-
traverseProperty
protected void traverseProperty(TestElementTraverser traverser, JMeterProperty value)
-
traverseMap
protected void traverseMap(MapProperty map, TestElementTraverser traverser)
-
traverseCollection
protected void traverseCollection(CollectionProperty col, TestElementTraverser traverser)
-
getPropertyAsInt
public int getPropertyAsInt(String key)
Description copied from interface:TestElementReturn a property as an int value.- Specified by:
getPropertyAsIntin interfaceTestElement- Parameters:
key- the name of the property to get- Returns:
- the value of the property
-
getPropertyAsInt
public int getPropertyAsInt(String key, int defaultValue)
Description copied from interface:TestElementReturn a property as an int value or a default value if no property could be found.- Specified by:
getPropertyAsIntin interfaceTestElement- Parameters:
key- the name of the property to getdefaultValue- the default value to use- Returns:
- the value of the property, or
defaultValueif no property could be found
-
getPropertyAsBoolean
public boolean getPropertyAsBoolean(String key)
Description copied from interface:TestElementReturn a property as a boolean value.- Specified by:
getPropertyAsBooleanin interfaceTestElement- Parameters:
key- the name of the property to get- Returns:
- the value of the property
-
getPropertyAsBoolean
public boolean getPropertyAsBoolean(String key, boolean defaultVal)
Description copied from interface:TestElementReturn a property as a boolean value or a default value if no property could be found.- Specified by:
getPropertyAsBooleanin interfaceTestElement- Parameters:
key- the name of the property to getdefaultVal- the default value to use- Returns:
- the value of the property, or
defaultValueif no property could be found
-
getPropertyAsFloat
public float getPropertyAsFloat(String key)
Description copied from interface:TestElementReturn a property as a float value.- Specified by:
getPropertyAsFloatin interfaceTestElement- Parameters:
key- the name of the property to get- Returns:
- the value of the property
-
getPropertyAsLong
public long getPropertyAsLong(String key)
Description copied from interface:TestElementReturn a property as a long value.- Specified by:
getPropertyAsLongin interfaceTestElement- Parameters:
key- the name of the property to get- Returns:
- the value of the property
-
getPropertyAsLong
public long getPropertyAsLong(String key, long defaultValue)
Description copied from interface:TestElementReturn a property as a long value or a default value if no property could be found.- Specified by:
getPropertyAsLongin interfaceTestElement- Parameters:
key- the name of the property to getdefaultValue- the default value to use- Returns:
- the value of the property, or
defaultValueif no property could be found
-
getPropertyAsDouble
public double getPropertyAsDouble(String key)
Description copied from interface:TestElementReturn a property as a double value.- Specified by:
getPropertyAsDoublein interfaceTestElement- Parameters:
key- the name of the property to get- Returns:
- the value of the property
-
getPropertyAsString
public String getPropertyAsString(String key)
Description copied from interface:TestElementReturn a property as a string value.- Specified by:
getPropertyAsStringin interfaceTestElement- Parameters:
key- the name of the property to get- Returns:
- the value of the property
-
getPropertyAsString
public String getPropertyAsString(String key, String defaultValue)
Description copied from interface:TestElementReturn a property as an string value or a default value if no property could be found.- Specified by:
getPropertyAsStringin interfaceTestElement- Parameters:
key- the name of the property to getdefaultValue- the default value to use- Returns:
- the value of the property, or
defaultValueif no property could be found
-
addProperty
protected void addProperty(JMeterProperty property, boolean clone)
Add property to test element- Parameters:
property-JMeterPropertyto add to current Test Elementclone- clone property
-
addProperty
protected void addProperty(JMeterProperty property)
Add property to test element without cloning it- Parameters:
property-JMeterProperty
-
clearTemporary
protected void clearTemporary(JMeterProperty property)
Remove property from temporaryProperties- Parameters:
property-JMeterProperty
-
logProperties
protected void logProperties()
Log the properties of the test element- See Also:
TestElement.setProperty(JMeterProperty)
-
setProperty
public void setProperty(JMeterProperty property)
Description copied from interface:TestElementSets and overwrites a property in the TestElement. This call will be ignored if the TestElement is currently a "running version".- Specified by:
setPropertyin interfaceTestElement- Parameters:
property- the property to be set
-
setProperty
public void setProperty(String name, String value)
- Specified by:
setPropertyin interfaceTestElement
-
setProperty
public void setProperty(String name, String value, String dflt)
Create a String property - but only if it is not the default. This is intended for use when adding new properties to JMeter so that JMX files are not expanded unnecessarily. N.B. - must agree with the default applied when reading the property.- Specified by:
setPropertyin interfaceTestElement- Parameters:
name- property namevalue- current valuedflt- default
-
setProperty
public void setProperty(String name, boolean value)
- Specified by:
setPropertyin interfaceTestElement
-
setProperty
public void setProperty(String name, boolean value, boolean dflt)
Create a boolean property - but only if it is not the default. This is intended for use when adding new properties to JMeter so that JMX files are not expanded unnecessarily. N.B. - must agree with the default applied when reading the property.- Specified by:
setPropertyin interfaceTestElement- Parameters:
name- property namevalue- current valuedflt- default
-
setProperty
public void setProperty(String name, int value)
- Specified by:
setPropertyin interfaceTestElement
-
setProperty
public void setProperty(String name, int value, int dflt)
Create an int property - but only if it is not the default. This is intended for use when adding new properties to JMeter so that JMX files are not expanded unnecessarily. N.B. - must agree with the default applied when reading the property.- Specified by:
setPropertyin interfaceTestElement- Parameters:
name- property namevalue- current valuedflt- default
-
setProperty
public void setProperty(String name, long value)
- Specified by:
setPropertyin interfaceTestElement
-
setProperty
public void setProperty(String name, long value, long dflt)
Create a long property - but only if it is not the default. This is intended for use when adding new properties to JMeter so that JMX files are not expanded unnecessarily. N.B. - must agree with the default applied when reading the property.- Specified by:
setPropertyin interfaceTestElement- Parameters:
name- property namevalue- current valuedflt- default
-
propertyIterator
public PropertyIterator propertyIterator()
Description copied from interface:TestElementGet a Property Iterator for the TestElements properties.- Specified by:
propertyIteratorin interfaceTestElement- Returns:
- PropertyIterator
-
mergeIn
protected void mergeIn(TestElement element)
Add to this the properties of element (by reference)- Parameters:
element-TestElement
-
isRunningVersion
public boolean isRunningVersion()
Returns the runningVersion.- Specified by:
isRunningVersionin interfaceTestElement- Returns:
trueif the element is the running version
-
setRunningVersion
public void setRunningVersion(boolean runningVersion)
Sets the runningVersion.- Specified by:
setRunningVersionin interfaceTestElement- Parameters:
runningVersion- the runningVersion to set
-
recoverRunningVersion
public void recoverRunningVersion()
Tells the test element to return to the state it was in when setRunningVersion(true) was called.- Specified by:
recoverRunningVersionin interfaceTestElement
-
emptyTemporary
protected void emptyTemporary()
Clears temporaryProperties
-
isTemporary
public boolean isTemporary(JMeterProperty property)
Test whether a given property is only a temporary resident of the TestElement- Specified by:
isTemporaryin interfaceTestElement- Parameters:
property- the property to be tested- Returns:
trueif property is temporary
-
setTemporary
public void setTemporary(JMeterProperty property)
Indicate that the given property should be only a temporary property in the TestElement- Specified by:
setTemporaryin interfaceTestElement- Parameters:
property- void
-
getThreadContext
public JMeterContext getThreadContext()
- Specified by:
getThreadContextin interfaceTestElement- Returns:
- Returns the threadContext.
-
setThreadContext
public void setThreadContext(JMeterContext inthreadContext)
- Specified by:
setThreadContextin interfaceTestElement- Parameters:
inthreadContext- The threadContext to set.
-
getThreadName
public String getThreadName()
- Specified by:
getThreadNamein interfaceTestElement- Returns:
- Returns the threadName.
-
setThreadName
public void setThreadName(String inthreadName)
- Specified by:
setThreadNamein interfaceTestElement- Parameters:
inthreadName- The threadName to set.
-
canRemove
public boolean canRemove()
Called by Remove to determine if it is safe to remove the element. The element can either clean itself up, and return true, or the element can return false.- Specified by:
canRemovein interfaceTestElement- Returns:
- true if safe to remove the element
-
isEnabled
public boolean isEnabled()
Description copied from interface:TestElementCheck if ENABLED property is present and true ; defaults to true- Specified by:
isEnabledin interfaceTestElement- Returns:
- true if element is enabled
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:TestElementSet the enabled status of the test element- Specified by:
setEnabledin interfaceTestElement- Parameters:
enabled- the status to set
-
getSearchableTokens
public List<String> getSearchableTokens()
Get a list of all tokens that should be visible to searching}- Specified by:
getSearchableTokensin interfaceSearchable- Returns:
- List of searchable tokens
-
-