This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 45ade55  Don't use the same file for writing when running tests.
45ade55 is described below

commit 45ade55e76f8e6742ee6ca0ac0d94a7616a0c19e
Author: Felix Schumacher <[email protected]>
AuthorDate: Wed Jul 17 20:59:57 2019 +0200

    Don't use the same file for writing when running tests.
---
 .../apache/jmeter/functions/TestStringtoFile.java  | 42 ++++++++++------------
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/test/src/org/apache/jmeter/functions/TestStringtoFile.java 
b/test/src/org/apache/jmeter/functions/TestStringtoFile.java
index 0f654f1..bb710e7 100644
--- a/test/src/org/apache/jmeter/functions/TestStringtoFile.java
+++ b/test/src/org/apache/jmeter/functions/TestStringtoFile.java
@@ -70,14 +70,11 @@ public class TestStringtoFile extends JMeterTestCase {
 
     @Test
     public void testWriteToFile() throws Exception {
-        try {
-            function.setParameters(functionParams(FILENAME, STRING_TO_WRITE, 
"true", ENCODING));
-            String returnValue = function.execute(result, null);
-            Assert.assertTrue("This method 'Stringtofile' should have 
successfully run",
-                    Boolean.parseBoolean(returnValue));
-        } finally {
-            Files.deleteIfExists(new 
File(FileServer.resolveBaseRelativeName(FILENAME)).toPath());
-        }
+        File file = tempFolder.newFile();
+        file.deleteOnExit();
+        function.setParameters(functionParams(file.getAbsolutePath(), 
STRING_TO_WRITE, "true", ENCODING));
+        String returnValue = function.execute(result, null);
+        Assert.assertTrue("This method 'Stringtofile' should have successfully 
run", Boolean.parseBoolean(returnValue));
     }
 
     @Test
@@ -104,26 +101,23 @@ public class TestStringtoFile extends JMeterTestCase {
 
     @Test
     public void testWriteToFileOptParamWayToWriteIsNull() throws Exception {
-        try {
-            function.setParameters(functionParams(FILENAME, STRING_TO_WRITE));
-            String returnValue = function.execute(result, null);
-            Assert.assertTrue("This method 'Stringtofile' should have 
successfully run with empty append",
-                    Boolean.parseBoolean(returnValue));
-        } finally {
-            Files.deleteIfExists(new 
File(FileServer.resolveBaseRelativeName(FILENAME)).toPath());
-        }
+        File file = tempFolder.newFile();
+        file.deleteOnExit();
+
+        function.setParameters(functionParams(file.getAbsolutePath(), 
STRING_TO_WRITE));
+        String returnValue = function.execute(result, null);
+        Assert.assertTrue("This method 'Stringtofile' should have successfully 
run with empty append",
+                Boolean.parseBoolean(returnValue));
     }
 
     @Test
     public void testWriteToFileOptParamEncodingIsNull() throws Exception {
-        try {
-            function.setParameters(functionParams(FILENAME, STRING_TO_WRITE, 
"true"));
-            String returnValue = function.execute(result, null);
-            Assert.assertTrue("This method 'Stringtofile' should have 
successfully run with no charset",
-                    Boolean.parseBoolean(returnValue));
-        } finally {
-            Files.deleteIfExists(new 
File(FileServer.resolveBaseRelativeName(FILENAME)).toPath());
-        }
+        File file = tempFolder.newFile();
+        file.deleteOnExit();
+        function.setParameters(functionParams(file.getAbsolutePath(), 
STRING_TO_WRITE, "true"));
+        String returnValue = function.execute(result, null);
+        Assert.assertTrue("This method 'Stringtofile' should have successfully 
run with no charset",
+                Boolean.parseBoolean(returnValue));
     }
 
     @Test

Reply via email to