You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jakarta.apache.org by se...@apache.org on 2010/12/16 04:07:17 UTC
svn commit: r1049771 - in /jakarta/jmeter/trunk: bin/
docs/images/screenshots/ src/components/org/apache/jmeter/control/
src/components/org/apache/jmeter/control/gui/
src/core/org/apache/jmeter/control/gui/
src/core/org/apache/jmeter/gui/util/ src/core...
Author: sebb
Date: Thu Dec 16 03:07:16 2010
New Revision: 1049771
URL: http://svn.apache.org/viewvc?rev=1049771&view=rev
Log:
Bug 50475 - Introduction of a Test Fragment Test Element for a better Include flow
Added:
jakarta/jmeter/trunk/docs/images/screenshots/test_fragment.png (with props)
jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/TestFragmentController.java (with props)
jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/gui/TestFragmentControllerGui.java (with props)
jakarta/jmeter/trunk/xdocs/images/screenshots/test_fragment.png (with props)
Modified:
jakarta/jmeter/trunk/bin/saveservice.properties
jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java
jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/gui/TestPlanGui.java
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jakarta/jmeter/trunk/xdocs/changes.xml
jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
jakarta/jmeter/trunk/xdocs/usermanual/test_plan.xml
Modified: jakarta/jmeter/trunk/bin/saveservice.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/bin/saveservice.properties?rev=1049771&r1=1049770&r2=1049771&view=diff
==============================================================================
--- jakarta/jmeter/trunk/bin/saveservice.properties (original)
+++ jakarta/jmeter/trunk/bin/saveservice.properties Thu Dec 16 03:07:16 2010
@@ -254,6 +254,8 @@ TCPSamplerGui=org.apache.jmeter.protocol
TestAction=org.apache.jmeter.sampler.TestAction
TestActionGui=org.apache.jmeter.sampler.gui.TestActionGui
TestBeanGUI=org.apache.jmeter.testbeans.gui.TestBeanGUI
+TestFragmentController=org.apache.jmeter.control.TestFragmentController
+TestFragmentControllerGui=org.apache.jmeter.control.gui.TestFragmentControllerGui
TestPlan=org.apache.jmeter.testelement.TestPlan
TestPlanGui=org.apache.jmeter.control.gui.TestPlanGui
ThreadGroup=org.apache.jmeter.threads.ThreadGroup
Added: jakarta/jmeter/trunk/docs/images/screenshots/test_fragment.png
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/test_fragment.png?rev=1049771&view=auto
==============================================================================
Binary file - no diff available.
Propchange: jakarta/jmeter/trunk/docs/images/screenshots/test_fragment.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java?rev=1049771&r1=1049770&r2=1049771&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java Thu Dec 16 03:07:16 2010
@@ -26,6 +26,9 @@ import java.io.InputStream;
import java.util.Iterator;
import java.util.LinkedList;
+import org.apache.jmeter.testelement.TestPlan;
+import org.apache.jmeter.control.TestFragmentController;
+
import org.apache.jmeter.gui.tree.JMeterTreeNode;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.services.FileServer;
@@ -105,6 +108,10 @@ public class IncludeController extends G
return SUBTREE;
}
+ public TestElement getReplacementElement() {
+ return SUB;
+ }
+
public void resolveReplacementSubTree(JMeterTreeNode context) {
this.SUBTREE = this.loadIncludedElements();
}
@@ -135,6 +142,8 @@ public class IncludeController extends G
reader = new FileInputStream(file);
tree = SaveService.loadTree(reader);
+ // filter the tree for a TestFragment.
+ tree = getProperBranch(tree);
removeDisabledItems(tree);
return tree;
} catch (NoClassDefFoundError ex) // Allow for missing optional jars
@@ -164,6 +173,28 @@ public class IncludeController extends G
return tree;
}
+ private HashTree getProperBranch(HashTree tree) {
+ Iterator<Object> iter = new LinkedList<Object>(tree.list()).iterator();
+ while (iter.hasNext()) {
+ TestElement item = (TestElement) iter.next();
+
+ //if we found a TestPlan, then we are on our way to the TestFragment
+ if (item instanceof TestPlan)
+ {
+ return getProperBranch(tree.getTree(item));
+ }
+
+ if (item instanceof TestFragmentController)
+ {
+ return tree.getTree(item);
+ }
+ }
+ //return the tree since we didn't find a TestFragment. This will mimic the
+ //old behavior to import an exact node.
+ return tree;
+ }
+
+
private void removeDisabledItems(HashTree tree) {
Iterator<Object> iter = new LinkedList<Object>(tree.list()).iterator();
while (iter.hasNext()) {
Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/TestFragmentController.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/TestFragmentController.java?rev=1049771&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/TestFragmentController.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/TestFragmentController.java Thu Dec 16 03:07:16 2010
@@ -0,0 +1,27 @@
+/*
+ * 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.control;
+
+import java.io.Serializable;
+
+public class TestFragmentController extends GenericController implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+}
Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/TestFragmentController.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/TestFragmentController.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/gui/TestFragmentControllerGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/gui/TestFragmentControllerGui.java?rev=1049771&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/gui/TestFragmentControllerGui.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/gui/TestFragmentControllerGui.java Thu Dec 16 03:07:16 2010
@@ -0,0 +1,95 @@
+/*
+ * 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.control.gui;
+
+import java.util.Collection;
+import java.util.Arrays;
+import java.awt.BorderLayout;
+
+import org.apache.jmeter.gui.util.MenuFactory;
+import org.apache.jmeter.control.TestFragmentController;
+import org.apache.jmeter.testelement.TestElement;
+
+/**
+ * This defines a simple Test Fragment GUI that can be used instead of a Thread Group
+ * to allow for a non-execution part of the Test Plan that can be saved and referenced
+ * by a Module or Include Controller.
+ */
+
+public class TestFragmentControllerGui extends AbstractControllerGui {
+
+ private static final long serialVersionUID = 240L;
+
+ public TestFragmentControllerGui() {
+ init();
+ }
+
+ /**
+ * A newly created component can be initialized with the contents of a Test
+ * Element object by calling this method. The component is responsible for
+ * querying the Test Element object for the relevant information to display
+ * in its GUI.
+ *
+ * @param element
+ * the TestElement to configure
+ */
+ @Override
+ public void configure(TestElement element) {
+ super.configure(element);
+ }
+
+ /**
+ * Implements JMeterGUIComponent.createTestElement()
+ */
+ public TestElement createTestElement() {
+ TestFragmentController controller = new TestFragmentController();
+ modifyTestElement(controller);
+ return controller;
+ }
+
+ /**
+ * Implements JMeterGUIComponent.modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement controller) {
+ configureTestElement(controller);
+ }
+
+ public String getLabelResource() {
+ return "test_fragment_title"; // $NON-NLS-1$
+ }
+
+ /**
+ * Initialize the GUI components and layout for this component.
+ */
+ private void init() {
+ setLayout(new BorderLayout(0, 5));
+ setBorder(makeBorder());
+ add(makeTitlePanel(), BorderLayout.NORTH);
+ }
+
+ /**
+ * Over-ride this so that we add ourselves to the Test Fragment Category instead.
+ */
+ @Override
+ public Collection<String> getMenuCategories() {
+ return Arrays.asList(new String[] { MenuFactory.FRAGMENTS });
+ }
+
+
+}
Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/gui/TestFragmentControllerGui.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/control/gui/TestFragmentControllerGui.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/gui/TestPlanGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/gui/TestPlanGui.java?rev=1049771&r1=1049770&r2=1049771&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/gui/TestPlanGui.java (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/gui/TestPlanGui.java Thu Dec 16 03:07:16 2010
@@ -87,6 +87,7 @@ public class TestPlanGui extends Abstrac
JPopupMenu pop = new JPopupMenu();
JMenu addMenu = new JMenu(JMeterUtils.getResString("add")); // $NON-NLS-1$
addMenu.add(MenuFactory.makeMenu(MenuFactory.THREADS, ActionNames.ADD));
+ addMenu.add(MenuFactory.makeMenu(MenuFactory.FRAGMENTS, ActionNames.ADD));
addMenu.add(MenuFactory.makeMenu(MenuFactory.CONFIG_ELEMENTS, ActionNames.ADD));
addMenu.add(MenuFactory.makeMenu(MenuFactory.TIMERS, ActionNames.ADD));
addMenu.add(MenuFactory.makeMenu(MenuFactory.PRE_PROCESSORS, ActionNames.ADD));
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java?rev=1049771&r1=1049770&r2=1049771&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java Thu Dec 16 03:07:16 2010
@@ -67,6 +67,8 @@ public final class MenuFactory {
* and also for resource lookup in messages.properties
*/
public static final String THREADS = "menu_threads"; //$NON-NLS-1$
+
+ public static final String FRAGMENTS = "menu_fragments"; //$NON-NLS-1$
public static final String TIMERS = "menu_timer"; //$NON-NLS-1$
@@ -119,12 +121,13 @@ public final class MenuFactory {
private static final String[] MENU_PARENT_SAMPLER = new String[] {
MenuFactory.CONTROLLERS };
- private static final List<MenuInfo> timers, controllers, samplers, threads,
- configElements, assertions, listeners, nonTestElements,
+ private static final List<MenuInfo> timers, controllers, samplers, threads,
+ fragments,configElements, assertions, listeners, nonTestElements,
postProcessors, preProcessors;
static {
threads = new LinkedList<MenuInfo>();
+ fragments = new LinkedList<MenuInfo>();
timers = new LinkedList<MenuInfo>();
controllers = new LinkedList<MenuInfo>();
samplers = new LinkedList<MenuInfo>();
@@ -135,6 +138,7 @@ public final class MenuFactory {
preProcessors = new LinkedList<MenuInfo>();
nonTestElements = new LinkedList<MenuInfo>();
menuMap.put(THREADS, threads);
+ menuMap.put(FRAGMENTS, fragments);
menuMap.put(TIMERS, timers);
menuMap.put(ASSERTIONS, assertions);
menuMap.put(CONFIG_ELEMENTS, configElements);
@@ -465,6 +469,9 @@ public final class MenuFactory {
if (categories.contains(THREADS)) {
threads.add(new MenuInfo(item, name));
}
+ if (categories.contains(FRAGMENTS)) {
+ fragments.add(new MenuInfo(item, name));
+ }
if (categories.contains(TIMERS)) {
timers.add(new MenuInfo(item, name));
}
@@ -549,6 +556,14 @@ public final class MenuFactory {
return false;
}
TestElement parent = parentNode.getTestElement();
+
+ // Force TestFragment to only be pastable under a Test Plan
+ if (foundClass(nodes, new Class[]{org.apache.jmeter.control.TestFragmentController.class})){
+ if (parent instanceof TestPlan)
+ return true;
+ return false;
+ }
+
if (parent instanceof WorkBench) {// allow everything else
return true;
}
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1049771&r1=1049770&r2=1049771&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Thu Dec 16 03:07:16 2010
@@ -488,6 +488,7 @@ menu_edit=Edit
menu_expand_all=Expand All
menu_generative_controller=Sampler
menu_threads=Threads (Users)
+menu_fragments=Test Fragment
menu_listener=Listener
menu_logic_controller=Logic Controller
menu_merge=Merge
@@ -906,6 +907,7 @@ textbox_title_view=View text
textbox_tooltip_cell=Double click to view/edit
thread_delay_properties=Thread Delay Properties
thread_group_title=Thread Group
+test_fragment_title=Test Fragment
thread_properties=Thread Properties
threadgroup=Thread Group
throughput_control_bynumber_label=Total Executions
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=1049771&r1=1049770&r2=1049771&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Thu Dec 16 03:07:16 2010
@@ -151,6 +151,7 @@ Also enable reversion to using System.cu
<h3>Controllers</h3>
<ul>
+<li>Bug 50475 - Introduction of a Test Fragment Test Element for a better Include flow</li>
</ul>
<h3>Listeners</h3>
Added: jakarta/jmeter/trunk/xdocs/images/screenshots/test_fragment.png
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/test_fragment.png?rev=1049771&view=auto
==============================================================================
Binary file - no diff available.
Propchange: jakarta/jmeter/trunk/xdocs/images/screenshots/test_fragment.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1049771&r1=1049770&r2=1049771&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Thu Dec 16 03:07:16 2010
@@ -2025,11 +2025,14 @@ otherwise a duplicate may be accidentall
<component name="Include Controller" index="§-num;.2.14" width="419" height="118" screenshot="includecontroller.png">
<description>
<p>
-The include controller is designed to use an external jmx file. To use it, add
-samples to a simple controller, then save the simple controller as a jmx file.
-The file can then be used in a test plan.
-The included test plan must not include a Thread Group.
-It should only contain the Simple Controller and any samplers, controllers etc below it.
+The include controller is designed to use an external jmx file. To use it, create a Test Fragment
+underneath the Test Plan and add any desired samplers, controllers etc. below it.
+Then save the Test Plan. The file is now ready to be included as part of other Test Plans.
+</p>
+<p>
+For convenience, a Thread Group can also be added in the external JMX file for debugging purposes.
+A Module Controller can be used to reference the Test Fragment. The Thread Group will be ignored during the
+include process.
</p>
<p>
If the test uses a Cookie Manager or User Defined Variables, these should be placed in the top-level
@@ -5053,6 +5056,17 @@ This is intended for developer use only.
</properties>
</component>
+<component name="Test Fragment" index="§-num;.9.9" width="236" height="94" screenshot="test_fragment.png">
+<description>
+<p>
+The Test Fragment is used in conjunction with the <complink name="Include Controller"/> and <complink name="Module Controller"/>.
+</p>
+</description>
+<properties>
+ <property name="Name" required="Yes">Descriptive name for this element that is shown in the tree.</property>
+</properties>
+</component>
+
<a href="#">^</a>
</section>
Modified: jakarta/jmeter/trunk/xdocs/usermanual/test_plan.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/test_plan.xml?rev=1049771&r1=1049770&r2=1049771&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/test_plan.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/test_plan.xml Thu Dec 16 03:07:16 2010
@@ -226,6 +226,15 @@ will share the same cookies.</p>
Logic Controllers</a>.</p>
</subsection>
+<subsection name="§-num;.2.3 Test Fragments" anchor="test_fragments">
+<p>The Test Fragment element is a special type of <a href="#controllers">controller</a> that
+exists on the Test Plan tree at the same level as the Thread Group element. It is distinguished
+from a Thread Group in that it is not executed unless it is
+referenced by either a <complink name="Module Controller"/> or an <complink name="Include_Controller"/>.
+</p>
+<p>This element is purely for code re-use within Test Plans and was introduced in Version 2.5</p>
+</subsection>
+
<subsection name="§-num;.3 Listeners" anchor="listeners">
<p>Listeners provide access to the information JMeter gathers about the test cases while
JMeter runs. The <complink name="Graph
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org