jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject Re: svn commit: r1536042 - /jmeter/trunk/src/core/org/apache/jmeter/gui/action/Save.java
Date Sun, 27 Oct 2013 08:30:39 GMT
Good catch, forgot to commit

On Sunday, October 27, 2013, sebb wrote:

> On 26 October 2013 23:32,  <pmouawad@apache.org <javascript:;>> wrote:
> > Author: pmouawad
> > Date: Sat Oct 26 22:32:44 2013
> > New Revision: 1536042
> >
> > URL: http://svn.apache.org/r1536042
> > Log:
> > Bug 55693 - Add a "Save as Test Fragment" option
> > Bugzilla Id: 55693
> >
> > Modified:
> >     jmeter/trunk/src/core/org/apache/jmeter/gui/action/Save.java
> >
> > Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Save.java
> > URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Save.java?rev=1536042&r1=1536041&r2=1536042&view=diff
> >
> ==============================================================================
> > --- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Save.java
> (original)
> > +++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Save.java Sat Oct
> 26 22:32:44 2013
> > @@ -37,6 +37,7 @@ import org.apache.jmeter.gui.tree.JMeter
> >  import org.apache.jmeter.gui.util.FileDialoger;
> >  import org.apache.jmeter.save.SaveService;
> >  import org.apache.jmeter.testelement.TestElement;
> > +import org.apache.jmeter.testelement.TestPlan;
> >  import org.apache.jmeter.testelement.WorkBench;
> >  import org.apache.jmeter.util.JMeterUtils;
> >  import org.apache.jorphan.collections.HashTree;
> > @@ -100,15 +101,22 @@ public class Save implements Command {
> >          }
> >          else if
> (e.getActionCommand().equals(ActionNames.SAVE_AS_TEST_FRAGMENT)) {
> >              JMeterTreeNode[] nodes =
> GuiPackage.getInstance().getTreeListener().getSelectedNodes();
> > -            subTree = GuiPackage.getInstance().getCurrentSubTree();
> > -
> > -            TestElement element =
> GuiPackage.getInstance().createTestElement(TestFragmentControllerGui.class.getName());
> > -            HashTree hashTree = new ListedHashTree();
> > -            HashTree tfTree = hashTree.add(new JMeterTreeNode(element,
> null));
> > -            for (int i = 0; i < nodes.length; i++) {
> > -                tfTree.add(nodes[i]);
> > +            if(checkAcceptableForTestFragment(nodes)) {
> > +                subTree = GuiPackage.getInstance().getCurrentSubTree();
> > +
> > +                TestElement element =
> GuiPackage.getInstance().createTestElement(TestFragmentControllerGui.class.getName());
> > +                HashTree hashTree = new ListedHashTree();
> > +                HashTree tfTree = hashTree.add(new
> JMeterTreeNode(element, null));
> > +                for (int i = 0; i < nodes.length; i++) {
> > +                    tfTree.add(nodes[i]);
> > +                }
> > +                subTree = hashTree;
> > +            } else {
> > +                JMeterUtils.reportErrorToUser(
> > +
>  JMeterUtils.getResString("save_as_test_fragment_error"), // $NON-NLS-1$
>
> The above needs to be added to the properties files.
>
> > +
>  JMeterUtils.getResString("save_as_test_fragment")); // $NON-NLS-1$
> > +                return;
> >              }
> > -            subTree = hashTree;
> >          } else {
> >              fullSave = true;
> >              HashTree testPlan =
> GuiPackage.getInstance().getTreeModel().getTestPlan();
> > @@ -181,6 +189,21 @@ public class Save implements Command {
> >          GuiPackage.getInstance().updateCurrentGui();
> >      }
> >
> > +    /**
> > +     * Check nodes does not contain a node of type TestPlan or
> ThreadGroup
> > +     * @param nodes
> > +     */
> > +    private static final boolean
> checkAcceptableForTestFragment(JMeterTreeNode[] nodes) {
> > +        for (int i = 0; i < nodes.length; i++) {
> > +            Object userObject = nodes[i].getUserObject();
> > +            if(userObject instanceof
> org.apache.jmeter.threads.ThreadGroup ||
> > +                    userObject instanceof TestPlan) {
> > +                return false;
> > +            }
> > +        }
> > +        return true;
> > +    }
> > +
> >      // package protected to allow access from test code
> >      void convertSubTree(HashTree tree) {
> >          Iterator<Object> iter = new
> LinkedList<Object>(tree.list()).iterator();
> >
> >
>


-- 
Cordialement.
Philippe Mouawad.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message