org.apache.jmeter.testelement

## Class AbstractTestElement

- java.lang.Object
- - org.apache.jmeter.testelement.AbstractTestElement

- All Implemented Interfaces:
    Serializable, Cloneable, Searchable, TestElement
  Direct Known Subclasses:
    AbstractBoltTestElement, AbstractJDBCTestElement, AbstractListenerElement, AbstractSampler, AbstractScopedTestElement, AbstractThreadGroup, AnchorModifier, Argument, Authorization, BackendListener, BeanShellTestElement, BoltConnectionElement, CompareAssertion, ConfigTestElement, ConstantThroughputTimer, ConstantTimer, Cookie, CounterConfig, DataSourceElement, DebugPostProcessor, GenericController, Header, HTMLAssertion, HTTPFileArg, HttpMirrorControl, JMESPathAssertion, JMSProperties, JMSProperty, JSONPathAssertion, LDAPArgument, MailerModel, MD5HexAssertion, OnErrorTestElement, PreciseThroughputTimer, RegExUserParameters, RemoteListenerWrapper, RemoteSampleListenerWrapper, RemoteTestListenerWrapper, RemoteThreadsListenerWrapper, ResultSaver, SampleTimeout, ScriptingTestElement, SMIMEAssertionTestElement, StaticHost, 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
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractTestElement()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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()` Returns comment associated with this element.
    `String` | `getName()` Get the name of this test element
    `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)` 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 searching
    `JMeterContext` | `getThreadContext()`
    `String` | `getThreadName()` Returns the threadName.
    `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)` Remove property stored under the `key`
    `void` | `setComment(String comment)` Associates a comment with this element
    `void` | `setEnabled(boolean enabled)` Set the enabled status of the test element
    `void` | `setName(String name)` Returns name of this element.
    `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)` Configures thread name.
    `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`

    - ### Methods inherited from interface org.apache.jmeter.testelement.TestElement

      `removed`

- - ### Constructor Detail

    - #### AbstractTestElement

          protected 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)

      Remove property stored under the `key`
      Specified by:
        `removeProperty` in interface `TestElement`
      Parameters:
        `key` - name of the property to be removed

    - #### 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)

      Description copied from interface: `TestElement`
      Returns name of this element.
      Specified by:
        `setName` in interface `TestElement`
      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 interface `TestElement`
      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 interface `TestElement`
      Parameters:
        `comment` - to be associated

    - #### getComment

          public String getComment()

      Description copied from interface: `TestElement`
      Returns comment associated with this element.
      Specified by:
        `getComment` in interface `TestElement`
      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 interface `TestElement`
      Parameters:
        `key` - the name of the property to get
      Returns:
        `JMeterProperty` stored under the name, or `NullProperty` 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 interface `TestElement`
      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 interface `TestElement`
      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 interface `TestElement`
      Parameters:
        `key` - the name of the property to get
        `defaultValue` - 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 interface `TestElement`
      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 interface `TestElement`
      Parameters:
        `key` - the name of the property to get
        `defaultVal` - 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 interface `TestElement`
      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 interface `TestElement`
      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 interface `TestElement`
      Parameters:
        `key` - the name of the property to get
        `defaultValue` - 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 interface `TestElement`
      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 interface `TestElement`
      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 interface `TestElement`
      Parameters:
        `key` - the name of the property to get
        `defaultValue` - 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 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`
      Parameters:
        `property` - the property to be set

    - #### 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`
      Returns:
        `true` if the element is the running version

    - #### 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`
      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 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()

      Description copied from interface: `TestElement`
      Returns the threadName.
      Specified by:
        `getThreadName` in interface `TestElement`
      Returns:
        Returns the threadName.

    - #### setThreadName

          public void setThreadName(String inthreadName)

      Description copied from interface: `TestElement`
      Configures thread name.
      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()

      Get a list of all tokens that should be visible to searching}
      Specified by:
        `getSearchableTokens` in interface `Searchable`
      Returns:
        List of searchable tokens

    - #### addPropertiesValues

          protected final void addPropertiesValues(List<String> result,
                                                   Set<String> propertyNames)

      Add to result the values of propertyNames
      Parameters:
        `result` - List of values of propertyNames
        `propertyNames` - Set of names of properties to extract

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