jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1854657 - in /jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler: TestHTTPSamplers.java TestSerializedHTTPSampler.java
Date Sat, 02 Mar 2019 17:17:47 GMT
Author: fschumacher
Date: Sat Mar  2 17:17:47 2019
New Revision: 1854657

URL: http://svn.apache.org/viewvc?rev=1854657&view=rev
Log:
Make test work in both IDE and ant setting

The test used the setting of CWD, which is different when run from an IDE or from ant.
Now it uses JMeterHome which is the same for both environments.

And while we are at the test,
 * we try to make sure, that we don't disturb other tests with the manipulated base dir
 * use more descriptive messages in the case of a failure

Relates to #400 on github
Bugzilla Id: 62785


Added:
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestSerializedHTTPSampler.java
  (with props)
Modified:
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java

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=1854657&r1=1854656&r2=1854657&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 Sat
Mar  2 17:17:47 2019
@@ -19,17 +19,12 @@
 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 java.io.File;
-
 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;
 
 public class TestHTTPSamplers {
@@ -370,21 +365,4 @@ public class TestHTTPSamplers {
         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();
-            assertFalse(sample.getResponseDataAsString().contains("java.io.FileNotFoundException:"));
-        } finally {
-            FileServer.getFileServer().setBase(baseDir);
-        }
-    }
 }

Added: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestSerializedHTTPSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestSerializedHTTPSampler.java?rev=1854657&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestSerializedHTTPSampler.java
(added)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestSerializedHTTPSampler.java
Sat Mar  2 17:17:47 2019
@@ -0,0 +1,38 @@
+package org.apache.jmeter.protocol.http.sampler;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
+import java.io.File;
+import java.nio.file.Paths;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.protocol.http.util.HTTPFileArg;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.services.FileServer;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.test.JMeterSerialTest;
+import org.junit.Test;
+
+public class TestSerializedHTTPSampler extends JMeterTestCase implements JMeterSerialTest
{
+
+    @Test
+    public void checkThatFilesAreReadRelativeToBaseDir() {
+        String baseDirPath = FileServer.getFileServer().getBaseDir();
+        File baseDir = new File(baseDirPath);
+        try {
+            FileServer.getFileServer().setBase(Paths.get(JMeterUtils.getJMeterHome(), "test",
"resources").toFile());
+            HTTPSamplerBase sampler = new HTTPSampler3();
+            sampler.setMethod("POST");
+            sampler.setPath("https://httpbin.org/post");
+            sampler.setHTTPFiles(new HTTPFileArg[]{new HTTPFileArg("resourcefile.txt", "",
"")});
+        
+            SampleResult sample = sampler.sample();
+            assertThat(sample.getResponseDataAsString(), not(containsString("java.io.FileNotFoundException:")));
+        } finally {
+            FileServer.getFileServer().setBase(baseDir);
+        }
+    }
+
+}

Propchange: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestSerializedHTTPSampler.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message