Class CsvFileSampleSource
-
- All Implemented Interfaces:
-
java.lang.Runnable
,org.apache.jmeter.report.processor.SampleSource
public class CsvFileSampleSource extends AbstractSampleSource
Read a csv source file and write its rows (samples) all the registered
SampleConsumer
s. If there is several other source files with the same root name then those files are produced on their corresponding channels.The root name of the files is determined by the source file name and is made of its name without the file extension :Example: If
results.csv
is the source file name thenresults
is the root file name. TheCsvFileSampleSource
looks for all the files in the same directory of the main source file that have the same root file nameExample : if the directory containsresults.csv
,results-1.csv
,results-2.csv
, etc. then all these files will be read and produced on their corresponding channels. The channel on which an input file will be produce is determined by its suffix- If the input file is named
results-1.csv
then it will be produced on the channel 1. - If the input file is named
results-2.csv
then it will be produced on the channel 2. - If the input file is named
results.csv
then it will be produced on the channel 0.
- Since:
3.0
-
-
Field Summary
Fields Modifier and Type Field Description public final static String
SOURCE_FILE_ATTRIBUTE
public SampleContext
sampleContext
-
Constructor Summary
Constructors Constructor Description CsvFileSampleSource(File inputFile, char separator)
Build a sample source from the specified input file and character separator.
-
Method Summary
Modifier and Type Method Description void
setSampleConsumers(List<SampleConsumer> consumers)
Sets the specified sample consumers that will consume samples produced by this sample source. void
addSampleConsumer(SampleConsumer consumer)
Add a sample consumer to this sample source. void
removeSampleConsumer(SampleConsumer consumer)
Remove a sample consumer from this sample source. void
run()
Run this sample source. -
Methods inherited from class org.apache.jmeter.report.processor.AbstractSampleSource
getSampleContext, setSampleContext
-
Methods inherited from class java.lang.Runnable
run
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
CsvFileSampleSource
CsvFileSampleSource(File inputFile, char separator)
Build a sample source from the specified input file and character separator.- Parameters:
inputFile
- The input sample file (CSV file) (must not benull
)separator
- The character separator to be used for delimiting samples columns
-
-
Method Detail
-
setSampleConsumers
void setSampleConsumers(List<SampleConsumer> consumers)
Sets the specified sample consumers that will consume samples produced by this sample source.
- Parameters:
consumers
- consumers to be set
-
addSampleConsumer
void addSampleConsumer(SampleConsumer consumer)
Add a sample consumer to this sample source.
- Parameters:
consumer
- consumer to be added
-
removeSampleConsumer
void removeSampleConsumer(SampleConsumer consumer)
Remove a sample consumer from this sample source.
- Parameters:
consumer
- consumer to be removed
-
run
void run()
Run this sample source. This sample source will start reading all inputs CSV files and produce their samples to this sample source registered sample consumers.
-
-
-
-