View | Details | Raw Unified | Return to bug 63037
Collapse All | Expand All

(-)src/functions/org/apache/jmeter/functions/FileRowColContainer.java (-2 / +2 lines)
Lines 19-25 Link Here
19
package org.apache.jmeter.functions;
19
package org.apache.jmeter.functions;
20
20
21
import java.io.BufferedReader;
21
import java.io.BufferedReader;
22
import java.io.File;
23
import java.io.FileNotFoundException;
22
import java.io.FileNotFoundException;
24
import java.io.IOException;
23
import java.io.IOException;
25
import java.nio.charset.Charset;
24
import java.nio.charset.Charset;
Lines 28-33 Link Here
28
import java.util.List;
27
import java.util.List;
29
import java.util.StringTokenizer;
28
import java.util.StringTokenizer;
30
29
30
import org.apache.jmeter.services.FileServer;
31
import org.apache.jmeter.util.JMeterUtils;
31
import org.apache.jmeter.util.JMeterUtils;
32
import org.slf4j.Logger;
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
33
import org.slf4j.LoggerFactory;
Lines 75-81 Link Here
75
75
76
    private void load() throws IOException, FileNotFoundException {
76
    private void load() throws IOException, FileNotFoundException {
77
        try (BufferedReader myBread = 
77
        try (BufferedReader myBread = 
78
                Files.newBufferedReader(new File(fileName).toPath(), 
78
                Files.newBufferedReader(FileServer.getFileServer().getResolvedFile(fileName).toPath(), 
79
                        Charset.defaultCharset())) {
79
                        Charset.defaultCharset())) {
80
            String line = myBread.readLine();
80
            String line = myBread.readLine();
81
            /*
81
            /*
(-)test/src/org/apache/jmeter/functions/TestFileRowColContainer.java (-1 / +33 lines)
Lines 23-31 Link Here
23
import static org.junit.Assert.assertTrue;
23
import static org.junit.Assert.assertTrue;
24
import static org.junit.Assert.fail;
24
import static org.junit.Assert.fail;
25
25
26
import java.io.File;
26
import java.nio.file.NoSuchFileException;
27
import java.nio.file.NoSuchFileException;
27
28
28
import org.apache.jmeter.junit.JMeterTestCase;
29
import org.apache.jmeter.junit.JMeterTestCase;
30
import org.apache.jmeter.services.FileServer;
31
import org.apache.jmeter.util.JMeterUtils;
32
import org.junit.After;
33
import org.junit.Before;
29
import org.junit.Test;
34
import org.junit.Test;
30
35
31
/**
36
/**
Lines 35-41 Link Here
35
 */
40
 */
36
public class TestFileRowColContainer extends JMeterTestCase {
41
public class TestFileRowColContainer extends JMeterTestCase {
37
42
38
    @Test(expected=NoSuchFileException.class)
43
    private String defaultBase = null;
44
45
    @Before
46
    public void setUp() {
47
        defaultBase = FileServer.getDefaultBase();
48
        FileServer.getFileServer().setBase(new File(JMeterUtils.getJMeterHome() + "/bin"));
49
    }
50
51
    @After
52
    public void tearDown() {
53
        FileServer.getFileServer().setBase(new File(defaultBase));
54
    }
55
56
    @Test(expected = NoSuchFileException.class)
39
    public void testNull() throws Exception {
57
    public void testNull() throws Exception {
40
        new FileRowColContainer(findTestPath("testfiles/xyzxyz"));
58
        new FileRowColContainer(findTestPath("testfiles/xyzxyz"));
41
    }
59
    }
Lines 55-60 Link Here
55
    }
73
    }
56
74
57
    @Test
75
    @Test
76
    public void testRowNumRelative() throws Exception {
77
        FileRowColContainer f = new FileRowColContainer("testfiles/unit/TestFileRowColContainer.csv");
78
        assertNotNull(f);
79
        assertEquals("Expected 4 lines", 4, f.getSize());
80
81
        assertEquals(0, f.nextRow());
82
        assertEquals(1, f.nextRow());
83
        assertEquals(2, f.nextRow());
84
        assertEquals(3, f.nextRow());
85
        assertEquals(0, f.nextRow());
86
87
    }
88
89
    @Test
58
    public void testColumns() throws Exception {
90
    public void testColumns() throws Exception {
59
        FileRowColContainer f = new FileRowColContainer(findTestPath("testfiles/unit/TestFileRowColContainer.csv"));
91
        FileRowColContainer f = new FileRowColContainer(findTestPath("testfiles/unit/TestFileRowColContainer.csv"));
60
        assertNotNull(f);
92
        assertNotNull(f);

Return to bug 63037