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 void
addPropertiesValues(List<String> result, Set<String> propertyNames)
Add to result the values of propertyNamesprotected void
addProperty(JMeterProperty property)
Add property to test element without cloning itprotected void
addProperty(JMeterProperty property, boolean clone)
Add property to test elementvoid
addTestElement(TestElement el)
boolean
canRemove()
Called by Remove to determine if it is safe to remove the element.void
clear()
Clear the TestElement of all data.protected void
clearTemporary(JMeterProperty property)
Remove property from temporaryPropertiesvoid
clearTestElementChildren()
This method should clear any test element properties that are merged byTestElement.addTestElement(TestElement)
.Object
clone()
protected void
emptyTemporary()
Clears temporaryPropertiesboolean
equals(Object o)
String
getComment()
String
getName()
Get the name of this test elementJMeterProperty
getProperty(String key)
Get the named property.boolean
getPropertyAsBoolean(String key)
Return a property as a boolean value.boolean
getPropertyAsBoolean(String key, boolean defaultVal)
Return a property as a boolean value or a default value if no property could be found.double
getPropertyAsDouble(String key)
Return a property as a double value.float
getPropertyAsFloat(String key)
Return a property as a float value.int
getPropertyAsInt(String key)
Return a property as an int value.int
getPropertyAsInt(String key, int defaultValue)
Return a property as an int value or a default value if no property could be found.long
getPropertyAsLong(String key)
Return a property as a long value.long
getPropertyAsLong(String key, long defaultValue)
Return a property as a long value or a default value if no property could be found.String
getPropertyAsString(String key)
Return a property as a string value.String
getPropertyAsString(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 searchingJMeterContext
getThreadContext()
String
getThreadName()
int
hashCode()
boolean
isEnabled()
Check if ENABLED property is present and true ; defaults to trueboolean
isRunningVersion()
Returns the runningVersion.boolean
isTemporary(JMeterProperty property)
Test whether a given property is only a temporary resident of the TestElementprotected void
logProperties()
Log the properties of the test elementprotected void
mergeIn(TestElement element)
Add to this the properties of element (by reference)PropertyIterator
propertyIterator()
Get a Property Iterator for the TestElements properties.void
recoverRunningVersion()
Tells the test element to return to the state it was in when setRunningVersion(true) was called.void
removeProperty(String key)
Remove property stored under thekey
void
setComment(String comment)
Associates a comment with this elementvoid
setEnabled(boolean enabled)
Set the enabled status of the test elementvoid
setName(String name)
void
setProperty(String name, boolean value)
void
setProperty(String name, boolean value, boolean dflt)
Create a boolean property - but only if it is not the default.void
setProperty(String name, int value)
void
setProperty(String name, int value, int dflt)
Create an int property - but only if it is not the default.void
setProperty(String name, long value)
void
setProperty(String name, long value, long dflt)
Create a long property - but only if it is not the default.void
setProperty(String name, String value)
void
setProperty(String name, String value, String dflt)
Create a String property - but only if it is not the default.void
setProperty(JMeterProperty property)
Sets and overwrites a property in the TestElement.void
setRunningVersion(boolean runningVersion)
Sets the runningVersion.void
setTemporary(JMeterProperty property)
Indicate that the given property should be only a temporary property in the TestElementvoid
setThreadContext(JMeterContext inthreadContext)
void
setThreadName(String inthreadName)
void
traverse(TestElementTraverser traverser)
Convenient way to traverse a test element.protected void
traverseCollection(CollectionProperty col, TestElementTraverser traverser)
protected void
traverseMap(MapProperty map, TestElementTraverser traverser)
protected void
traverseProperty(TestElementTraverser traverser, JMeterProperty value)
-
-
-
Method Detail
-
clone
public Object clone()
- Specified by:
clone
in interfaceTestElement
- Overrides:
clone
in classObject
-
clear
public void clear()
Clear the TestElement of all data.- Specified by:
clear
in 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:
clearTestElementChildren
in interfaceTestElement
-
removeProperty
public void removeProperty(String key)
Remove property stored under thekey
- Specified by:
removeProperty
in interfaceTestElement
- Parameters:
key
- name of the property to be removed
-
addTestElement
public void addTestElement(TestElement el)
- Specified by:
addTestElement
in interfaceTestElement
-
setName
public void setName(String name)
- Specified by:
setName
in interfaceTestElement
- Parameters:
name
- of this element
-
getName
public String getName()
Description copied from interface:TestElement
Get the name of this test element- Specified by:
getName
in interfaceTestElement
- Returns:
- name of this element
-
setComment
public void setComment(String comment)
Description copied from interface:TestElement
Associates a comment with this element- Specified by:
setComment
in interfaceTestElement
- Parameters:
comment
- to be associated
-
getComment
public String getComment()
- Specified by:
getComment
in 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:
getProperty
in interfaceTestElement
- Parameters:
key
- the name of the property to get- Returns:
JMeterProperty
stored under the name, orNullProperty
if no property can be found
-
traverse
public void traverse(TestElementTraverser traverser)
Description copied from interface:TestElement
Convenient way to traverse a test element.- Specified by:
traverse
in 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:TestElement
Return a property as an int value.- Specified by:
getPropertyAsInt
in 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:TestElement
Return a property as an int value or a default value if no property could be found.- Specified by:
getPropertyAsInt
in interfaceTestElement
- Parameters:
key
- the name of the property to getdefaultValue
- the default value to use- Returns:
- the value of the property, or
defaultValue
if no property could be found
-
getPropertyAsBoolean
public boolean getPropertyAsBoolean(String key)
Description copied from interface:TestElement
Return a property as a boolean value.- Specified by:
getPropertyAsBoolean
in 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:TestElement
Return a property as a boolean value or a default value if no property could be found.- Specified by:
getPropertyAsBoolean
in interfaceTestElement
- Parameters:
key
- the name of the property to getdefaultVal
- the default value to use- Returns:
- the value of the property, or
defaultValue
if no property could be found
-
getPropertyAsFloat
public float getPropertyAsFloat(String key)
Description copied from interface:TestElement
Return a property as a float value.- Specified by:
getPropertyAsFloat
in 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:TestElement
Return a property as a long value.- Specified by:
getPropertyAsLong
in 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:TestElement
Return a property as a long value or a default value if no property could be found.- Specified by:
getPropertyAsLong
in interfaceTestElement
- Parameters:
key
- the name of the property to getdefaultValue
- the default value to use- Returns:
- the value of the property, or
defaultValue
if no property could be found
-
getPropertyAsDouble
public double getPropertyAsDouble(String key)
Description copied from interface:TestElement
Return a property as a double value.- Specified by:
getPropertyAsDouble
in 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:TestElement
Return a property as a string value.- Specified by:
getPropertyAsString
in 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:TestElement
Return a property as an string value or a default value if no property could be found.- Specified by:
getPropertyAsString
in interfaceTestElement
- Parameters:
key
- the name of the property to getdefaultValue
- the default value to use- Returns:
- the value of the property, or
defaultValue
if no property could be found
-
addProperty
protected void addProperty(JMeterProperty property, boolean clone)
Add property to test element- Parameters:
property
-JMeterProperty
to 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:TestElement
Sets and overwrites a property in the TestElement. This call will be ignored if the TestElement is currently a "running version".- Specified by:
setProperty
in interfaceTestElement
- Parameters:
property
- the property to be set
-
setProperty
public void setProperty(String name, String value)
- Specified by:
setProperty
in 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:
setProperty
in interfaceTestElement
- Parameters:
name
- property namevalue
- current valuedflt
- default
-
setProperty
public void setProperty(String name, boolean value)
- Specified by:
setProperty
in 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:
setProperty
in interfaceTestElement
- Parameters:
name
- property namevalue
- current valuedflt
- default
-
setProperty
public void setProperty(String name, int value)
- Specified by:
setProperty
in 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:
setProperty
in interfaceTestElement
- Parameters:
name
- property namevalue
- current valuedflt
- default
-
setProperty
public void setProperty(String name, long value)
- Specified by:
setProperty
in 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:
setProperty
in interfaceTestElement
- Parameters:
name
- property namevalue
- current valuedflt
- default
-
propertyIterator
public PropertyIterator propertyIterator()
Description copied from interface:TestElement
Get a Property Iterator for the TestElements properties.- Specified by:
propertyIterator
in 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:
isRunningVersion
in interfaceTestElement
- Returns:
true
if the element is the running version
-
setRunningVersion
public void setRunningVersion(boolean runningVersion)
Sets the runningVersion.- Specified by:
setRunningVersion
in 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:
recoverRunningVersion
in 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:
isTemporary
in interfaceTestElement
- Parameters:
property
- the property to be tested- Returns:
true
if 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:
setTemporary
in interfaceTestElement
- Parameters:
property
- void
-
getThreadContext
public JMeterContext getThreadContext()
- Specified by:
getThreadContext
in interfaceTestElement
- Returns:
- Returns the threadContext.
-
setThreadContext
public void setThreadContext(JMeterContext inthreadContext)
- Specified by:
setThreadContext
in interfaceTestElement
- Parameters:
inthreadContext
- The threadContext to set.
-
getThreadName
public String getThreadName()
- Specified by:
getThreadName
in interfaceTestElement
- Returns:
- Returns the threadName.
-
setThreadName
public void setThreadName(String inthreadName)
- Specified by:
setThreadName
in 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:
canRemove
in interfaceTestElement
- Returns:
- true if safe to remove the element
-
isEnabled
public boolean isEnabled()
Description copied from interface:TestElement
Check if ENABLED property is present and true ; defaults to true- Specified by:
isEnabled
in interfaceTestElement
- Returns:
- true if element is enabled
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:TestElement
Set the enabled status of the test element- Specified by:
setEnabled
in 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:
getSearchableTokens
in interfaceSearchable
- Returns:
- List of searchable tokens
-
-