Author: sebb Date: Tue Nov 3 15:53:23 2009 New Revision: 832461 URL: http://svn.apache.org/viewvc?rev=832461&view=rev Log: Add evalFileOrScript() method
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/BSFTestElement.java Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/BSFTestElement.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/BSFTestElement.java?rev=832461&r1=832460&r2=832461&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/BSFTestElement.java (original) +++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/BSFTestElement.java Tue Nov 3 15:53:23 2009 @@ -141,6 +141,22 @@ } } + 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)); + return bsfEngine.eval(scriptFile,0,0,script); + } catch (IOException e) { + log.warn(e.getLocalizedMessage()); + throw new BSFException(BSFException.REASON_IO_ERROR,"Problem reading script file",e); + } + } + } + /** * Return the script (TestBean version). * Must be overridden for subclasses that don't implement TestBean --------------------------------------------------------------------- To unsubscribe, e-mail: jmeter-dev-unsubscr...@jakarta.apache.org For additional commands, e-mail: jmeter-dev-h...@jakarta.apache.org