Apache JMeter

org.apache.jmeter.testelement
Class AbstractTestElement

java.lang.Object
  extended by org.apache.jmeter.testelement.AbstractTestElement
All Implemented Interfaces:
Serializable, Cloneable, Searchable, TestElement
Direct Known Subclasses:
AbstractChart, AbstractJDBCTestElement, AbstractListenerElement, AbstractReportWriter, AbstractSampler, AbstractScopedTestElement, AbstractTable, AbstractThreadGroup, AnchorModifier, Argument, Authorization, 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, ReportPage, ReportPlan, 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
AbstractTestElement()
           
 
Method Summary
protected  void addPropertiesValues(List<String> result, Set<String> propertyNames)
          Add to result the values of propertyNames
protected  void addProperty(JMeterProperty property)
          Add property to test element without cloning it
protected  void addProperty(JMeterProperty property, boolean clone)
          Add property to test element
 void 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 temporaryProperties
 void clearTestElementChildren()
          This method should clear any test element properties that are merged by TestElement.addTestElement(TestElement).
 Object clone()
           
protected  void emptyTemporary()
          Clears temporaryProperties
 boolean equals(Object o)
          
 String getComment()
           
 String getName()
           
 JMeterProperty getProperty(String key)
          Get the named property.
 boolean getPropertyAsBoolean(String key)
          Return a property as a boolean value.
 boolean getPropertyAsBoolean(String key, boolean defaultVal)
           
 double getPropertyAsDouble(String key)
           
 float getPropertyAsFloat(String key)
           
 int getPropertyAsInt(String key)
           
 int getPropertyAsInt(String key, int defaultValue)
           
 long getPropertyAsLong(String key)
           
 long getPropertyAsLong(String key, long defaultValue)
           
 String getPropertyAsString(String key)
           
 String getPropertyAsString(String key, String defaultValue)
           
 List<String> getSearchableTokens()
          }
 JMeterContext getThreadContext()
           
 String getThreadName()
           
 int hashCode()
          
 boolean isEnabled()
          Check if ENABLED property is present and true ; defaults to true
 boolean isRunningVersion()
          Returns the runningVersion.
 boolean isTemporary(JMeterProperty property)
          Test whether a given property is only a temporary resident of the TestElement
protected  void logProperties()
          Log the properties of the test element
protected  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)
          
 void setComment(String comment)
           
 void setEnabled(boolean enabled)
          Set the enabled status of the test element
 void setName(String name)
           
 void setProperty(JMeterProperty property)
          Sets and overwrites a property in the TestElement.
 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 setRunningVersion(boolean runningVersion)
          Sets the runningVersion.
 void setTemporary(JMeterProperty property)
          Indicate that the given property should be only a temporary property in the TestElement
 void 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)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTestElement

public AbstractTestElement()
Method Detail

clone

public Object clone()
Specified by:
clone in interface TestElement
Overrides:
clone in class Object

clear

public void clear()
Clear the TestElement of all data.

Specified by:
clear in interface TestElement

clearTestElementChildren

public void clearTestElementChildren()
This method should clear any test element properties that are merged by TestElement.addTestElement(TestElement).

Default implementation - does nothing

Specified by:
clearTestElementChildren in interface TestElement

removeProperty

public void removeProperty(String key)

Specified by:
removeProperty in interface TestElement

equals

public boolean equals(Object o)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

addTestElement

public void addTestElement(TestElement el)

Specified by:
addTestElement in interface TestElement

setName

public void setName(String name)
Specified by:
setName in interface TestElement

getName

public String getName()
Specified by:
getName in interface TestElement

setComment

public void setComment(String comment)
Specified by:
setComment in interface TestElement

getComment

public String getComment()
Specified by:
getComment in interface TestElement

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 interface TestElement

traverse

public void traverse(TestElementTraverser traverser)
Description copied from interface: TestElement
Convenient way to traverse a test element.

Specified by:
traverse in interface TestElement

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)
Specified by:
getPropertyAsInt in interface TestElement

getPropertyAsInt

public int getPropertyAsInt(String key,
                            int defaultValue)
Specified by:
getPropertyAsInt in interface TestElement

getPropertyAsBoolean

public boolean getPropertyAsBoolean(String key)
Description copied from interface: TestElement
Return a property as a boolean value.

Specified by:
getPropertyAsBoolean in interface TestElement

getPropertyAsBoolean

public boolean getPropertyAsBoolean(String key,
                                    boolean defaultVal)
Specified by:
getPropertyAsBoolean in interface TestElement

getPropertyAsFloat

public float getPropertyAsFloat(String key)
Specified by:
getPropertyAsFloat in interface TestElement

getPropertyAsLong

public long getPropertyAsLong(String key)
Specified by:
getPropertyAsLong in interface TestElement

getPropertyAsLong

public long getPropertyAsLong(String key,
                              long defaultValue)
Specified by:
getPropertyAsLong in interface TestElement

getPropertyAsDouble

public double getPropertyAsDouble(String key)
Specified by:
getPropertyAsDouble in interface TestElement

getPropertyAsString

public String getPropertyAsString(String key)
Specified by:
getPropertyAsString in interface TestElement

getPropertyAsString

public String getPropertyAsString(String key,
                                  String defaultValue)
Specified by:
getPropertyAsString in interface TestElement

addProperty

protected void addProperty(JMeterProperty property,
                           boolean clone)
Add property to test element

Parameters:
property - JMeterProperty to add to current Test Element
clone - 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 interface TestElement

setProperty

public void setProperty(String name,
                        String value)
Specified by:
setProperty in interface TestElement

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 interface TestElement
Parameters:
name - property name
value - current value
dflt - default

setProperty

public void setProperty(String name,
                        boolean value)
Specified by:
setProperty in interface TestElement

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 interface TestElement
Parameters:
name - property name
value - current value
dflt - default

setProperty

public void setProperty(String name,
                        int value)
Specified by:
setProperty in interface TestElement

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 interface TestElement
Parameters:
name - property name
value - current value
dflt - default

setProperty

public void setProperty(String name,
                        long value)
Specified by:
setProperty in interface TestElement

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 interface TestElement
Parameters:
name - property name
value - current value
dflt - default

propertyIterator

public PropertyIterator propertyIterator()
Description copied from interface: TestElement
Get a Property Iterator for the TestElements properties.

Specified by:
propertyIterator in interface TestElement
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 interface TestElement

setRunningVersion

public void setRunningVersion(boolean runningVersion)
Sets the runningVersion.

Specified by:
setRunningVersion in interface TestElement
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 interface TestElement

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 interface TestElement
Returns:
boolean

setTemporary

public void setTemporary(JMeterProperty property)
Indicate that the given property should be only a temporary property in the TestElement

Specified by:
setTemporary in interface TestElement
Parameters:
property - void

getThreadContext

public JMeterContext getThreadContext()
Specified by:
getThreadContext in interface TestElement
Returns:
Returns the threadContext.

setThreadContext

public void setThreadContext(JMeterContext inthreadContext)
Specified by:
setThreadContext in interface TestElement
Parameters:
inthreadContext - The threadContext to set.

getThreadName

public String getThreadName()
Specified by:
getThreadName in interface TestElement
Returns:
Returns the threadName.

setThreadName

public void setThreadName(String inthreadName)
Specified by:
setThreadName in interface TestElement
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 interface TestElement
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 interface TestElement
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 interface TestElement
Parameters:
enabled - the status to set

getSearchableTokens

public List<String> getSearchableTokens()
                                 throws Exception
}

Specified by:
getSearchableTokens in interface Searchable
Returns:
List of searchable tokens
Throws:
Exception

addPropertiesValues

protected final void addPropertiesValues(List<String> result,
                                         Set<String> propertyNames)
Add to result the values of propertyNames

Parameters:
result - List values of propertyNames
propertyNames - Set properties to extract

Apache JMeter

Copyright © 1998-2013 Apache Software Foundation. All Rights Reserved.