use of org.apache.bsf.BSFException in project jmeter by apache.
the class BSFTestElement method processFileOrScript.
protected void processFileOrScript(BSFManager mgr) throws BSFException {
BSFEngine bsfEngine = mgr.loadScriptingEngine(getScriptLanguage());
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), Charset.defaultCharset());
bsfEngine.exec(scriptFile, 0, 0, script);
} catch (IOException e) {
if (log.isWarnEnabled()) {
log.warn("Exception executing script. {}", e.getLocalizedMessage());
}
throw new BSFException(BSFException.REASON_IO_ERROR, "Problem reading script file", e);
}
}
}
use of org.apache.bsf.BSFException in project jmeter by apache.
the class BSFTestElement method evalFileOrScript.
protected Object evalFileOrScript(BSFManager mgr) throws BSFException {
BSFEngine bsfEngine = mgr.loadScriptingEngine(getScriptLanguage());
final String scriptFile = getFilename();
if (scriptFile.length() == 0) {
return bsfEngine.eval("[script]", 0, 0, getScript());
} else {
// we have a file, read and process it
try {
String script = FileUtils.readFileToString(new File(scriptFile), Charset.defaultCharset());
return bsfEngine.eval(scriptFile, 0, 0, script);
} catch (IOException e) {
if (log.isWarnEnabled()) {
log.warn("Exception evaluating script. {}", e.getLocalizedMessage());
}
throw new BSFException(BSFException.REASON_IO_ERROR, "Problem reading script file", e);
}
}
}
Aggregations