Class BeanShellTestElement

java.lang.Object
org.apache.jmeter.testelement.AbstractTestElement
org.apache.jmeter.util.BeanShellTestElement
All Implemented Interfaces:
Serializable, Cloneable, Searchable, org.apache.jmeter.testelement.TestElement, TestStateListener, ThreadListener
Direct Known Subclasses:
BeanShellAssertion, BeanShellListener, BeanShellPostProcessor, BeanShellPreProcessor, BeanShellSampler, BeanShellTimer

public abstract class BeanShellTestElement extends AbstractTestElement implements Serializable, Cloneable, ThreadListener, TestStateListener
See Also:
  • Constructor Details

    • BeanShellTestElement

      protected BeanShellTestElement()
  • Method Details

    • getInitFileProperty

      protected abstract String getInitFileProperty()
    • getBeanShellInterpreter

      protected BeanShellInterpreter getBeanShellInterpreter()
      Get the interpreter and set up standard script variables.

      Sets the following script variables:

      • ctx
      • Label
      • prev
      • props
      • vars
      Returns:
      the interpreter
    • readResolve

      protected Object readResolve()
    • clone

      public Object clone()
      Specified by:
      clone in interface org.apache.jmeter.testelement.TestElement
      Overrides:
      clone in class AbstractTestElement
    • processFileOrScript

      protected Object processFileOrScript(BeanShellInterpreter bsh) throws JMeterException
      Process the file or script from the test element.

      Sets the following script variables:

      • FileName
      • Parameters
      • bsh.args
      Parameters:
      bsh - the interpreter, not null
      Returns:
      the result of the script, may be null
      Throws:
      JMeterException - when working with the bsh fails
    • processFileOrScript

      protected Object processFileOrScript(BeanShellInterpreter bsh, SampleResult sampleResult) throws JMeterException
      Process the file or script from the test element.

      Sets the following script variables:

      • FileName
      • Parameters
      • bsh.args
      Parameters:
      bsh - the interpreter, not null
      sampleResult - sampler result to set setSamplerData or null
      Returns:
      the result of the script, may be null
      Throws:
      JMeterException - when working with the bsh fails
    • getScript

      public String getScript()
      Return the script (TestBean version). Must be overridden for subclasses that don't implement TestBean otherwise the clone() method won't work.
      Returns:
      the script to execute
    • setScript

      public void setScript(String s)
      Set the script (TestBean version). Must be overridden for subclasses that don't implement TestBean otherwise the clone() method won't work.
      Parameters:
      s - the script to execute (may be blank)
    • threadStarted

      public void threadStarted()
      Description copied from interface: ThreadListener
      Called for each thread before starting sampling. WARNING: this is called before any Config test elements are processed, so any properties they define will not have been merged in yet. See org.apache.jmeter.threads.JMeterThread#threadStarted()
      Specified by:
      threadStarted in interface ThreadListener
    • threadFinished

      public void threadFinished()
      Description copied from interface: ThreadListener
      Called for each thread after all samples have been processed. See org.apache.jmeter.threads.JMeterThread#threadFinished(org.apache.jmeter.engine.event.LoopIterationListener)
      Specified by:
      threadFinished in interface ThreadListener
    • testEnded

      public void testEnded()
      Description copied from interface: TestStateListener

      Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
      testEnded in interface TestStateListener
      See Also:
    • testEnded

      public void testEnded(String host)
      Description copied from interface: TestStateListener

      Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
      testEnded in interface TestStateListener
      Parameters:
      host - name of host
      See Also:
    • testStarted

      public void testStarted()
      Description copied from interface: TestStateListener

      Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
      testStarted in interface TestStateListener
      See Also:
    • testStarted

      public void testStarted(String host)
      Description copied from interface: TestStateListener

      Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
      testStarted in interface TestStateListener
      Parameters:
      host - name of host
      See Also:
    • getParameters

      public String getParameters()
    • setParameters

      public void setParameters(String s)
    • getFilename

      public String getFilename()
    • setFilename

      public void setFilename(String s)
    • isResetInterpreter

      public boolean isResetInterpreter()
    • setResetInterpreter

      public void setResetInterpreter(boolean b)