|
JMeter example source code file (CSVRead.java)
The JMeter CSVRead.java source code
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.jmeter.functions;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.jmeter.engine.util.CompoundVariable;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
/**
* The function represented by this class allows data to be read from CSV files.
* Syntax is similar to StringFromFile function. 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 each different file is opened and used for all
* threads.
*
* To open the same file twice, use the alias function: __CSVRead(abc.csv,*ONE);
* __CSVRead(abc.csv,*TWO);
*
* __CSVRead(*ONE,1); etc
*
*/
public class CSVRead extends AbstractFunction {
private static final Logger log = LoggingManager.getLoggerForClass();
private static final String KEY = "__CSVRead"; // Function name //$NON-NLS-1$
private static final List<String> desc = new LinkedList
Other JMeter examples (source code examples)Here is a short list of links related to this JMeter CSVRead.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.