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);
}
}
}
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());
}
}
Aggregations