Author: sebb
Date: Sat Mar 22 15:18:40 2008
New Revision: 640095
URL: http://svn.apache.org/viewvc?rev=640095&view=rev
Log:
Bug 44650 - CSV Dataset now handles quoted column values
Modified:
jakarta/jmeter/trunk/docs/images/screenshots/csvdatasetconfig.png
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetResources.properties
jakarta/jmeter/trunk/xdocs/changes.xml
jakarta/jmeter/trunk/xdocs/images/screenshots/csvdatasetconfig.png
jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified: jakarta/jmeter/trunk/docs/images/screenshots/csvdatasetconfig.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/csvdatasetconfig.png?rev=640095&r1=640094&r2=640095&view=diff
==============================================================================
Binary files - no diff available.
Modified:
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java?rev=640095&r1=640094&r2=640095&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java
(original)
+++
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java
Sat Mar 22 15:18:40 2008
@@ -19,10 +19,12 @@
package org.apache.jmeter.config;
import java.io.IOException;
+import java.io.StringReader;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.engine.event.LoopIterationEvent;
import org.apache.jmeter.engine.event.LoopIterationListener;
+import org.apache.jmeter.save.CSVSaveService;
import org.apache.jmeter.services.FileServer;
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jmeter.threads.JMeterVariables;
@@ -32,10 +34,6 @@
import org.apache.jorphan.util.JOrphanUtils;
import org.apache.log.Logger;
-/**
- * @author mstover
- *
- */
public class CSVDataSet extends ConfigTestElement implements TestBean,
LoopIterationListener {
private static final Logger log = LoggingManager.getLoggerForClass();
@@ -52,6 +50,8 @@
private transient String delimiter;
+ private transient boolean quoted = false;
+
private transient boolean recycle = true;
private transient boolean stopThread = false;
@@ -81,7 +81,9 @@
JMeterVariables threadVars =
this.getThreadContext().getVariables();
String line = server.readLine(_fileName,getRecycle());
if (line!=null) {// i.e. not EOF
- String[] lineValues = JOrphanUtils.split(line, delim,false);
+ String[] lineValues = getQuotedData() ?
+ CSVSaveService.csvReadFile(new StringReader(line),
delim.charAt(0))
+ : JOrphanUtils.split(line, delim, false);
for (int a = 0; a < vars.length && a <
lineValues.length; a++) {
threadVars.put(vars[a], lineValues[a]);
}
@@ -151,6 +153,14 @@
public void setDelimiter(String delimiter) {
this.delimiter = delimiter;
}
+
+ public boolean getQuotedData() {
+ return quoted;
+ }
+
+ public void setQuotedData(boolean quoted) {
+ this.quoted = quoted;
+ }
public boolean getRecycle() {
return recycle;
Modified:
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java?rev=640095&r1=640094&r2=640095&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java
(original)
+++
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java
Sat Mar 22 15:18:40 2008
@@ -35,11 +35,12 @@
private static final String DELIMITER = "delimiter";
//$NON-NLS-1$
private static final String RECYCLE = "recycle";
//$NON-NLS-1$
private static final String STOPTHREAD = "stopThread";
//$NON-NLS-1$
+ private static final String QUOTED_DATA = "quotedData";
//$NON-NLS-1$
public CSVDataSetBeanInfo() {
super(CSVDataSet.class);
createPropertyGroup("csv_data", //$NON-NLS-1$
- new String[] { FILENAME, FILE_ENCODING, VARIABLE_NAMES,
DELIMITER, RECYCLE, STOPTHREAD });
+ new String[] { FILENAME, FILE_ENCODING, VARIABLE_NAMES,
DELIMITER, QUOTED_DATA, RECYCLE, STOPTHREAD });
PropertyDescriptor p = property(FILENAME);
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
@@ -60,6 +61,11 @@
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, ","); //$NON-NLS-1$
p.setValue(NOT_EXPRESSION, Boolean.TRUE);
+
+ p = property(QUOTED_DATA);
+ p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+ p.setValue(DEFAULT, Boolean.FALSE);
+ p.setValue(NOT_EXPRESSION, Boolean.TRUE);
p = property(RECYCLE);
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
Modified:
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetResources.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetResources.properties?rev=640095&r1=640094&r2=640095&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetResources.properties
(original)
+++
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetResources.properties
Sat Mar 22 15:18:40 2008
@@ -8,6 +8,8 @@
variableNames.shortDescription=List your variable names in order to match the
order of columns in your csv data. Separate by commas.
delimiter.displayName=Delimiter (use '\\t' for tab)
delimiter.shortDescription=Enter the delimiter ('\\t' for tab)
+quotedData.displayName=Allow quoted data?
+quotedData.shortDescription=Allow CSV data values to be quoted?
recycle.displayName=Recycle on EOF ?
recycle.shortDescription=Should the file be re-read from the start on reaching
EOF ?
stopThread.displayName=Stop thread on EOF ?
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=640095&r1=640094&r2=640095&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sat Mar 22 15:18:40 2008
@@ -121,6 +121,7 @@
As a special case, if the HTTP Sampler path starts with "http://" or
"https://" then this is used as the full URL.
</li>
<li>Bug 44575 - Result Saver can now save only successful results</li>
+<li>Bug 44650 - CSV Dataset now handles quoted column values</li>
</ul>
<h4>Non-functional changes</h4>
Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/csvdatasetconfig.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/csvdatasetconfig.png?rev=640095&r1=640094&r2=640095&view=diff
==============================================================================
Binary files - no diff available.
Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=640095&r1=640094&r2=640095&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Sat Mar 22
15:18:40 2008
@@ -2084,11 +2084,13 @@
<br></br>
</description>
-<component name="CSV Data Set Config" index="§-num;.4.1" width="363"
height="251" screenshot="csvdatasetconfig.png">
+<component name="CSV Data Set Config" index="§-num;.4.1" width="308"
height="278" screenshot="csvdatasetconfig.png">
<description>
- <p>
+ <p>
CSV Data Set Config is used to read lines from a file, and split them
into variables.
It is easier to use than the __CSVRead() and _StringFromFile()
functions.
+ Versions of JMeter after 2.3.1 allow variables to be quoted; this
allows the value to contain a delimiter.
+ Previously it was necessary to choose a delimiter that was not used in
any values.
</p>
<p>
The file is only opened once, and each thread will use a different line
from the file.
@@ -2100,7 +2102,7 @@
However the variables do work in the HTTP Auth Manager, as the username
etc are processed at run-time.
</note>
<p>
- As a special case, the string "\t" (without quotes) is treated as a Tab.
+ As a special case, the string "\t" (without quotes) in the delimiter
field is treated as a Tab.
</p>
<p>
When the end of file (EOF) is reached, and the recycle option is true,
reading starts again with the first line of the file.
@@ -2125,6 +2127,7 @@
<property name="Delimiter" required="Yes">Delimiter to be used to split the
records in the file.
If there are fewer values on the line than there are variables the remaining
variables are not updated -
so they will retain their previous value (if any).</property>
+ <property name="Allow quoted data?" required="Yes">Should the CSV file allow
values to be quoted?</property>
<property name="Recycle on EOF?" required="Yes">Should the file be re-read
from the beginning on reaching EOF? (default is true)</property>
<property name="Stop thread on EOF?" required="Yes">Should the thread be
stopped on EOF, if Recycle is false? (default is false)</property>
</properties>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]