예제 #1
0
        /**
         * Refactored from AbstractAction.java
         *
         * @param tree
         */
        public static void ConvertSubTree(HashTree tree)
        {
            LinkedList<Object> copyList = new LinkedList<Object>(tree.list());
            foreach (Object obj  in copyList)
            {
                if (typeof(TestElement).IsAssignableFrom(obj.GetType()))
                {
                    TestElement item = (TestElement) obj;
                    if (item.isEnabled())
                    {
                        if (typeof(ReplaceableController).IsAssignableFrom(item.GetType()))
                        {
                            ReplaceableController rc;

                            // TODO this bit of code needs to be tidied up
                            // Unfortunately ModuleController is in components, not core
                            if (item.GetType().Name.Equals("org.apache.jmeter.control.ModuleController"))
                            { // Bug 47165
                                rc = (ReplaceableController) item;
                            }
                            else
                            {
                                // HACK: force the controller to load its tree
                                rc = (ReplaceableController) item.Clone();
                            }

                            HashTree subTree = tree.GetTree(item);
                            if (subTree != null)
                            {
                                HashTree replacementTree = rc.getReplacementSubTree();
                                if (replacementTree != null)
                                {
                                    ConvertSubTree(replacementTree);
                                    tree.Replace(item, rc);
                                    tree.Set(rc, replacementTree);
                                }
                            }
                            else
                            { // null subTree
                                ConvertSubTree(tree.GetTree(item));
                            }
                        }
                        else
                        { // not Replaceable Controller
                            ConvertSubTree(tree.GetTree(item));
                        }
                    }
                    else
                    { // Not enabled
                        tree.Remove(item);
                    }
                }
                else
                { // Not a TestElement
                    NetMeterTreeNode item = (NetMeterTreeNode) obj;
                    if (item.isEnabled())
                    {
                        // Replacement only needs to occur when starting the engine
                        // @see StandardJMeterEngine.run()
                        if (item.getUserObject() is ReplaceableController)
                        {
                            ReplaceableController rc = (ReplaceableController) item.getTestElement();
                            HashTree subTree = tree.GetTree(item);

                            if (subTree != null)
                            {
                                HashTree replacementTree = rc.getReplacementSubTree();
                                if (replacementTree != null)
                                {
                                    ConvertSubTree(replacementTree);
                                    tree.Replace(item, rc);
                                    tree.Set(rc, replacementTree);
                                }
                            }
                        }
                        else
                        { // Not a ReplaceableController
                            ConvertSubTree(tree.GetTree(item));
                            TestElement testElement = item.getTestElement();
                            tree.Replace(item, testElement);
                        }
                     }
                    else
                    { // Not enabled
                        tree.Remove(item);
                    }
                }
            }
        }
예제 #2
0
        /**
         * Refactored from AbstractAction.java
         *
         * @param tree
         */
        public static void ConvertSubTree(HashTree tree)
        {
            LinkedList <Object> copyList = new LinkedList <Object>(tree.list());

            foreach (Object obj  in copyList)
            {
                if (typeof(TestElement).IsAssignableFrom(obj.GetType()))
                {
                    TestElement item = (TestElement)obj;
                    if (item.isEnabled())
                    {
                        if (typeof(ReplaceableController).IsAssignableFrom(item.GetType()))
                        {
                            ReplaceableController rc;

                            // TODO this bit of code needs to be tidied up
                            // Unfortunately ModuleController is in components, not core
                            if (item.GetType().Name.Equals("org.apache.jmeter.control.ModuleController"))
                            { // Bug 47165
                                rc = (ReplaceableController)item;
                            }
                            else
                            {
                                // HACK: force the controller to load its tree
                                rc = (ReplaceableController)item.Clone();
                            }

                            HashTree subTree = tree.GetTree(item);
                            if (subTree != null)
                            {
                                HashTree replacementTree = rc.getReplacementSubTree();
                                if (replacementTree != null)
                                {
                                    ConvertSubTree(replacementTree);
                                    tree.Replace(item, rc);
                                    tree.Set(rc, replacementTree);
                                }
                            }
                            else
                            { // null subTree
                                ConvertSubTree(tree.GetTree(item));
                            }
                        }
                        else
                        { // not Replaceable Controller
                            ConvertSubTree(tree.GetTree(item));
                        }
                    }
                    else
                    { // Not enabled
                        tree.Remove(item);
                    }
                }
                else
                { // Not a TestElement
                    NetMeterTreeNode item = (NetMeterTreeNode)obj;
                    if (item.isEnabled())
                    {
                        // Replacement only needs to occur when starting the engine
                        // @see StandardJMeterEngine.run()
                        if (item.getUserObject() is ReplaceableController)
                        {
                            ReplaceableController rc = (ReplaceableController)item.getTestElement();
                            HashTree subTree         = tree.GetTree(item);

                            if (subTree != null)
                            {
                                HashTree replacementTree = rc.getReplacementSubTree();
                                if (replacementTree != null)
                                {
                                    ConvertSubTree(replacementTree);
                                    tree.Replace(item, rc);
                                    tree.Set(rc, replacementTree);
                                }
                            }
                        }
                        else
                        { // Not a ReplaceableController
                            ConvertSubTree(tree.GetTree(item));
                            TestElement testElement = item.getTestElement();
                            tree.Replace(item, testElement);
                        }
                    }
                    else
                    { // Not enabled
                        tree.Remove(item);
                    }
                }
            }
        }