Author: fschumacher
Date: Fri Apr 28 19:30:23 2017
New Revision: 1793138
URL: http://svn.apache.org/viewvc?rev=1793138&view=rev
Log:
TableEditor can't be saved, when using two or more instances.
Bugfix provided by Emilian Bold (emi at apache.org)
This closes #293 on github.
Bugzilla Id: 58743
Added:
jmeter/trunk/test/src/org/apache/jmeter/testelement/property/AbstractPropertyTest.java
(with props)
Modified:
jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
jmeter/trunk/xdocs/changes.xml
Modified: jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java?rev=1793138&r1=1793137&r2=1793138&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java Fri
Apr 28 19:30:23 2017
@@ -297,11 +297,6 @@ public abstract class AbstractProperty i
* @return Collection of JMeterProperty objects
*/
protected Collection<JMeterProperty> normalizeList(Collection<?> coll) {
- if (coll.isEmpty()) {
- @SuppressWarnings("unchecked") // empty collection, local var is here to allow
SuppressWarnings
- Collection<JMeterProperty> okColl = (Collection<JMeterProperty>)
coll;
- return okColl;
- }
try {
@SuppressWarnings("unchecked") // empty collection
Collection<JMeterProperty> newColl = coll.getClass().newInstance();
@@ -324,11 +319,6 @@ public abstract class AbstractProperty i
* @return converted Map
*/
protected Map<String, JMeterProperty> normalizeMap(Map<?,?> coll) {
- if (coll.isEmpty()) {
- @SuppressWarnings("unchecked")// empty collection ok to cast, local var is here
to allow SuppressWarnings
- Map<String, JMeterProperty> emptyColl = (Map<String, JMeterProperty>)
coll;
- return emptyColl;
- }
try {
@SuppressWarnings("unchecked") // empty collection
Map<String, JMeterProperty> newColl = coll.getClass().newInstance();
Added: jmeter/trunk/test/src/org/apache/jmeter/testelement/property/AbstractPropertyTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/testelement/property/AbstractPropertyTest.java?rev=1793138&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/testelement/property/AbstractPropertyTest.java
(added)
+++ jmeter/trunk/test/src/org/apache/jmeter/testelement/property/AbstractPropertyTest.java
Fri Apr 28 19:30:23 2017
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.jmeter.testelement.property;
+
+import static org.junit.Assert.assertThat;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.jmeter.testelement.TestElement;
+import org.hamcrest.CoreMatchers;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AbstractPropertyTest {
+
+ private AbstractProperty dummyProperty;
+
+ @SuppressWarnings("serial")
+ @Before
+ public void setUp() {
+
+ this.dummyProperty = new AbstractProperty() {
+
+ @Override
+ public void setObjectValue(Object value) {
+ // not needed for our tests
+ }
+
+ @Override
+ public void recoverRunningVersion(TestElement owner) {
+ // not needed for our tests
+ }
+
+ @Override
+ public String getStringValue() {
+ // not needed for our tests
+ return null;
+ }
+
+ @Override
+ public Object getObjectValue() {
+ // not needed for our tests
+ return null;
+ }
+ };
+ }
+
+ @Test
+ public void testNormalizeListWithEmptyList() {
+ Collection<JMeterProperty> emptyCollection = Collections.emptyList();
+ Collection<JMeterProperty> newCollection = dummyProperty.normalizeList(emptyCollection);
+ assertThat(newCollection, CoreMatchers.nullValue());
+ }
+
+ @Test
+ public void testNormalizeListWithEmptyArrayList() {
+ Collection<JMeterProperty> emptyCollection = new ArrayList<JMeterProperty>();
+ Collection<JMeterProperty> newCollection = dummyProperty.normalizeList(emptyCollection);
+ assertThat(newCollection, CoreMatchers.not(CoreMatchers.sameInstance(emptyCollection)));
+ assertThat(newCollection, CoreMatchers.equalTo(emptyCollection));
+ }
+
+ @Test
+ public void testNormalizeListWithFilledArrayList() {
+ List<JMeterProperty> filledCollection = new ArrayList<JMeterProperty>();
+ filledCollection.add(new StringProperty("key", "value"));
+ Collection<JMeterProperty> newCollection = dummyProperty.normalizeList(filledCollection);
+ assertThat(newCollection, CoreMatchers.not(CoreMatchers.sameInstance(filledCollection)));
+ assertThat(newCollection, CoreMatchers.equalTo(filledCollection));
+ }
+
+ @Test
+ public void testNormalizeListWithEmptyMap() {
+ Map<String, JMeterProperty> emptyCollection = Collections.emptyMap();
+ Map<String, JMeterProperty> newCollection = dummyProperty.normalizeMap(emptyCollection);
+ assertThat(newCollection, CoreMatchers.nullValue());
+ }
+
+ @Test
+ public void testNormalizeMapWithEmptyHashMap() {
+ Map<String, JMeterProperty> emptyCollection = new HashMap<>();
+ Map<String, JMeterProperty> newCollection = dummyProperty.normalizeMap(emptyCollection);
+ assertThat(newCollection, CoreMatchers.not(CoreMatchers.sameInstance(emptyCollection)));
+ assertThat(newCollection, CoreMatchers.equalTo(emptyCollection));
+ }
+
+ @Test
+ public void testNormalizeMapWithFilledHashMap() {
+ Map<String, JMeterProperty> filledCollection = new HashMap<>();
+ filledCollection.put("someKey", new StringProperty("key", "value"));
+ Map<String, JMeterProperty> newCollection = dummyProperty.normalizeMap(filledCollection);
+ assertThat(newCollection, CoreMatchers.not(CoreMatchers.sameInstance(filledCollection)));
+ assertThat(newCollection, CoreMatchers.equalTo(filledCollection));
+ }
+}
Propchange: jmeter/trunk/test/src/org/apache/jmeter/testelement/property/AbstractPropertyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1793138&r1=1793137&r2=1793138&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Fri Apr 28 19:30:23 2017
@@ -147,6 +147,7 @@ Summary
<h3>Timers, Assertions, Config, Pre- & Post-Processors</h3>
<ul>
+ <li><bug>58743</bug><pr>293</bug>TableEditor can't be saved,
when using two or more instances. Bugfix provided by Emilian Bold (emi at apache.org)</li>
</ul>
<h3>Functions</h3>
@@ -176,6 +177,7 @@ Summary
<ul>
<li>Anass Benomar (abenomar at umanis.com, Mithrandir0407 @ github)</li>
<li>Anthony Kearns (anthony.kearns atrightside.co)</li>
+<li>Emilian Bold (emi @ apache.org)</li>
</ul>
<p>We also thank bug reporters who helped us improve JMeter. <br/>
For this release we want to give special thanks to the following reporters for the clear
reports and tests made after our fixes:</p>
|