You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2008/11/09 01:44:31 UTC
svn commit: r712453 - in /jakarta/jmeter/trunk:
src/core/org/apache/jmeter/config/
src/protocol/http/org/apache/jmeter/protocol/http/sampler/ xdocs/
Author: sebb
Date: Sat Nov 8 16:44:31 2008
New Revision: 712453
URL: http://svn.apache.org/viewvc?rev=712453&view=rev
Log:
Bug 44521 - empty variables for a POST in the HTTP Request don't get ignored
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/config/Argument.java
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
jakarta/jmeter/trunk/xdocs/changes.xml
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/config/Argument.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/config/Argument.java?rev=712453&r1=712452&r2=712453&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/config/Argument.java (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/config/Argument.java Sat Nov 8 16:44:31 2008
@@ -135,4 +135,23 @@
public String toString() {
return getName() + getMetaData() + getValue();
}
+
+ /**
+ * Is this parameter skippable, i.e. empty/blank string
+ * or it looks like an unrecognised variable.
+ *
+ * @param parameterName - parameter name
+ * @return true if parameter should be skipped
+ */
+ public boolean isSkippable(String parameterName) {
+ if (parameterName.trim().length()==0){
+ return true; // Skip parameters with a blank name (allows use of optional variables in parameter lists)
+ }
+ // TODO: improve this test
+ if (parameterName.trim().startsWith("${") && parameterName.endsWith("}")){// $NON-NLS-1$ $NON-NLS-2$
+ return true; // Missing variable name
+ }
+ return false;
+ }
+
}
Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java?rev=712453&r1=712452&r2=712453&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java Sat Nov 8 16:44:31 2008
@@ -267,22 +267,18 @@
contentEncoding = null;
}
- // Check how many parts we need, one for each parameter and file
- int noParts = getArguments().getArgumentCount();
- noParts += files.length;
-
+ // We don't know how many entries will be skipped
+ ArrayList partlist = new ArrayList();
// Create the parts
- Part[] parts = new Part[noParts];
- int partNo = 0;
// Add any parameters
PropertyIterator args = getArguments().iterator();
while (args.hasNext()) {
HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
String parameterName = arg.getName();
- if (parameterName.length()==0){
- continue; // Skip parameters with a blank name (allows use of optional variables in parameter lists)
+ if (arg.isSkippable(parameterName)){
+ continue;
}
- parts[partNo++] = new StringPart(arg.getName(), arg.getValue(), contentEncoding);
+ partlist.add(new StringPart(arg.getName(), arg.getValue(), contentEncoding));
}
// Add any files
@@ -292,10 +288,12 @@
// We do not know the char set of the file to be uploaded, so we set it to null
ViewableFilePart filePart = new ViewableFilePart(file.getParamName(), inputFile, file.getMimeType(), null);
filePart.setCharSet(null); // We do not know what the char set of the file is
- parts[partNo++] = filePart;
+ partlist.add(filePart);
}
// Set the multipart for the post
+ int partNo = partlist.size();
+ Part[] parts = (Part[])partlist.toArray(new Part[partNo]);
MultipartRequestEntity multiPart = new MultipartRequestEntity(parts, post.getParams());
post.setRequestEntity(multiPart);
@@ -394,7 +392,7 @@
}
}
- // Just append all the non-empty parameter values, and use that as the post body
+ // Just append all the parameter values, and use that as the post body
StringBuffer postBody = new StringBuffer();
PropertyIterator args = getArguments().iterator();
while (args.hasNext()) {
@@ -425,8 +423,8 @@
// so if the argument is already encoded, we have to decode
// it before adding it to the post request
String parameterName = arg.getName();
- if (parameterName.length()==0){
- continue; // Skip parameters with a blank name (allows use of optional variables in parameter lists)
+ if (arg.isSkippable(parameterName)){
+ continue;
}
String parameterValue = arg.getValue();
if(!arg.isAlwaysEncoded()) {
Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java?rev=712453&r1=712452&r2=712453&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java Sat Nov 8 16:44:31 2008
@@ -188,8 +188,8 @@
while (args.hasNext()) {
HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
String parameterName = arg.getName();
- if (parameterName.length()==0){
- continue; // Skip parameters with a blank name (allows use of optional variables in parameter lists)
+ if (arg.isSkippable(parameterName)){
+ continue;
}
// End the previous multipart
bos.write(CRLF);
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=712453&r1=712452&r2=712453&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sat Nov 8 16:44:31 2008
@@ -155,6 +155,7 @@
<li>Bug 45458 - Point to Point JMS in combination with authentication</li>
<li>Bug 45460 - JMS TestPlan elements depend on resource property</li>
<li>Bug 34096 - Duplicate samples not eliminated when writing to CSV files</li>
+<li>Bug 44521 - empty variables for a POST in the HTTP Request don't get ignored</li>
</ul>
<h3>Improvements</h3>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org