Author: pmouawad
Date: Sun Nov 18 22:29:35 2012
New Revision: 1411006
URL: http://svn.apache.org/viewvc?rev=1411006&view=rev
Log:
Bug 54109 - JSR223TestElement : SampleResult properties should be set before
entering script to allow user setting different code
Bugzilla Id: 54109
Modified:
jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JSR223Sampler.java
jmeter/trunk/xdocs/changes.xml
Modified:
jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JSR223Sampler.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JSR223Sampler.java?rev=1411006&r1=1411005&r2=1411006&view=diff
==============================================================================
---
jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JSR223Sampler.java
(original)
+++
jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JSR223Sampler.java
Sun Nov 18 22:29:35 2012
@@ -42,7 +42,7 @@ public class JSR223Sampler extends JSR22
private static final Set<String> APPLIABLE_CONFIG_CLASSES = new
HashSet<String>(
Arrays.asList(new String[]{
"org.apache.jmeter.config.gui.SimpleConfigGui"}));
-
+
private static final long serialVersionUID = 234L;
private static final Logger log = LoggingManager.getLoggerForClass();
@@ -50,6 +50,10 @@ public class JSR223Sampler extends JSR22
public SampleResult sample(Entry entry) {
SampleResult result = new SampleResult();
result.setSampleLabel(getName());
+ result.setSuccessful(true);
+ result.setResponseCodeOK();
+ result.setResponseMessageOK();
+
final String filename = getFilename();
if (filename.length() > 0){
result.setSamplerData("File: "+filename);
@@ -63,10 +67,7 @@ public class JSR223Sampler extends JSR22
Bindings bindings = scriptEngine.createBindings();
bindings.put("SampleResult",result);
Object ret = processFileOrScript(scriptEngine, bindings);
- result.setSuccessful(true);
- result.setResponseCodeOK();
- result.setResponseMessageOK();
- if (ret != null){
+ if (ret != null && (result.getResponseData() == null ||
result.getResponseData()==SampleResult.EMPTY_BA)){
result.setResponseData(ret.toString(), null);
}
} catch (IOException e) {
Modified: jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1411006&r1=1411005&r2=1411006&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Nov 18 22:29:35 2012
@@ -95,7 +95,14 @@ This does not affect JMeter operation.
map which held the PreparedStatement for SQL queries. This limitation provoked
a bug <bugzilla>53995</bugzilla>.
It has been removed so now size of these 2 maps is not limited anymore. This
change changes behaviour as starting from this version no PreparedStatement
will be closed during the test.</p>
-<p>Starting with this version JSR223 Test Elements that have an invalid
filename (not existing or unreadable) will make test fail instead of making the
element silently work</p>
+<p>Starting with this version, there are some important changes on JSR223 Test
Elements:
+<ul>
+ <li>JSR223 Test Elements that have an invalid filename (not existing or
unreadable) will make test fail instead of making the element silently work</li>
+ <li>In JSR223 Test Elements: responseCodeOk, responseMessageOK and
successful are set before script is executed, if responseData is set it will
not be overriden anymore by a toString() on script return value</li>
+</ul>
+</p>
+
+
<!-- =================== Bug fixes =================== -->
<h2>Bug fixes</h2>
@@ -157,6 +164,7 @@ and right angle bracket (>) in search
<li><bugzilla>54004</bugzilla> - Webservice Sampler : Allow adding headers to
request with Header Manager</li>
<li><bugzilla>54106</bugzilla> - JSR223TestElement should check for file
existence when a filename is set instead of using Text Area content </li>
<li><bugzilla>54107</bugzilla> - JSR223TestElement : Enable compilation and
caching of Script Text</li>
+<li><bugzilla>54109</bugzilla> - JSR223TestElement : SampleResult properties
should be set before entering script to allow user setting different code</li>
</ul>
<h3>Controllers</h3>