jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1842697 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java xdocs/changes.xml
Date Wed, 03 Oct 2018 09:54:37 GMT
Author: fschumacher
Date: Wed Oct  3 09:54:37 2018
New Revision: 1842697

URL: http://svn.apache.org/viewvc?rev=1842697&view=rev
Log:
Incomplete search path applied to the filenames used in the upload functionality of the HTTP
sampler

Implemented by Artem Fedorov (artem.fedorov at blazemeter.com) and contributed by BlazeMeter.

Closes #400 on github
Bugzilla Id: 62785

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1842697&r1=1842696&r2=1842697&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Wed Oct  3 09:54:37 2018
@@ -1464,8 +1464,7 @@ public class HTTPHC4Impl extends HTTPHCA
                         entityEnclosingRequest.setHeader(HTTPConstants.HEADER_CONTENT_TYPE,
HTTPConstants.APPLICATION_X_WWW_FORM_URLENCODED);
                     }
                 }
-
-                FileEntity fileRequestEntity = new FileEntity(new File(file.getPath()),(ContentType)
null);
+                FileEntity fileRequestEntity = new FileEntity(FileServer.getFileServer().getResolvedFile(file.getPath()),
(ContentType) null);
                 entityEnclosingRequest.setEntity(fileRequestEntity);
 
                 // We just add placeholder text for file content

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java?rev=1842697&r1=1842696&r2=1842697&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java Wed
Oct  3 09:54:37 2018
@@ -19,14 +19,19 @@
 package org.apache.jmeter.protocol.http.sampler;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 
 import org.apache.jmeter.config.Argument;
 import org.apache.jmeter.config.Arguments;
 import org.apache.jmeter.protocol.http.util.HTTPConstants;
 import org.apache.jmeter.protocol.http.util.HTTPFileArg;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.services.FileServer;
 import org.junit.Test;
 
+import java.io.File;
+
 public class TestHTTPSamplers {
 
 
@@ -364,4 +369,23 @@ public class TestHTTPSamplers {
         file = sampler.getHTTPFiles()[0];
         assertEquals("mime2", file.getMimeType());
     }
+
+    @Test
+    public void testRawBodyFromFile() {
+        String baseDirPath = FileServer.getFileServer().getBaseDir();
+        File baseDir = new File(baseDirPath);
+        try {
+            FileServer.getFileServer().setBase(baseDir.getParentFile());
+            HTTPSamplerBase sampler = new HTTPSampler3();
+            sampler.setMethod("POST");
+            sampler.setPath("http://httpbin.org/post");
+            sampler.setHTTPFiles(new HTTPFileArg[]{new HTTPFileArg("bin/jmeter.properties",
"", "")});
+
+            SampleResult sample = sampler.sample();
+            System.out.println(sample.getResponseDataAsString());
+            assertFalse(sample.getResponseDataAsString().contains("java.io.FileNotFoundException:"));
+        } finally {
+            FileServer.getFileServer().setBase(baseDir);
+        }
+    }
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1842697&r1=1842696&r2=1842697&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Wed Oct  3 09:54:37 2018
@@ -124,6 +124,7 @@ Summary
 
 <h3>HTTP Samplers and Test Script Recorder</h3>
 <ul>
+    <li><bug>62785</bug><pr>400</pr>Incomplete search path
applied to the filenames used in the upload functionality of the HTTP sampler. Implemented
by Artem Fedorov (artem.fedorov at blazemeter.com) and contributed by BlazeMeter.</li>
 </ul>
 
 <h3>Other Samplers</h3>
@@ -182,6 +183,7 @@ Summary
     <li>Till Neunast (https://github.com/tilln)</li>
     <li>Mingun (alexander_sergey at mail.ru)</li>
     <li><a href="https://ubikloadpack.com">Ubik Load Pack</a></li>
+    <li>Artem Fedorov (artem.fedorov at blazemeter.com)</li>
 </ul>
 <p>We also thank bug reporters who helped us improve JMeter.</p>
 <ul>



Mime
View raw message