You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by vl...@apache.org on 2019/10/05 08:16:42 UTC
[jmeter] 01/02: 62861: Ensure thread groups from pre-5.0 jmx are
loaded with "same user on each iteration"=true
This is an automated email from the ASF dual-hosted git repository.
vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git
commit f20a30fcebd919f78bfd191a04255721c2c36171
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Sat Oct 5 11:13:02 2019 +0300
62861: Ensure thread groups from pre-5.0 jmx are loaded with "same user on each iteration"=true
---
.../apache/jmeter/threads/AbstractThreadGroup.java | 2 +-
.../apache/jmeter/threads/gui/ThreadGroupGui.java | 8 +-
.../org/apache/jmeter/threads/ThreadGroupLoad.java | 101 +++++++++++++++++++++
3 files changed, 104 insertions(+), 7 deletions(-)
diff --git a/src/core/src/main/java/org/apache/jmeter/threads/AbstractThreadGroup.java b/src/core/src/main/java/org/apache/jmeter/threads/AbstractThreadGroup.java
index 17ceed8..1864600 100644
--- a/src/core/src/main/java/org/apache/jmeter/threads/AbstractThreadGroup.java
+++ b/src/core/src/main/java/org/apache/jmeter/threads/AbstractThreadGroup.java
@@ -325,6 +325,6 @@ public abstract class AbstractThreadGroup extends AbstractTestElement
* @return the kind of user.
*/
public boolean isSameUserOnNextIteration() {
- return getPropertyAsBoolean(ThreadGroup.IS_SAME_USER_ON_NEXT_ITERATION);
+ return getPropertyAsBoolean(ThreadGroup.IS_SAME_USER_ON_NEXT_ITERATION, true);
}
}
diff --git a/src/core/src/main/java/org/apache/jmeter/threads/gui/ThreadGroupGui.java b/src/core/src/main/java/org/apache/jmeter/threads/gui/ThreadGroupGui.java
index 80bb43e..9978565 100644
--- a/src/core/src/main/java/org/apache/jmeter/threads/gui/ThreadGroupGui.java
+++ b/src/core/src/main/java/org/apache/jmeter/threads/gui/ThreadGroupGui.java
@@ -125,12 +125,8 @@ public class ThreadGroupGui extends AbstractThreadGroupGui implements ItemListen
duration.setText(tg.getPropertyAsString(ThreadGroup.DURATION));
delay.setText(tg.getPropertyAsString(ThreadGroup.DELAY));
- final boolean isSameUser = tg.getPropertyAsBoolean(AbstractThreadGroup.IS_SAME_USER_ON_NEXT_ITERATION, false);
- if (isSameUser){
- sameUserBox.setSelected(true);
- } else {
- differentUserBox.setSelected(true);
- }
+ final boolean isSameUser = tg.getPropertyAsBoolean(AbstractThreadGroup.IS_SAME_USER_ON_NEXT_ITERATION, true);
+ sameUserBox.setSelected(isSameUser);
}
@Override
diff --git a/src/dist-check/src/test/java/org/apache/jmeter/threads/ThreadGroupLoad.java b/src/dist-check/src/test/java/org/apache/jmeter/threads/ThreadGroupLoad.java
new file mode 100644
index 0000000..a1f2401
--- /dev/null
+++ b/src/dist-check/src/test/java/org/apache/jmeter/threads/ThreadGroupLoad.java
@@ -0,0 +1,101 @@
+/*
+ * 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.threads;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Collections;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.save.SaveService;
+import org.apache.jorphan.collections.HashTree;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+public class ThreadGroupLoad {
+ static {
+ // Initialize properties
+ JMeterTestCase.assertPrimitiveEquals(true, true);
+ }
+
+ @TempDir
+ public Path tmpDir;
+
+ @Test
+ public void readJmxSavedWithJMeter26() throws IOException {
+ String jmx26 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<jmeterTestPlan version=\"1.2\" properties=\"2.2\">\n" +
+ " <hashTree>\n" +
+ " <TestPlan guiclass=\"TestPlanGui\" testclass=\"TestPlan\" testname=\"Test Plan\" enabled=\"true\">\n" +
+ " <stringProp name=\"TestPlan.comments\"></stringProp>\n" +
+ " <boolProp name=\"TestPlan.functional_mode\">false</boolProp>\n" +
+ " <boolProp name=\"TestPlan.serialize_threadgroups\">false</boolProp>\n" +
+ " <elementProp name=\"TestPlan.user_defined_variables\" elementType=\"Arguments\"" +
+ " guiclass=\"ArgumentsPanel\" testclass=\"Arguments\" testname=\"User Defined Variables\n" +
+ "\" enabled=\"true\">\n" +
+ " <collectionProp name=\"Arguments.arguments\"/>\n" +
+ " </elementProp>\n" +
+ " <stringProp name=\"TestPlan.user_define_classpath\"></stringProp>\n" +
+ " </TestPlan>\n" +
+ " <hashTree>\n" +
+ " <ThreadGroup guiclass=\"ThreadGroupGui\" testclass=\"ThreadGroup\" testname=\"Thread Group\" enabled=\"true\">\n" +
+ " <stringProp name=\"ThreadGroup.on_sample_error\">continue</stringProp>\n" +
+ " <elementProp name=\"ThreadGroup.main_controller\" elementType=\"LoopController\"" +
+ " guiclass=\"LoopControlPanel\" testclass=\"LoopController\" testname=\"Loop Control\n" +
+ "ler\" enabled=\"true\">\n" +
+ " <boolProp name=\"LoopController.continue_forever\">false</boolProp>\n" +
+ " <stringProp name=\"LoopController.loops\">1</stringProp>\n" +
+ " </elementProp>\n" +
+ " <stringProp name=\"ThreadGroup.num_threads\">1</stringProp>\n" +
+ " <stringProp name=\"ThreadGroup.ramp_time\">1</stringProp>\n" +
+ " <longProp name=\"ThreadGroup.start_time\">1570221190000</longProp>\n" +
+ " <longProp name=\"ThreadGroup.end_time\">1570221190000</longProp>\n" +
+ " <boolProp name=\"ThreadGroup.scheduler\">false</boolProp>\n" +
+ " <stringProp name=\"ThreadGroup.duration\"></stringProp>\n" +
+ " <stringProp name=\"ThreadGroup.delay\"></stringProp>\n" +
+ " </ThreadGroup>\n" +
+ " <hashTree/>\n" +
+ " </hashTree>\n" +
+ " </hashTree>\n" +
+ "</jmeterTestPlan>";
+
+ Path jmx = tmpDir.resolve("default_thread_group_2_6.xml");
+
+ Files.write(jmx, Collections.singleton(jmx26));
+
+ HashTree hashTree = SaveService.loadTree(jmx.toFile());
+ HashTree testPlanTree = hashTree.values().iterator().next();
+ ThreadGroup tg = (ThreadGroup) testPlanTree.keySet().iterator().next();
+
+ tg.setRunningVersion(true);
+ String actual = "getName: " + tg.getName() + "\n" +
+ "getNumThreads: " + tg.getNumThreads() + "\n" +
+ "getRampUp: " + tg.getRampUp() + "\n" +
+ "getScheduler: " + tg.getScheduler() + "\n" +
+ "isSameUserOnNextIteration: " + tg.isSameUserOnNextIteration() + "\n";
+
+ Assertions.assertEquals("getName: Thread Group\n" +
+ "getNumThreads: 1\n" +
+ "getRampUp: 1\n" +
+ "getScheduler: false\n" +
+ "isSameUserOnNextIteration: true\n", actual);
+ }
+}