Search in sources :

Example 11 with IllegalUserActionException

use of org.apache.jmeter.exceptions.IllegalUserActionException in project jmeter by apache.

the class What method doAction.

@Override
public void doAction(ActionEvent e) throws IllegalUserActionException {
    JMeterTreeNode node = GuiPackage.getInstance().getTreeListener().getCurrentNode();
    TestElement te = (TestElement) node.getUserObject();
    if (ActionNames.WHAT_CLASS.equals(e.getActionCommand())) {
        String guiClassName = te.getPropertyAsString(TestElement.GUI_CLASS);
        System.out.println(te.getClass().getName());
        System.out.println(guiClassName);
        if (log.isInfoEnabled()) {
            log.info("TestElement: {}, guiClassName: {}", te.getClass(), guiClassName);
        }
    } else if (ActionNames.DEBUG_ON.equals(e.getActionCommand())) {
        final String loggerName = te.getClass().getName();
        Configurator.setAllLevels(loggerName, Level.DEBUG);
        log.info("Log level set to DEBUG for {}", loggerName);
    } else if (ActionNames.DEBUG_OFF.equals(e.getActionCommand())) {
        final String loggerName = te.getClass().getName();
        Configurator.setAllLevels(loggerName, Level.INFO);
        log.info("Log level set to INFO for {}", loggerName);
    } else if (ActionNames.HEAP_DUMP.equals(e.getActionCommand())) {
        try {
            String s = HeapDumper.dumpHeap();
            JOptionPane.showMessageDialog(null, "Created " + s, "HeapDump", JOptionPane.INFORMATION_MESSAGE);
        } catch (Exception ex) {
            // NOSONAR We show cause in message
            JOptionPane.showMessageDialog(null, ex.toString(), "HeapDump", JOptionPane.ERROR_MESSAGE);
        }
    } else if (ActionNames.THREAD_DUMP.equals(e.getActionCommand())) {
        try {
            String s = ThreadDumper.threadDump();
            JOptionPane.showMessageDialog(null, "Created " + s, "ThreadDump", JOptionPane.INFORMATION_MESSAGE);
        } catch (Exception ex) {
            // NOSONAR We show cause in message
            JOptionPane.showMessageDialog(null, ex.toString(), "ThreadDump", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TestElement(org.apache.jmeter.testelement.TestElement) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException)

Example 12 with IllegalUserActionException

use of org.apache.jmeter.exceptions.IllegalUserActionException in project jmeter by apache.

the class ProxyControl method placeSampler.

private void placeSampler(final HTTPSamplerBase sampler, final TestElement[] testElements, JMeterTreeNode myTarget) {
    try {
        final JMeterTreeModel treeModel = getJmeterTreeModel();
        boolean firstInBatch = false;
        long now = System.currentTimeMillis();
        long deltaT = now - lastTime;
        int cachedGroupingMode = groupingMode;
        if (deltaT > SAMPLE_GAP) {
            if (!myTarget.isLeaf() && cachedGroupingMode == GROUPING_ADD_SEPARATORS) {
                addDivider(treeModel, myTarget);
            }
            if (cachedGroupingMode == GROUPING_IN_SIMPLE_CONTROLLERS) {
                addSimpleController(treeModel, myTarget, sampler.getName());
            }
            if (cachedGroupingMode == GROUPING_IN_TRANSACTION_CONTROLLERS) {
                addTransactionController(treeModel, myTarget, sampler.getName());
            }
            // Remember this was first in its batch
            firstInBatch = true;
        }
        if (lastTime == 0) {
            // Decent value for timers
            deltaT = 0;
        }
        lastTime = now;
        if (cachedGroupingMode == GROUPING_STORE_FIRST_ONLY) {
            if (!firstInBatch) {
                // Huh! don't store this one!
                return;
            }
            // If we're not storing subsequent samplers, we'll need the
            // first sampler to do all the work...:
            sampler.setFollowRedirects(true);
            sampler.setImageParser(true);
        }
        if (cachedGroupingMode == GROUPING_IN_SIMPLE_CONTROLLERS || cachedGroupingMode == GROUPING_IN_TRANSACTION_CONTROLLERS) {
            // sampler there:
            for (int i = myTarget.getChildCount() - 1; i >= 0; i--) {
                JMeterTreeNode c = (JMeterTreeNode) myTarget.getChildAt(i);
                if (c.getTestElement() instanceof GenericController) {
                    myTarget = c;
                    break;
                }
            }
        }
        final long deltaTFinal = deltaT;
        final boolean firstInBatchFinal = firstInBatch;
        final JMeterTreeNode myTargetFinal = myTarget;
        JMeterUtils.runSafe(true, () -> {
            try {
                final JMeterTreeNode newNode = treeModel.addComponent(sampler, myTargetFinal);
                if (firstInBatchFinal) {
                    if (addAssertions) {
                        addAssertion(treeModel, newNode);
                    }
                    addTimers(treeModel, newNode, deltaTFinal);
                }
                if (testElements != null) {
                    for (TestElement testElement : testElements) {
                        if (isAddableTestElement(testElement)) {
                            treeModel.addComponent(testElement, newNode);
                        }
                    }
                }
            } catch (IllegalUserActionException e) {
                log.error("Error placing sampler", e);
                JMeterUtils.reportErrorToUser(e.getMessage());
            }
        });
    } catch (Exception e) {
        log.error("Error placing sampler", e);
        JMeterUtils.reportErrorToUser(e.getMessage());
    }
}
Also used : JMeterTreeModel(org.apache.jmeter.gui.tree.JMeterTreeModel) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException) GenericController(org.apache.jmeter.control.GenericController) TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) CertificateExpiredException(java.security.cert.CertificateExpiredException) GeneralSecurityException(java.security.GeneralSecurityException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MalformedCachePatternException(org.apache.oro.text.MalformedCachePatternException) CertificateNotYetValidException(java.security.cert.CertificateNotYetValidException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) InvalidVariableException(org.apache.jmeter.functions.InvalidVariableException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException)

Aggregations

IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)12 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)8 TestElement (org.apache.jmeter.testelement.TestElement)5 IOException (java.io.IOException)4 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)3 TestPlan (org.apache.jmeter.testelement.TestPlan)3 ActionEvent (java.awt.event.ActionEvent)2 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)2 InvalidVariableException (org.apache.jmeter.functions.InvalidVariableException)2 GuiPackage (org.apache.jmeter.gui.GuiPackage)2 JMeterGUIComponent (org.apache.jmeter.gui.JMeterGUIComponent)2 HashTree (org.apache.jorphan.collections.HashTree)2 ListedHashTree (org.apache.jorphan.collections.ListedHashTree)2 ConversionException (com.thoughtworks.xstream.converters.ConversionException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1