You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2013/08/17 15:59:33 UTC
svn commit: r1514993 - in /jmeter/trunk: bin/testfiles/GenTest210.jmx
bin/testfiles/GenTest27.jmx
src/components/org/apache/jmeter/config/CSVDataSet.java
src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java
xdocs/changes.xml
Author: sebb
Date: Sat Aug 17 13:59:32 2013
New Revision: 1514993
URL: http://svn.apache.org/r1514993
Log:
CSV Dataset Config loses sharing mode when switching languages
Bugzilla Id: 55432
Modified:
jmeter/trunk/bin/testfiles/GenTest210.jmx
jmeter/trunk/bin/testfiles/GenTest27.jmx
jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java
jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java
jmeter/trunk/xdocs/changes.xml
Modified: jmeter/trunk/bin/testfiles/GenTest210.jmx
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/testfiles/GenTest210.jmx?rev=1514993&r1=1514992&r2=1514993&view=diff
==============================================================================
--- jmeter/trunk/bin/testfiles/GenTest210.jmx (original)
+++ jmeter/trunk/bin/testfiles/GenTest210.jmx Sat Aug 17 13:59:32 2013
@@ -126,7 +126,7 @@
<stringProp name="filename"></stringProp>
<boolProp name="quotedData">false</boolProp>
<boolProp name="recycle">true</boolProp>
- <stringProp name="shareMode">All threads</stringProp>
+ <stringProp name="shareMode">shareMode.all</stringProp>
<boolProp name="stopThread">false</boolProp>
<stringProp name="variableNames"></stringProp>
</CSVDataSet>
Modified: jmeter/trunk/bin/testfiles/GenTest27.jmx
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/testfiles/GenTest27.jmx?rev=1514993&r1=1514992&r2=1514993&view=diff
==============================================================================
--- jmeter/trunk/bin/testfiles/GenTest27.jmx (original)
+++ jmeter/trunk/bin/testfiles/GenTest27.jmx Sat Aug 17 13:59:32 2013
@@ -126,7 +126,7 @@
<stringProp name="filename"></stringProp>
<boolProp name="quotedData">false</boolProp>
<boolProp name="recycle">true</boolProp>
- <stringProp name="shareMode">All threads</stringProp>
+ <stringProp name="shareMode">shareMode.all</stringProp>
<boolProp name="stopThread">false</boolProp>
<stringProp name="variableNames"></stringProp>
</CSVDataSet>
Modified: jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java?rev=1514993&r1=1514992&r2=1514993&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java Sat Aug 17 13:59:32 2013
@@ -18,7 +18,11 @@
package org.apache.jmeter.config;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
import java.io.IOException;
+import java.util.ResourceBundle;
import org.apache.jmeter.engine.event.LoopIterationEvent;
import org.apache.jmeter.engine.event.LoopIterationListener;
@@ -26,6 +30,9 @@ import org.apache.jmeter.engine.util.NoC
import org.apache.jmeter.save.CSVSaveService;
import org.apache.jmeter.services.FileServer;
import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer;
+import org.apache.jmeter.testelement.property.JMeterProperty;
+import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterVariables;
import org.apache.jmeter.util.JMeterUtils;
@@ -96,9 +103,48 @@ public class CSVDataSet extends ConfigTe
}
/**
- * {@inheritDoc}
+ * Override the setProperty method in order to convert
+ * the original String shareMode propertty.
+ * This used the locale-dependent display value, so caused
+ * problems when the language was changed.
+ * If the "shareMode" value matches a resource value then it is converted
+ * into the resource key.
+ * To reduce the need to look up resources, we only attempt to
+ * convert values with spaces in them, as these are almost certainly
+ * not variables (and they are definitely not resource keys).
*/
@Override
+ public void setProperty(JMeterProperty property) {
+ if (property instanceof StringProperty) {
+ final String propName = property.getName();
+ if (propName.equals("shareMode")) { // The original name of the property
+ final String propValue = property.getStringValue();
+ if (propValue.contains(" ")){ // variables are unlikely to contain spaces, so most likely a translation
+ try {
+ final BeanInfo beanInfo = Introspector.getBeanInfo(this.getClass());
+ final ResourceBundle rb = (ResourceBundle) beanInfo.getBeanDescriptor().getValue(GenericTestBeanCustomizer.RESOURCE_BUNDLE);
+ for(String resKey : CSVDataSetBeanInfo.SHARE_TAGS) {
+ if (propValue.equals(rb.getString(resKey))) {
+ if (log.isDebugEnabled()) {
+ log.debug("Converted " + propName + "=" + propValue + " to " + resKey + " using Locale: " + rb.getLocale());
+ }
+ ((StringProperty) property).setValue(resKey); // reset the value
+ super.setProperty(property);
+ return;
+ }
+ }
+ // This could perhaps be a variable name
+ log.warn("Could not translate " + propName + "=" + propValue + " using Locale: " + rb.getLocale());
+ } catch (IntrospectionException e) {
+ log.error("Could not find BeanInfo; cannot translate shareMode entries", e);
+ }
+ }
+ }
+ }
+ super.setProperty(property);
+ }
+
+ @Override
public void iterationStart(LoopIterationEvent iterEvent) {
FileServer server = FileServer.getFileServer();
final JMeterContext context = getThreadContext();
Modified: jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java?rev=1514993&r1=1514992&r2=1514993&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java Sat Aug 17 13:59:32 2013
@@ -19,9 +19,9 @@
package org.apache.jmeter.config;
import java.beans.PropertyDescriptor;
-import java.util.ResourceBundle;
import org.apache.jmeter.testbeans.BeanInfoSupport;
+import org.apache.jmeter.testbeans.gui.TypeEditor;
public class CSVDataSetBeanInfo extends BeanInfoSupport {
@@ -35,21 +35,22 @@ public class CSVDataSetBeanInfo extends
private static final String QUOTED_DATA = "quotedData"; //$NON-NLS-1$
private static final String SHAREMODE = "shareMode"; //$NON-NLS-1$
- private static final String[] SHARE_TAGS = new String[3];
- static final int SHARE_ALL = 0;
- static final int SHARE_GROUP = 1;
- static final int SHARE_THREAD = 2;
-
+ // Access needed from CSVDataSet
+ static final String[] SHARE_TAGS = new String[3];
+ static final int SHARE_ALL = 0;
+ static final int SHARE_GROUP = 1;
+ static final int SHARE_THREAD = 2;
+
+ // Store the resource keys
+ static {
+ SHARE_TAGS[SHARE_ALL] = "shareMode.all"; //$NON-NLS-1$
+ SHARE_TAGS[SHARE_GROUP] = "shareMode.group"; //$NON-NLS-1$
+ SHARE_TAGS[SHARE_THREAD] = "shareMode.thread"; //$NON-NLS-1$
+ }
public CSVDataSetBeanInfo() {
super(CSVDataSet.class);
- ResourceBundle rb = (ResourceBundle) getBeanDescriptor().getValue(RESOURCE_BUNDLE);
-// These must agree with the resources
- SHARE_TAGS[SHARE_ALL] = rb.getString("shareMode.all"); //$NON-NLS-1$
- SHARE_TAGS[SHARE_GROUP] = rb.getString("shareMode.group"); //$NON-NLS-1$
- SHARE_TAGS[SHARE_THREAD] = rb.getString("shareMode.thread"); //$NON-NLS-1$
-
createPropertyGroup("csv_data", //$NON-NLS-1$
new String[] { FILENAME, FILE_ENCODING, VARIABLE_NAMES, DELIMITER, QUOTED_DATA, RECYCLE, STOPTHREAD, SHAREMODE });
@@ -85,15 +86,15 @@ public class CSVDataSetBeanInfo extends
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, Boolean.FALSE);
- p = property(SHAREMODE); //$NON-NLS-1$
+ p = property(SHAREMODE, TypeEditor.ComboStringEditor);
+ p.setValue(RESOURCE_BUNDLE, getBeanDescriptor().getValue(RESOURCE_BUNDLE));
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
- p.setValue(DEFAULT, SHARE_TAGS[0]);
+ p.setValue(DEFAULT, SHARE_TAGS[SHARE_ALL]);
p.setValue(NOT_OTHER, Boolean.FALSE);
p.setValue(NOT_EXPRESSION, Boolean.FALSE);
p.setValue(TAGS, SHARE_TAGS);
}
- // TODO need to find better way to do this
public static int getShareModeAsInt(String mode) {
if (mode == null || mode.length() == 0){
return SHARE_ALL; // default (e.g. if test plan does not have definition)
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1514993&r1=1514992&r2=1514993&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Aug 17 13:59:32 2013
@@ -359,6 +359,7 @@ Previously the default was 1, which coul
<ul>
<li><bugzilla>55241</bugzilla> - Need GUI Editor to process fields which are based on Enums with localised display strings</li>
<li><bugzilla>55440</bugzilla> - ComboStringEditor should allow tags to be language dependent</li>
+<li><bugzilla>55432</bugzilla> - CSV Dataset Config loses sharing mode when switching languages</li>
</ul>
<h3>General</h3>