Apache JMeter
2.0.1.20050615

org.apache.jmeter.functions
Class StringFromFile

java.lang.Object
  extended byorg.apache.jmeter.functions.AbstractFunction
      extended byorg.apache.jmeter.functions.StringFromFile
All Implemented Interfaces:
Function, Serializable, TestListener

public class StringFromFile
extends AbstractFunction
implements Serializable, TestListener

StringFromFile Function to read a String from a text file. Parameters: - file name - variable name (optional - defaults to StringFromFile_) Returns: - 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 copy of each function for every reference in a Sampler or elsewhere; each instance will open its own copy of the the file - the file name is resolved at file (re-)open time - the output variable name is resolved every time the function is invoked

Version:
$Revision: 1.14.2.5 $ Updated on: $Date: 2004/09/21 22:11:12 $
See Also:
Serialized Form

Constructor Summary
StringFromFile()
           
 
Method Summary
 Object clone()
           
 String execute(SampleResult previousResult, Sampler currentSampler)
          Given the previous SampleResult and the current Sampler, return a string to use as a replacement value for the function call.
 List getArgumentDesc()
          Return a list of strings briefly describing each parameter your function takes.
 String getReferenceKey()
          Return the name of your function.
 void setParameters(Collection parameters)
          A collection of the parameters used to configure your function.
 void testEnded()
          Called once for all threads after the end of a test
 void testEnded(String host)
           
 void testIterationStart(LoopIterationEvent event)
          Each time through a Thread Group's test script, an iteration event is fired.
 void testStarted()
          Called just before the start of the test Note that not all the test variables will have been set up at this point.
 void testStarted(String host)
           
 
Methods inherited from class org.apache.jmeter.functions.AbstractFunction
execute, getVariables
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringFromFile

public StringFromFile()
Method Detail

clone

public Object clone()

execute

public String execute(SampleResult previousResult,
                      Sampler currentSampler)
               throws InvalidVariableException
Description copied from interface: Function
Given the previous SampleResult and the current Sampler, return a string to use as a replacement value for the function call. Assume "setParameter" was previously called. This method must be threadsafe - multiple threads will be using the same object.

Specified by:
execute in interface Function
Specified by:
execute in class AbstractFunction
Throws:
InvalidVariableException
See Also:
Function.execute(SampleResult, Sampler)

setParameters

public void setParameters(Collection parameters)
                   throws InvalidVariableException
Description copied from interface: Function
A collection of the parameters used to configure your function. Each parameter is a CompoundFunction and can be resolved by calling the execute() method of the CompoundFunction (which should be done at execution.)

Specified by:
setParameters in interface Function
Specified by:
setParameters in class AbstractFunction
Throws:
InvalidVariableException
See Also:
Function.setParameters(Collection)

getReferenceKey

public String getReferenceKey()
Description copied from interface: Function
Return the name of your function. Convention is to prepend "__" to the name (ie "__regexFunction")

Specified by:
getReferenceKey in interface Function
Specified by:
getReferenceKey in class AbstractFunction
See Also:
Function.getReferenceKey()

getArgumentDesc

public List getArgumentDesc()
Description copied from interface: Function
Return a list of strings briefly describing each parameter your function takes. Please use JMeterUtils.getResString(resource_name) to grab a resource string. Otherwise, your help text will be difficult to internationalize. Add your strings to all org.apache.jmeter.resources.*.properties files. Do not worry about translating - that's someone else's responsibility. This list is not optional. If you don't wish to write help, you must at least return a List containing the correct number of blank strings, one for each argument.

Specified by:
getArgumentDesc in interface Function

testStarted

public void testStarted()
Description copied from interface: TestListener
Called just before the start of the test Note that not all the test variables will have been set up at this point.

Specified by:
testStarted in interface TestListener
See Also:
StandardJMeterEngine.run()

testStarted

public void testStarted(String host)
Specified by:
testStarted in interface TestListener

testEnded

public void testEnded()
Description copied from interface: TestListener
Called once for all threads after the end of a test

Specified by:
testEnded in interface TestListener
See Also:
StandardJMeterEngine.stopTest()

testEnded

public void testEnded(String host)
Specified by:
testEnded in interface TestListener

testIterationStart

public void testIterationStart(LoopIterationEvent event)
Description copied from interface: TestListener
Each time through a Thread Group's test script, an iteration event is fired.

Specified by:
testIterationStart in interface TestListener
Parameters:
event -

Apache JMeter
2.0.1.20050615

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