use of org.apache.jmeter.protocol.http.control.RecordingController in project jmeter by apache.
the class ProxyControl method findTargetControllerNode.
/**
* Finds the controller where samplers have to be stored, that is:
* <ul>
* <li>The controller specified by the <code>target</code> property.
* <li>If none was specified, the first RecordingController in the tree.
* <li>If none is found, the first AbstractThreadGroup in the tree.
* </ul>
*
* @return the tree node for the controller where the proxy must store the
* generated samplers.
*/
public JMeterTreeNode findTargetControllerNode() {
JMeterTreeNode myTarget = getTarget();
if (myTarget != null) {
return myTarget;
}
myTarget = findFirstNodeOfType(RecordingController.class);
if (myTarget != null) {
return myTarget;
}
myTarget = findFirstNodeOfType(AbstractThreadGroup.class);
if (myTarget != null) {
return myTarget;
}
log.error("Program error: test script recording target not found.");
return null;
}
use of org.apache.jmeter.protocol.http.control.RecordingController in project jmeter by apache.
the class RecordController method createTestElement.
@Override
public TestElement createTestElement() {
RecordingController con = new RecordingController();
super.configureTestElement(con);
return con;
}
use of org.apache.jmeter.protocol.http.control.RecordingController in project jmeter by apache.
the class ProxyControlGui method startProxy.
private boolean startProxy() {
ValueReplacer replacer = GuiPackage.getInstance().getReplacer();
modifyTestElement(model);
TreeNodeWrapper treeNodeWrapper = (TreeNodeWrapper) targetNodesModel.getSelectedItem();
if (JMeterUtils.getResString("use_recording_controller").equals(treeNodeWrapper.getLabel())) {
JMeterTreeNode targetNode = model.findTargetControllerNode();
if (targetNode == null || !(targetNode.getTestElement() instanceof RecordingController)) {
JOptionPane.showMessageDialog(this, // $NON-NLS-1$
JMeterUtils.getResString("proxy_cl_wrong_target_cl"), // $NON-NLS-1$
JMeterUtils.getResString("error_title"), JOptionPane.ERROR_MESSAGE);
return false;
}
}
// Proxy can take some while to start up; show a waiting cursor
Cursor cursor = getCursor();
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
replacer.replaceValues(model);
model.startProxy();
start.setEnabled(false);
stop.setEnabled(true);
restart.setEnabled(false);
if (ProxyControl.isDynamicMode()) {
String[] details = model.getCertificateDetails();
StringBuilder sb = new StringBuilder();
sb.append("<html>");
// $NON-NLS-1$
sb.append(JMeterUtils.getResString("proxy_daemon_msg_rootca_cert")).append(" <b>").append(KeyToolUtils.ROOT_CACERT_CRT_PFX).append("</b> ").append(JMeterUtils.getResString("proxy_daemon_msg_created_in_bin"));
// $NON-NLS-1$
sb.append("<br>").append(JMeterUtils.getResString("proxy_daemon_msg_install_as_in_doc"));
sb.append("<br><b>").append(MessageFormat.format(JMeterUtils.getResString("proxy_daemon_msg_check_expiration"), // $NON-NLS-1$
ProxyControl.CERT_VALIDITY)).append("</b><br>");
sb.append("<br>").append(JMeterUtils.getResString("proxy_daemon_msg_check_details")).append(// $NON-NLS-1$
"<ul>");
for (String detail : details) {
sb.append("<li>").append(detail).append("</li>");
}
sb.append("</ul>").append("</html>");
// Make dialog disappear after 7 seconds
JLabel messageLabel = new JLabel(sb.toString());
Timer timer = new Timer(7000, evt -> {
Window window = SwingUtilities.getWindowAncestor(messageLabel);
// Window may be closed by user
if (window != null) {
window.dispose();
}
});
timer.setRepeats(false);
timer.start();
JOptionPane.showMessageDialog(this, messageLabel, // $NON-NLS-1$
JMeterUtils.getResString("proxy_daemon_msg_rootca_cert") + SPACE + KeyToolUtils.ROOT_CACERT_CRT_PFX + SPACE + // $NON-NLS-1$
JMeterUtils.getResString("proxy_daemon_msg_created_in_bin"), JOptionPane.INFORMATION_MESSAGE);
}
return true;
} catch (InvalidVariableException e) {
JOptionPane.showMessageDialog(this, // $NON-NLS-1$ $NON-NLS-2$
JMeterUtils.getResString("invalid_variables") + ": " + e.getMessage(), // $NON-NLS-1$
JMeterUtils.getResString("error_title"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (BindException e) {
JOptionPane.showMessageDialog(this, // $NON-NLS-1$ $NON-NLS-2$
JMeterUtils.getResString("proxy_daemon_bind_error") + ": " + e.getMessage(), // $NON-NLS-1$
JMeterUtils.getResString("error_title"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (IOException e) {
JOptionPane.showMessageDialog(this, // $NON-NLS-1$ $NON-NLS-2$
JMeterUtils.getResString("proxy_daemon_error") + ": " + e.getMessage(), // $NON-NLS-1$
JMeterUtils.getResString("error_title"), JOptionPane.ERROR_MESSAGE);
return false;
} finally {
setCursor(cursor);
}
}
Aggregations