use of org.apache.bsf.BSFEngine in project groovy-core by groovy.
the class BSFTest method testCall.
public void testCall() throws Exception {
BSFEngine bsfEngine = manager.loadScriptingEngine("groovy");
manager.declareBean("myvar", "hello", String.class);
Object myvar = manager.lookupBean("myvar");
String result = (String) bsfEngine.call(myvar, "reverse", new Object[] {});
assertEquals("olleh", result);
}
use of org.apache.bsf.BSFEngine in project groovy by apache.
the class CacheBSFTest method testVersion.
public void testVersion() throws Exception {
//System.out.println("BSFManager.getVersion() = " + BSFManager.getVersion());
BSFEngine bsfEngine = manager.loadScriptingEngine("groovy");
assertEquals(CACHING_ENGINE, bsfEngine.getClass());
}
use of org.apache.bsf.BSFEngine 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.BSFEngine 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