jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1849687 - in /jmeter/trunk: src/functions/org/apache/jmeter/functions/FileRowColContainer.java test/src/org/apache/jmeter/functions/TestFileRowColContainer.java xdocs/changes.xml
Date Mon, 24 Dec 2018 13:13:31 GMT
Author: fschumacher
Date: Mon Dec 24 13:13:31 2018
New Revision: 1849687

URL: http://svn.apache.org/viewvc?rev=1849687&view=rev
Log:
When using CSVRead search the script base path for files, too.

Bugzilla Id: 63037

Modified:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/FileRowColContainer.java
    jmeter/trunk/test/src/org/apache/jmeter/functions/TestFileRowColContainer.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/FileRowColContainer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/FileRowColContainer.java?rev=1849687&r1=1849686&r2=1849687&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/FileRowColContainer.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/FileRowColContainer.java Mon Dec
24 13:13:31 2018
@@ -19,7 +19,6 @@
 package org.apache.jmeter.functions;
 
 import java.io.BufferedReader;
-import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.charset.Charset;
@@ -28,6 +27,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
 
+import org.apache.jmeter.services.FileServer;
 import org.apache.jmeter.util.JMeterUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -75,7 +75,7 @@ public class FileRowColContainer {
 
     private void load() throws IOException, FileNotFoundException {
         try (BufferedReader myBread = 
-                Files.newBufferedReader(new File(fileName).toPath(), 
+                Files.newBufferedReader(FileServer.getFileServer().getResolvedFile(fileName).toPath(),

                         Charset.defaultCharset())) {
             String line = myBread.readLine();
             /*

Modified: jmeter/trunk/test/src/org/apache/jmeter/functions/TestFileRowColContainer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/functions/TestFileRowColContainer.java?rev=1849687&r1=1849686&r2=1849687&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/functions/TestFileRowColContainer.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/functions/TestFileRowColContainer.java Mon Dec
24 13:13:31 2018
@@ -23,9 +23,14 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.io.File;
 import java.nio.file.NoSuchFileException;
 
 import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.services.FileServer;
+import org.apache.jmeter.util.JMeterUtils;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -35,7 +40,20 @@ import org.junit.Test;
  */
 public class TestFileRowColContainer extends JMeterTestCase {
 
-    @Test(expected=NoSuchFileException.class)
+    private String defaultBase = null;
+
+    @Before
+    public void setUp() {
+        defaultBase = FileServer.getDefaultBase();
+        FileServer.getFileServer().setBase(new File(JMeterUtils.getJMeterHome() + "/bin"));
+    }
+
+    @After
+    public void tearDown() {
+        FileServer.getFileServer().setBase(new File(defaultBase));
+    }
+
+    @Test(expected = NoSuchFileException.class)
     public void testNull() throws Exception {
         new FileRowColContainer(findTestPath("testfiles/xyzxyz"));
     }
@@ -46,6 +64,20 @@ public class TestFileRowColContainer ext
         assertNotNull(f);
         assertEquals("Expected 4 lines", 4, f.getSize());
 
+        assertEquals(0, f.nextRow());
+        assertEquals(1, f.nextRow());
+        assertEquals(2, f.nextRow());
+        assertEquals(3, f.nextRow());
+        assertEquals(0, f.nextRow());
+
+    }
+
+    @Test
+    public void testRowNumRelative() throws Exception {
+        FileRowColContainer f = new FileRowColContainer("testfiles/unit/TestFileRowColContainer.csv");
+        assertNotNull(f);
+        assertEquals("Expected 4 lines", 4, f.getSize());
+
         assertEquals(0, f.nextRow());
         assertEquals(1, f.nextRow());
         assertEquals(2, f.nextRow());

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1849687&r1=1849686&r2=1849687&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Mon Dec 24 13:13:31 2018
@@ -105,6 +105,7 @@ of previous time slot as a base. Startin
 
 <h3>Functions</h3>
 <ul>
+  <li><bug>63037</bug>When using <code>CSVRead</code> search
the script base path for files, too.</li>
 </ul>
 
 <h3>I18N</h3>



Mime
View raw message