Package org.apache.jmeter.testelement

Examples of org.apache.jmeter.testelement.TestElement


        JMeterTreeNode myNode = treeModel.getNodeOf(this);
        Enumeration<JMeterTreeNode> kids = myNode.children();
        while (kids.hasMoreElements()) {
            JMeterTreeNode subNode = kids.nextElement();
            if (subNode.isEnabled()) {
                TestElement testElement = subNode.getTestElement();
                if (testElement instanceof SampleListener) {
                    ((SampleListener) testElement).sampleOccurred(event);
                }
            }
        }
View Full Code Here


        JMeterTreeNode myNode = treeModel.getNodeOf(this);
        Enumeration<JMeterTreeNode> kids = myNode.children();
        while (kids.hasMoreElements()) {
            JMeterTreeNode subNode = kids.nextElement();
            if (subNode.isEnabled()) {
                TestElement testElement = subNode.getTestElement();
                if (testElement instanceof TestListener) {
                    ((TestListener) testElement).testStarted();
                }
            }
        }
View Full Code Here

        JMeterTreeNode myNode = treeModel.getNodeOf(this);
        Enumeration<JMeterTreeNode> kids = myNode.children();
        while (kids.hasMoreElements()) {
            JMeterTreeNode subNode = kids.nextElement();
            if (subNode.isEnabled()) {
                TestElement testElement = subNode.getTestElement();
                if (testElement instanceof TestListener) {
                    ((TestListener) testElement).testEnded();
                }
            }
        }
View Full Code Here

    public static void convertSubTree(HashTree tree) {
        Iterator<Object> iter = new LinkedList<Object>(tree.list()).iterator();
        while (iter.hasNext()) {
            Object o = iter.next();
            if (o instanceof TestElement) {
                TestElement item = (TestElement) o;
                if (item.isEnabled()) {
                    if (item instanceof ReplaceableController) {
                        ReplaceableController rc;

                        // TODO this bit of code needs to be tidied up
                        // Unfortunately ModuleController is in components, not core
                        if (item.getClass().getName().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
                JMeterTreeNode item = (JMeterTreeNode) o;
                if (item.isEnabled()) {
                    // Replacement only needs to occur when starting the engine
                    // @see StandardJMeterEngine.run()
                    if (item.getUserObject() instanceof 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);
                }
View Full Code Here

     */
    private static Test suiteTestElements() throws Exception {
        TestSuite suite = new TestSuite("TestElements");
        Iterator<Object> iter = getObjects(TestElement.class).iterator();
        while (iter.hasNext()) {
            TestElement item = (TestElement) iter.next();
            TestSuite ts = new TestSuite(item.getClass().getName());
            ts.addTest(new JMeterTest("runTestElement", item));
            suite.addTest(ts);
        }
        return suite;
    }
View Full Code Here

        assertEquals("CLONE-SAME-CLASS: testing " + item.getClass().getName(), item.getClass().getName(), clonedItem
                .getClass().getName());
    }

    private static void checkElementCloning(TestElement item) {
        TestElement clonedItem = (TestElement) item.clone();
        cloneTesting(item, clonedItem);
        PropertyIterator iter2 = item.propertyIterator();
        while (iter2.hasNext()) {
            JMeterProperty item2 = iter2.next();
            // [sebb] assertEquals(item2,
            // clonedItem.getProperty(item2.getName()));
            assertEquals(item2.getStringValue(), clonedItem.getProperty(item2.getName()).getStringValue());
            assertTrue(item2 != clonedItem.getProperty(item2.getName()));
        }
    }
View Full Code Here

        {
            for (int i = 0; i < node.getChildCount(); i++)
            {
                StringBuffer name = new StringBuffer();
                JMeterTreeNode cur = (JMeterTreeNode) node.getChildAt(i);
                TestElement te = cur.getTestElement();
/*
* Will never be true.
* Probably intended to use org.apache.jmeter.threads.ThreadGroup rather than java.lang.ThreadGroup
* However, that does not work correctly; whereas treating it as a Controller does.
                if (te instanceof ThreadGroup)
View Full Code Here

        while (children.hasMoreElements())
        {
            JMeterTreeNode templateNode= (JMeterTreeNode)children.nextElement();
            if (templateNode.isEnabled())
            {
                TestElement template= templateNode.getTestElement();
                if (template instanceof Timer)
                {
                    TestElement timer= (TestElement)template.clone();
                    try
                    {
                        replacer.undoReverseReplace(timer);
                        model.addComponent(timer, node);
                    }
View Full Code Here

            controller.initialize();
            for (int i = 0; i < 4; i++)
            {
                assertEquals(14, counter);
                counter = 0;
                TestElement sampler = null;
                while ((sampler = controller.next()) != null)
                {
                    if (counter == 0)
                    {
                        assertEquals(
                            interleaveOrder[i % 2],
                            sampler.getPropertyAsString(TestElement.NAME));
                    }
                    else
                    {
                        assertEquals(
                            order[counter],
                            sampler.getPropertyAsString(TestElement.NAME));
                    }
                    counter++;
                }
            }
        }
View Full Code Here

            controller.initialize();
            for (int i = 0; i < 4; i++)
            {
                assertEquals(1, counter);
                counter = 0;
                TestElement sampler = null;
                while ((sampler = controller.next()) != null)
                {
                    assertEquals(
                        "one",
                        sampler.getPropertyAsString(TestElement.NAME));
                    counter++;
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jmeter.testelement.TestElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.