Apache JMeter
1.9

org.apache.jmeter.functions
Class CSVRead

java.lang.Object
  |
  +--org.apache.jmeter.functions.AbstractFunction
        |
        +--org.apache.jmeter.functions.CSVRead
All Implemented Interfaces:
Function, Serializable

public class CSVRead
extends AbstractFunction
implements Serializable

Author:
Cyrus M. Syntax is similar to StringFromFile function. The function represented by this class allows data to be read from CSV files. The function allows the test to line-thru the data in the CSV file - one line per each test. E.g. inserting the following in the test scripts : ${_CSVRead(c:/BOF/abcd.csv,0)} // read (first) line of 'c:/BOF/abcd.csv' , return the 1st column ( represented by the '0'), ${_CSVRead(c:/BOF/abcd.csv,1)} // read (first) line of 'c:/BOF/abcd.csv' , return the 2nd column ( represented by the '1'), ${_CSVRead(c:/BOF/abcd.csv,next())} // Go to next line of 'c:/BOF/abcd.csv' NOTE: A single instance of file is opened and used for all threads. For example, if thread-1 reads the first line and then issues a 'next()' , then thread-2 will be starting from line-1. Use CSVRead to isolate the file usage between different threads .
See Also:
Serialized Form

Field Summary
protected static List desc
           
protected static FileDataContainer fileData
           
protected static org.apache.log.Logger log
           
protected  BufferedReader myBread
           
protected  String myName
           
protected  String myValue
           
protected  boolean reopenFile
           
protected static Hashtable threadData
           
protected  Object[] values
           
 
Constructor Summary
CSVRead()
           
 
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.
protected  FileDataContainer getFileData(String fileName)
          get the FileDataContainer
protected  String getId()
          reset - resets the file - so the file is read in the next iteration
 String getReferenceKey()
          Return the name of your function.
protected static Hashtable getThreadData()
          Insert the method's description here.
protected  ArrayList reloadCurrentLine()
          Deprecated.  
protected  void reset()
          reset - resets the file - so the file is read in the next iteration
protected  void setFileData(FileDataContainer newValue)
          Set the FileDataContainer.
 void setParameters(Collection parameters)
          A collection of the parameters used to configure your function.
 void storeCurrentLine(ArrayList currentLine)
          Deprecated.  
 
Methods inherited from class org.apache.jmeter.functions.AbstractFunction
execute, getVariables, parseArguments
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static transient org.apache.log.Logger log

desc

protected static final List desc

fileData

protected static FileDataContainer fileData

myValue

protected String myValue

myName

protected String myName

values

protected Object[] values

myBread

protected BufferedReader myBread

reopenFile

protected boolean reopenFile

threadData

protected static Hashtable threadData
Constructor Detail

CSVRead

public CSVRead()
Method Detail

clone

public Object clone()
Overrides:
clone in class Object

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
InvalidVariableException
See Also:
Function.execute(SampleResult, Sampler)

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
See Also:
Function.getArgumentDesc()

getFileData

protected FileDataContainer getFileData(String fileName)
                                 throws IOException
get the FileDataContainer

IOException

getId

protected String getId()
reset - resets the file - so the file is read in the next iteration


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

getThreadData

protected static Hashtable getThreadData()
Insert the method's description here. Creation date: (24/03/2003 17:11:30)

Returns:
java.util.Hashtable

reloadCurrentLine

protected ArrayList reloadCurrentLine()
                               throws InvalidVariableException
Deprecated.  

this is for version 1.8.1 only -

InvalidVariableException

reset

protected void reset()
reset - resets the file - so the file is read in the next iteration


setFileData

protected void setFileData(FileDataContainer newValue)
Set the FileDataContainer.


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
InvalidVariableException
See Also:
Function.setParameters(Collection)

storeCurrentLine

public void storeCurrentLine(ArrayList currentLine)
                      throws InvalidVariableException
Deprecated.  

this is for version 1.8.1 only -

InvalidVariableException

Apache JMeter
1.9

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