jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1201231 - in /jmeter/trunk: src/core/org/apache/jmeter/services/FileServer.java test/src/org/apache/jmeter/services/TestFileServer.java xdocs/changes.xml
Date Sat, 12 Nov 2011 09:32:26 GMT
Author: pmouawad
Date: Sat Nov 12 09:32:26 2011
New Revision: 1201231

URL: http://svn.apache.org/viewvc?rev=1201231&view=rev
Log:
[Bug 52150] FileServer has 3 confusingly similar methods to set the file base
Reverting

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java
    jmeter/trunk/test/src/org/apache/jmeter/services/TestFileServer.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java?rev=1201231&r1=1201230&r2=1201231&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java Sat Nov 12 09:32:26 2011
@@ -113,12 +113,16 @@ public class FileServer {
      * @throws IOException if there is a problem resolving the file name
      */
     public synchronized void setBasedir(String basedir) throws IOException {
+        if (filesOpen()) {
+            throw new IOException("Files are still open, cannot change base directory");
+        }
+        files.clear();
         if (basedir != null) {
-            File base = new File(basedir);
+            base = new File(basedir);
             if (!base.isDirectory()) {
                 base = base.getParentFile();
             }
-            setBase(base);
+            log.info("Set new base='"+base+"'");
         }
     }
 
@@ -135,9 +139,14 @@ public class FileServer {
         if (scriptPath == null){
             throw new IllegalArgumentException("scriptPath must not be null");
         }
-        File parentFolder = scriptPath.getAbsoluteFile().getParentFile();
-        setBase(parentFolder);
+        if (filesOpen()) {
+            throw new IllegalStateException("Files are still open, cannot change base directory");
+        }
+        files.clear();
+        // getParentFile() may not work on relative paths
         setScriptName(scriptPath.getName());
+        base = scriptPath.getAbsoluteFile().getParentFile();
+        log.info("Set new base '"+base+"'");
     }
 
     /**

Modified: jmeter/trunk/test/src/org/apache/jmeter/services/TestFileServer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/services/TestFileServer.java?rev=1201231&r1=1201230&r2=1201231&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/services/TestFileServer.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/services/TestFileServer.java Sat Nov 12 09:32:26
2011
@@ -94,21 +94,13 @@ public class TestFileServer extends JMet
         assertFalse("Should not have any files open",FS.filesOpen());
         assertEquals("a1,b1,c1,d1",FS.readLine(infile));
         try {
-            FS.setBasedir(System.getProperty("java.io.tmpdir"));
-            fail("Expected IllegalStateException");
-        } catch (IllegalStateException ignored){
-        	assertEquals("Files are still open, cannot change base directory", ignored.getMessage());
+            FS.setBasedir("x");
+            fail("Expected IOException");
+        } catch (IOException ignored){
         }
         FS.closeFile(infile);
-        FS.setBasedir(System.getProperty("java.io.temp"));
+        FS.setBasedir("y");
         FS.closeFiles();
-        
-        try {
-        	FS.setBasedir("x");
-            fail("Expected IllegalArgumentException");
-        } catch (IllegalArgumentException ignored){
-        	assertEquals("jmxBase must not be null", ignored.getMessage());
-        }
     }
     
     public void testRelative() throws Exception {

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1201231&r1=1201230&r2=1201231&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Nov 12 09:32:26 2011
@@ -208,7 +208,6 @@ these occurs, Sampler is marked as faile
 <li>Bug 52116 - Allow to add (paste) entries from the clipboard to an arguments list</li>
 <li>Bug 51091 - New function returning the name of the current "Test Plan"</li>
 <li>Bug 52160 - Don't display TestBeanGui items which are flagged as hidden</li>
-<li>Bug 52150 - FileServer has 3 confusingly similar methods to set the file base</li>
 </ul>
 
 <h2>Non-functional changes</h2>



Mime
View raw message