Package org.apache.jmeter.functions
Class StringFromFile
java.lang.Object
org.apache.jmeter.functions.AbstractFunction
org.apache.jmeter.functions.StringFromFile
- All Implemented Interfaces:
org.apache.jmeter.functions.Function
,org.apache.jmeter.testelement.TestStateListener
@AutoService(org.apache.jmeter.functions.Function.class)
public class StringFromFile
extends org.apache.jmeter.functions.AbstractFunction
implements org.apache.jmeter.testelement.TestStateListener
StringFromFile Function to read a String from a text file.
Parameters:- file name
- variable name (optional - defaults to
StringFromFile_
) - sequence start
- sequence end
- the next line from the file
- or
**ERR**
if an error occurs - value is also saved in the variable for later re-use.
Ensure that different variable names are used for each call to the function
Notes:- JMeter instantiates a single copy of each function for every reference in the test plan
- Function instances are shared between threads.
- Each StringFromFile instance reads the file independently. The output variable can be used to save the value for later use in the same thread.
- The file name is resolved at file (re-)open time; the file is initially opened on first execution (which could be any thread)
- the output variable name is resolved every time the function is invoked
- Since:
- 1.9
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute
(org.apache.jmeter.samplers.SampleResult previousResult, org.apache.jmeter.samplers.Sampler currentSampler) void
setParameters
(Collection<org.apache.jmeter.engine.util.CompoundVariable> parameters) void
void
void
void
testStarted
(String host) Methods inherited from class org.apache.jmeter.functions.AbstractFunction
addVariableValue, checkMinParameterCount, checkParameterCount, checkParameterCount, execute, getVariables
-
Constructor Details
-
StringFromFile
public StringFromFile()
-
-
Method Details
-
execute
public String execute(org.apache.jmeter.samplers.SampleResult previousResult, org.apache.jmeter.samplers.Sampler currentSampler) throws org.apache.jmeter.functions.InvalidVariableException - Specified by:
execute
in interfaceorg.apache.jmeter.functions.Function
- Specified by:
execute
in classorg.apache.jmeter.functions.AbstractFunction
- Throws:
org.apache.jmeter.functions.InvalidVariableException
-
setParameters
public void setParameters(Collection<org.apache.jmeter.engine.util.CompoundVariable> parameters) throws org.apache.jmeter.functions.InvalidVariableException - Specified by:
setParameters
in interfaceorg.apache.jmeter.functions.Function
- Specified by:
setParameters
in classorg.apache.jmeter.functions.AbstractFunction
- Throws:
org.apache.jmeter.functions.InvalidVariableException
-
getReferenceKey
- Specified by:
getReferenceKey
in interfaceorg.apache.jmeter.functions.Function
- Specified by:
getReferenceKey
in classorg.apache.jmeter.functions.AbstractFunction
-
getArgumentDesc
- Specified by:
getArgumentDesc
in interfaceorg.apache.jmeter.functions.Function
-
testStarted
public void testStarted()- Specified by:
testStarted
in interfaceorg.apache.jmeter.testelement.TestStateListener
-
testStarted
- Specified by:
testStarted
in interfaceorg.apache.jmeter.testelement.TestStateListener
-
testEnded
public void testEnded()- Specified by:
testEnded
in interfaceorg.apache.jmeter.testelement.TestStateListener
-
testEnded
- Specified by:
testEnded
in interfaceorg.apache.jmeter.testelement.TestStateListener
-