DurationAssertion (Apache JMeter dist API)
Description: declaration: package: org.apache.jmeter.assertions, class: DurationAssertion

Package org.apache.jmeter.assertions

# Class DurationAssertion

java.lang.Object
org.apache.jmeter.testelement.AbstractTestElement
org.apache.jmeter.testelement.AbstractScopedTestElement
org.apache.jmeter.testelement.AbstractScopedAssertion
org.apache.jmeter.assertions.DurationAssertion

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `Assertion`, `Searchable`, `org.apache.jmeter.testelement.TestElement`

public class DurationAssertion extends AbstractScopedAssertion implements Serializable, Assertion
Checks if an Sample is sampled within a specified time-frame. If the duration is larger than the timeframe the Assertion is considered a failure.

See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface org.apache.jmeter.testelement.TestElement

  `org.apache.jmeter.testelement.TestElement.Companion`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DURATION_KEY`
  Key for storing assertion-information in the jmx-file.

  ### Fields inherited from interface org.apache.jmeter.testelement.TestElement

  `COMMENTS, Companion, ENABLED, GUI_CLASS, NAME, TEST_CLASS`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DurationAssertion()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AssertionResult`
  `getResult(SampleResult response)`
  Returns the result of the Assertion.
  `void`
  `setAllowedDuration(long duration)`
  Set duration

  ### Methods inherited from class org.apache.jmeter.testelement.AbstractScopedAssertion

  `getScopeName`

  ### Methods inherited from class org.apache.jmeter.testelement.AbstractScopedTestElement

  `fetchScope, getProps, getSampleList, getSchema, getVariableName, isScopeAll, isScopeChildren, isScopeParent, isScopeVariable, isScopeVariable, setScopeAll, setScopeChildren, setScopeParent, setScopeVariable`

  ### Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

  `addPropertiesValues, addProperty, addProperty, addTestElement, canRemove, clear, clearTemporary, clearTestElementChildren, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty`

  ### Methods inherited from class java.lang.Object

  `finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

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

  `get, get, get, get, get, get, get, get, get, getOrCreate, getOrCreate, getOrNull, getOrNull, getOrNull, getPropertyOrNull, getString, removed, removeProperty, set, set, set, set, set, set, set, set, set`

- ## Field Details

  - ### DURATION_KEY

    public static final String DURATION_KEY
    Key for storing assertion-information in the jmx-file.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### DurationAssertion

    public DurationAssertion()

- ## Method Details

  - ### getResult

    public AssertionResult getResult(SampleResult response)
    Returns the result of the Assertion. Here it checks whether the Sample took to long to be considered successful. If so an AssertionResult containing a FailureMessage will be returned. Otherwise the returned AssertionResult will reflect the success of the Sample.
    Specified by:
      `getResult` in interface `Assertion`
    Parameters:
      `response` - the SampleResult containing information about the Sample (duration, success, etc)
    Returns:
      the AssertionResult containing the information about whether the assertion passed or failed.

  - ### setAllowedDuration

    public void setAllowedDuration(long duration)
    Set duration
    Parameters:
      `duration` - Duration in millis