You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2017/11/17 21:42:18 UTC
svn commit: r1815632 - in /jmeter/trunk:
src/core/org/apache/jmeter/util/JSR223TestElement.java
src/core/org/apache/jmeter/util/ScriptingBeanInfoSupport.java
xdocs/changes.xml
Author: pmouawad
Date: Fri Nov 17 21:42:18 2017
New Revision: 1815632
URL: http://svn.apache.org/viewvc?rev=1815632&view=rev
Log:
Bug 61640 - JSR223 Test Elements : Enable by default caching
Bugzilla Id: 61640
Modified:
jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java
jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingBeanInfoSupport.java
jmeter/trunk/xdocs/changes.xml
Modified: jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java?rev=1815632&r1=1815631&r2=1815632&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java Fri Nov 17 21:42:18 2017
@@ -54,7 +54,7 @@ public abstract class JSR223TestElement
implements Serializable, TestStateListener
{
private static final long serialVersionUID = 232L;
-
+
/**
* Cache of compiled scripts
*/
@@ -204,7 +204,8 @@ public abstract class JSR223TestElement
+ "' does not exist or is unreadable for element:" + getName());
}
} else if (!StringUtils.isEmpty(getScript())) {
- if (supportsCompilable && !StringUtils.isEmpty(cacheKey)) {
+ if (supportsCompilable &&
+ !ScriptingBeanInfoSupport.FALSE_AS_STRING.equals(cacheKey)) {
computeScriptMD5();
CompiledScript compiledScript = compiledScriptsCache.get(this.scriptMd5);
if (compiledScript == null) {
@@ -233,7 +234,7 @@ public abstract class JSR223TestElement
}
}
}
-
+
/**
* compute MD5 if it is null
*/
Modified: jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingBeanInfoSupport.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingBeanInfoSupport.java?rev=1815632&r1=1815631&r2=1815632&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingBeanInfoSupport.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingBeanInfoSupport.java Fri Nov 17 21:42:18 2017
@@ -24,11 +24,9 @@ import java.awt.event.ActionListener;
import java.beans.PropertyDescriptor;
import java.beans.PropertyEditorSupport;
import java.util.ResourceBundle;
-import java.util.UUID;
import javax.swing.JCheckBox;
-import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.gui.ClearGui;
import org.apache.jmeter.testbeans.BeanInfoSupport;
import org.apache.jmeter.testbeans.TestBean;
@@ -40,6 +38,9 @@ import org.apache.jmeter.testbeans.gui.T
*/
public abstract class ScriptingBeanInfoSupport extends BeanInfoSupport {
+ static final String FALSE_AS_STRING = Boolean.FALSE.toString();
+ static final String TRUE_AS_STRING = Boolean.TRUE.toString();
+
public ScriptingBeanInfoSupport(Class<? extends TestBean> beanClass, String[] languageTags) {
this(beanClass, languageTags, null);
}
@@ -105,9 +106,10 @@ public abstract class ScriptingBeanInfoS
if (JSR223TestElement.class.isAssignableFrom(beanClass) ) {
p = property("cacheKey"); // $NON-NLS-1$
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
- p.setValue(DEFAULT, ""); // $NON-NLS-1$
+ p.setValue(NOT_OTHER, Boolean.TRUE);
+ p.setValue(DEFAULT, TRUE_AS_STRING); // $NON-NLS-1$
p.setPropertyEditorClass(JSR223ScriptCacheCheckboxEditor.class);
-
+ p.setValue(TAGS, new String[]{TRUE_AS_STRING,FALSE_AS_STRING});
createPropertyGroup("cacheKey_group", // $NON-NLS-1$
new String[] { "cacheKey" }); // $NON-NLS-1$
}
@@ -133,35 +135,23 @@ public abstract class ScriptingBeanInfoS
public JSR223ScriptCacheCheckboxEditor() {
super();
-
checkbox = new JCheckBox();
checkbox.addActionListener(this);
}
@Override
public String getAsText() {
- String value = null;
if(checkbox.isSelected()) {
- if(initialValue != null) {
- value = initialValue;
- }
- else {
- // the value is unique -> if the script is opened with a previous version of jmeter
- // where the cache key is used as the key for the cache
- // in the current version the key is automatically generated from the script content
- value = UUID.randomUUID().toString();
- }
+ return TRUE_AS_STRING;
+ } else {
+ return FALSE_AS_STRING;
}
-
- return value;
}
@Override
public void setAsText(String value) {
- if(StringUtils.isNotBlank(value)) {
- initialValue = value;
- }
- checkbox.setSelected(initialValue!= null);
+ initialValue = getBooleanValueAsString(value);
+ checkbox.setSelected(Boolean.parseBoolean(initialValue));
}
@Override
@@ -171,13 +161,27 @@ public abstract class ScriptingBeanInfoS
@Override
public void setValue(Object value) {
- if (value instanceof String) {
- setAsText((String) value);
+ if (value == null || value instanceof String) {
+ setAsText(getBooleanValueAsString((String)value));
} else {
throw new IllegalArgumentException();
}
}
-
+
+ /**
+ * "false" leads to false
+ * "true" or any other non "false" value leads to true
+ * @param value boolean or UUID
+ * @return String true/false
+ */
+ private static String getBooleanValueAsString(String value) {
+ return value == null ? FALSE_AS_STRING :
+ // We must use this form as:
+ // - "false" leads to false
+ // - "true" or any other non "false" value leads to true
+ Boolean.toString(!FALSE_AS_STRING.equals(value));
+ }
+
@Override
public Component getCustomEditor() {
return checkbox;
@@ -207,8 +211,8 @@ public abstract class ScriptingBeanInfoS
@Override
public void clearGui() {
- initialValue = null;
- checkbox.setSelected(false);
+ initialValue = TRUE_AS_STRING;
+ checkbox.setSelected(true);
}
}
}
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1815632&r1=1815631&r2=1815632&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Fri Nov 17 21:42:18 2017
@@ -163,6 +163,7 @@ Summary
<li><bug>61697</bug>Introduce Darcula Look And Feel to make JMeter UI more attractive</li>
<li><bug>61704</bug>Toolbar : Improve a bit the right part</li>
<li><bug>61731</bug>Enhance Test plan Backup with option to save before run. Based on a contribution by orimarko at gmail.com</li>
+ <li><bug>61640</bug>JSR223 Test Elements : Enable by default caching. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
</ul>
<ch_section>Non-functional changes</ch_section>