Search in sources :

Example 11 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class TestElementConverter method unmarshal.

/** {@inheritDoc} */
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    String classAttribute = reader.getAttribute(ConversionHelp.ATT_CLASS);
    Class<?> type;
    if (classAttribute == null) {
        type = mapper().realClass(reader.getNodeName());
    } else {
        type = mapper().realClass(classAttribute);
    }
    // Update the test class name if necessary (Bug 52466)
    String inputName = type.getName();
    String targetName = inputName;
    String guiClassName = SaveService.aliasToClass(reader.getAttribute(ConversionHelp.ATT_TE_GUICLASS));
    targetName = NameUpdater.getCurrentTestName(inputName, guiClassName);
    if (!targetName.equals(inputName)) {
        // remap the class name
        type = mapper().realClass(targetName);
    }
    // needed by property converters  (Bug 52466)
    context.put(SaveService.TEST_CLASS_NAME, targetName);
    try {
        TestElement el = (TestElement) type.newInstance();
        // No need to check version, just process the attributes if present
        ConversionHelp.restoreSpecialProperties(el, reader);
        // Slight hack - we need to ensure the TestClass is not reset by the previous call
        el.setProperty(TestElement.TEST_CLASS, targetName);
        while (reader.hasMoreChildren()) {
            reader.moveDown();
            JMeterProperty prop = (JMeterProperty) readItem(reader, context, el);
            if (prop != null) {
                // could be null if it has been deleted via NameUpdater
                el.setProperty(prop);
            }
            reader.moveUp();
        }
        return el;
    } catch (InstantiationException | IllegalAccessException e) {
        log.error("TestElement not instantiable: {}", type, e);
        return null;
    }
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) TestElement(org.apache.jmeter.testelement.TestElement)

Example 12 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class LdapExtConfigGui method configure.

/**
     * 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);
    servername.setText(element.getPropertyAsString(LDAPExtSampler.SERVERNAME));
    port.setText(element.getPropertyAsString(LDAPExtSampler.PORT));
    rootdn.setText(element.getPropertyAsString(LDAPExtSampler.ROOTDN));
    scope.setSelectedIndex(element.getPropertyAsInt(LDAPExtSampler.SCOPE));
    countlim.setText(element.getPropertyAsString(LDAPExtSampler.COUNTLIM));
    timelim.setText(element.getPropertyAsString(LDAPExtSampler.TIMELIM));
    attribs.setText(element.getPropertyAsString(LDAPExtSampler.ATTRIBS));
    retobj.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.RETOBJ));
    deref.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.DEREF));
    connto.setText(element.getPropertyAsString(LDAPExtSampler.CONNTO));
    parseflag.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.PARSEFLAG));
    secure.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.SECURE));
    userpw.setText(element.getPropertyAsString(LDAPExtSampler.USERPW));
    userdn.setText(element.getPropertyAsString(LDAPExtSampler.USERDN));
    comparedn.setText(element.getPropertyAsString(LDAPExtSampler.COMPAREDN));
    comparefilt.setText(element.getPropertyAsString(LDAPExtSampler.COMPAREFILT));
    modddn.setText(element.getPropertyAsString(LDAPExtSampler.MODDDN));
    newdn.setText(element.getPropertyAsString(LDAPExtSampler.NEWDN));
    CardLayout cl = (CardLayout) (cards.getLayout());
    final String testType = element.getPropertyAsString(LDAPExtSampler.TEST);
    if (testType.equals(LDAPExtSampler.UNBIND)) {
        unbind.setSelected(true);
        cl.show(cards, CARDS_DEFAULT);
    } else if (testType.equals(LDAPExtSampler.BIND)) {
        bind.setSelected(true);
        cl.show(cards, CARDS_BIND);
    } else if (testType.equals(LDAPExtSampler.SBIND)) {
        sbind.setSelected(true);
        cl.show(cards, CARDS_BIND);
    } else if (testType.equals(LDAPExtSampler.COMPARE)) {
        compare.setSelected(true);
        cl.show(cards, CARDS_COMPARE);
    } else if (testType.equals(LDAPExtSampler.ADD)) {
        addTest.setSelected(true);
        add.setText(element.getPropertyAsString(LDAPExtSampler.BASE_ENTRY_DN));
        tableAddPanel.configure((TestElement) element.getProperty(LDAPExtSampler.ARGUMENTS).getObjectValue());
        cl.show(cards, CARDS_ADD);
    } else if (testType.equals(LDAPExtSampler.MODIFY)) {
        modifyTest.setSelected(true);
        modify.setText(element.getPropertyAsString(LDAPExtSampler.BASE_ENTRY_DN));
        tableModifyPanel.configure((TestElement) element.getProperty(LDAPExtSampler.LDAPARGUMENTS).getObjectValue());
        cl.show(cards, CARDS_MODIFY);
    } else if (testType.equals(LDAPExtSampler.DELETE)) {
        deleteTest.setSelected(true);
        delete.setText(element.getPropertyAsString(LDAPExtSampler.DELETE));
        cl.show(cards, CARDS_DELETE);
    } else if (testType.equals(LDAPExtSampler.RENAME)) {
        rename.setSelected(true);
        cl.show(cards, CARDS_RENAME);
    } else if (testType.equals(LDAPExtSampler.SEARCH)) {
        searchTest.setSelected(true);
        searchbase.setText(element.getPropertyAsString(LDAPExtSampler.SEARCHBASE));
        searchfilter.setText(element.getPropertyAsString(LDAPExtSampler.SEARCHFILTER));
        cl.show(cards, CARDS_SEARCH);
    }
}
Also used : CardLayout(java.awt.CardLayout) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) TestElement(org.apache.jmeter.testelement.TestElement)

Example 13 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class GenerateTreeGui method createTestElement.

@Override
public TestElement createTestElement() {
    TestElement el = new ConfigTestElement();
    modifyTestElement(el);
    return el;
}
Also used : TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement)

Example 14 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class ProxyControl method notifyTestListenersOfEnd.

/**
     * This will notify test listeners directly within the Proxy that the 'test'
     * (here meaning the proxy recording) has ended.
     */
private void notifyTestListenersOfEnd() {
    JMeterTreeModel treeModel = getJmeterTreeModel();
    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 TestStateListener) {
                // TL - TE
                ((TestStateListener) testElement).testEnded();
            }
        }
    }
}
Also used : JMeterTreeModel(org.apache.jmeter.gui.tree.JMeterTreeModel) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TestStateListener(org.apache.jmeter.testelement.TestStateListener) TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement)

Example 15 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class ProxyControl method notifyTestListenersOfStart.

/**
     * This will notify test listeners directly within the Proxy that the 'test'
     * (here meaning the proxy recording) has started.
     */
private void notifyTestListenersOfStart() {
    JMeterTreeModel treeModel = getJmeterTreeModel();
    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 TestStateListener) {
                ((TestStateListener) testElement).testStarted();
            }
        }
    }
}
Also used : JMeterTreeModel(org.apache.jmeter.gui.tree.JMeterTreeModel) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TestStateListener(org.apache.jmeter.testelement.TestStateListener) TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement)

Aggregations

TestElement (org.apache.jmeter.testelement.TestElement)83 Test (org.junit.Test)27 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)26 TestSampler (org.apache.jmeter.junit.stubs.TestSampler)21 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)18 TestPlan (org.apache.jmeter.testelement.TestPlan)12 ArrayList (java.util.ArrayList)9 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)9 StringProperty (org.apache.jmeter.testelement.property.StringProperty)7 Controller (org.apache.jmeter.control.Controller)6 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)6 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)6 TreePath (javax.swing.tree.TreePath)5 GuiPackage (org.apache.jmeter.gui.GuiPackage)5 ActionEvent (java.awt.event.ActionEvent)4 IOException (java.io.IOException)4 LinkedList (java.util.LinkedList)4 Arguments (org.apache.jmeter.config.Arguments)4 WorkBench (org.apache.jmeter.testelement.WorkBench)4 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)4