Bug 46407 - BSF elements do not load script files, attempt to interpret filename as script

git-svn-id: https://svn.apache.org/repos/asf/jakarta/jmeter/trunk@728228 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2008-12-20 03:54:40 +00:00
parent 60838b039e
commit 4be3414bb0
2 changed files with 12 additions and 1 deletions

View File

@ -18,6 +18,8 @@
package org.apache.jmeter.util;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Serializable;
import java.util.Properties;
@ -25,6 +27,7 @@ import java.util.Properties;
import org.apache.bsf.BSFEngine;
import org.apache.bsf.BSFException;
import org.apache.bsf.BSFManager;
import org.apache.commons.io.FileUtils;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.testelement.AbstractTestElement;
@ -126,8 +129,15 @@ public abstract class BSFTestElement extends AbstractTestElement
final String scriptFile = getFilename();
if (scriptFile.length() == 0) {
bsfEngine.exec("[script]",0,0,getScript());
} else {// we have a file, read and process it
try {
String script=FileUtils.readFileToString(new File(scriptFile));
bsfEngine.exec(scriptFile,0,0,script);
} catch (IOException e) {
log.warn(e.getLocalizedMessage());
throw new BSFException(BSFException.REASON_IO_ERROR,"Problem reading script file",e);
}
}
bsfEngine.exec(scriptFile,0,0,scriptFile);
}
/**

View File

@ -170,6 +170,7 @@ These are implemented in the AbstractTestElement class which all elements should
<li>Fix Java 1.6 https error: java.net.SocketException: Unconnected sockets not implemented</li>
<li>Bug 46359 - BSF JavaScript Preprocessor cannot access sampler variable on first interation (Implement temporary work-round for BSF-22)</li>
<li>Bug 46332 - HTTP Cookie Manager ignores manually defined cookies (bug introduced in r707810)</li>
<li>Bug 46407 - BSF elements do not load script files, attempt to interpret filename as script</li>
</ul>
<h3>Improvements</h3>