Bug 60543 - HTTP Request / Http Request Defaults UX: Move to advanced panel Timeouts, Implementation, Proxy

Bugzilla Id: 60543

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1777041 13f79535-47bb-0310-9956-ffa450edef68

Former-commit-id: 2c182abb1a
This commit is contained in:
Philippe Mouawad 2017-01-02 23:55:21 +00:00
parent b9f0b42b26
commit 27c7ea15e0
4 changed files with 406 additions and 284 deletions

View File

@ -20,15 +20,19 @@ package org.apache.jmeter.protocol.http.config.gui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.UIManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.config.ConfigTestElement;
@ -36,12 +40,14 @@ import org.apache.jmeter.config.gui.AbstractConfigGui;
import org.apache.jmeter.gui.util.HorizontalPanel;
import org.apache.jmeter.gui.util.VerticalPanel;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerFactory;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.testelement.property.IntegerProperty;
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.JLabeledChoice;
import org.apache.jorphan.gui.JLabeledTextField;
/**
@ -52,6 +58,10 @@ public class HttpDefaultsGui extends AbstractConfigGui {
private static final long serialVersionUID = 241L;
private static final Font FONT_DEFAULT = UIManager.getDefaults().getFont("TextField.font");
private static final Font FONT_SMALL = new Font("SansSerif", Font.PLAIN, (int) Math.round(FONT_DEFAULT.getSize() * 0.8));
private UrlConfigGui urlConfigGui;
private JCheckBox retrieveEmbeddedResources;
@ -68,6 +78,21 @@ public class HttpDefaultsGui extends AbstractConfigGui {
private JComboBox<String> sourceIpType = new JComboBox<>(HTTPSamplerBase.getSourceTypeList());
private JTextField proxyHost;
private JTextField proxyPort;
private JTextField proxyUser;
private JPasswordField proxyPass;
private JLabeledChoice httpImplementation;
private JTextField connectTimeOut;
private JTextField responseTimeOut;
public HttpDefaultsGui() {
super();
init();
@ -141,6 +166,15 @@ public class HttpDefaultsGui extends AbstractConfigGui {
config.removeProperty(HTTPSamplerBase.IP_SOURCE);
config.removeProperty(HTTPSamplerBase.IP_SOURCE_TYPE);
}
config.setProperty(HTTPSamplerBase.PROXYHOST, proxyHost.getText(),"");
config.setProperty(HTTPSamplerBase.PROXYPORT, proxyPort.getText(),"");
config.setProperty(HTTPSamplerBase.PROXYUSER, proxyUser.getText(),"");
config.setProperty(HTTPSamplerBase.PROXYPASS, String.valueOf(proxyPass.getPassword()),"");
config.setProperty(HTTPSamplerBase.IMPLEMENTATION, httpImplementation.getText(),"");
config.setProperty(HTTPSamplerBase.CONNECT_TIMEOUT, connectTimeOut.getText());
config.setProperty(HTTPSamplerBase.RESPONSE_TIMEOUT, responseTimeOut.getText());
}
/**
@ -158,6 +192,13 @@ public class HttpDefaultsGui extends AbstractConfigGui {
embeddedRE.setText(""); // $NON-NLS-1$
sourceIpAddr.setText(""); // $NON-NLS-1$
sourceIpType.setSelectedIndex(HTTPSamplerBase.SourceType.HOSTNAME.ordinal()); //default: IP/Hostname
proxyHost.setText(""); // $NON-NLS-1$
proxyPort.setText(""); // $NON-NLS-1$
proxyUser.setText(""); // $NON-NLS-1$
proxyPass.setText(""); // $NON-NLS-1$
httpImplementation.setText(""); // $NON-NLS-1$
connectTimeOut.setText(""); // $NON-NLS-1$
responseTimeOut.setText(""); // $NON-NLS-1$
}
@Override
@ -174,6 +215,14 @@ public class HttpDefaultsGui extends AbstractConfigGui {
sourceIpType.setSelectedIndex(
samplerBase.getPropertyAsInt(HTTPSamplerBase.IP_SOURCE_TYPE,
HTTPSamplerBase.SOURCE_TYPE_DEFAULT));
proxyHost.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYHOST));
proxyPort.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYPORT));
proxyUser.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYUSER));
proxyPass.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYPASS));
httpImplementation.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.IMPLEMENTATION));
connectTimeOut.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.CONNECT_TIMEOUT));
responseTimeOut.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.RESPONSE_TIMEOUT));
}
private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
@ -186,7 +235,10 @@ public class HttpDefaultsGui extends AbstractConfigGui {
// AdvancedPanel (embedded resources, source address and optional tasks)
JPanel advancedPanel = new VerticalPanel();
advancedPanel.add(createEmbeddedRsrcPanel());
advancedPanel.add(getTimeOutPanel());
advancedPanel.add(getImplementationPanel());
advancedPanel.add(createSourceAddrPanel());
advancedPanel.add(getProxyServerPanel());
advancedPanel.add(createOptionalTasksPanel());
JTabbedPane tabbedPane = new JTabbedPane();
@ -203,6 +255,43 @@ public class HttpDefaultsGui extends AbstractConfigGui {
add(emptyPanel, BorderLayout.SOUTH);
}
private JPanel getTimeOutPanel() {
JPanel timeOut = new HorizontalPanel();
timeOut.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("web_server_timeout_title"))); // $NON-NLS-1$
final JPanel connPanel = getConnectTimeOutPanel();
final JPanel reqPanel = getResponseTimeOutPanel();
timeOut.add(connPanel);
timeOut.add(reqPanel);
return timeOut;
}
private JPanel getConnectTimeOutPanel() {
connectTimeOut = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_timeout_connect")); // $NON-NLS-1$
label.setLabelFor(connectTimeOut);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(connectTimeOut, BorderLayout.CENTER);
return panel;
}
private JPanel getResponseTimeOutPanel() {
responseTimeOut = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_timeout_response")); // $NON-NLS-1$
label.setLabelFor(responseTimeOut);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(responseTimeOut, BorderLayout.CENTER);
return panel;
}
protected JPanel createEmbeddedRsrcPanel() {
// retrieve Embedded resources
retrieveEmbeddedResources = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$
@ -286,4 +375,94 @@ public class HttpDefaultsGui extends AbstractConfigGui {
embeddedRE.setEnabled(false);
}
}
/**
* Create a panel containing the implementation details
*
* @return the panel
*/
protected final JPanel getImplementationPanel(){
JPanel implPanel = new HorizontalPanel();
httpImplementation = new JLabeledChoice(JMeterUtils.getResString("http_implementation"), // $NON-NLS-1$
HTTPSamplerFactory.getImplementations());
httpImplementation.addValue("");
implPanel.add(httpImplementation);
return implPanel;
}
/**
* Create a panel containing the proxy server details
*
* @return the panel
*/
protected final JPanel getProxyServerPanel(){
JPanel proxyServer = new HorizontalPanel();
proxyServer.add(getProxyHostPanel(), BorderLayout.CENTER);
proxyServer.add(getProxyPortPanel(), BorderLayout.EAST);
JPanel proxyLogin = new HorizontalPanel();
proxyLogin.add(getProxyUserPanel());
proxyLogin.add(getProxyPassPanel());
JPanel proxyServerPanel = new HorizontalPanel();
proxyServerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("web_proxy_server_title"))); // $NON-NLS-1$
proxyServerPanel.add(proxyServer);
proxyServerPanel.add(proxyLogin);
return proxyServerPanel;
}
private JPanel getProxyHostPanel() {
proxyHost = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_domain")); // $NON-NLS-1$
label.setLabelFor(proxyHost);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyHost, BorderLayout.CENTER);
return panel;
}
private JPanel getProxyPortPanel() {
proxyPort = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_port")); // $NON-NLS-1$
label.setLabelFor(proxyPort);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyPort, BorderLayout.CENTER);
return panel;
}
private JPanel getProxyUserPanel() {
proxyUser = new JTextField(5);
JLabel label = new JLabel(JMeterUtils.getResString("username")); // $NON-NLS-1$
label.setLabelFor(proxyUser);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyUser, BorderLayout.CENTER);
return panel;
}
private JPanel getProxyPassPanel() {
proxyPass = new JPasswordField(5);
JLabel label = new JLabel(JMeterUtils.getResString("password")); // $NON-NLS-1$
label.setLabelFor(proxyPass);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyPass, BorderLayout.CENTER);
return panel;
}
}

View File

@ -24,15 +24,11 @@ import java.awt.FlowLayout;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@ -43,11 +39,9 @@ import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.gui.util.HorizontalPanel;
import org.apache.jmeter.gui.util.JSyntaxTextArea;
import org.apache.jmeter.gui.util.JTextScrollPane;
import org.apache.jmeter.gui.util.VerticalPanel;
import org.apache.jmeter.protocol.http.gui.HTTPArgumentsPanel;
import org.apache.jmeter.protocol.http.gui.HTTPFileArgsPanel;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerFactory;
import org.apache.jmeter.protocol.http.util.HTTPArgument;
import org.apache.jmeter.protocol.http.util.HTTPConstants;
import org.apache.jmeter.testelement.TestElement;
@ -56,6 +50,7 @@ import org.apache.jmeter.testelement.property.JMeterProperty;
import org.apache.jmeter.testelement.property.TestElementProperty;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.JLabeledChoice;
import org.apache.jorphan.gui.JLabeledTextField;
/**
* Basic URL / HTTP Request configuration:
@ -84,27 +79,15 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
private HTTPFileArgsPanel filesPanel;
private JTextField domain;
private JLabeledTextField domain;
private JTextField port;
private JLabeledTextField port;
private JTextField proxyHost;
private JLabeledTextField protocol;
private JTextField proxyPort;
private JLabeledTextField contentEncoding;
private JTextField proxyUser;
private JPasswordField proxyPass;
private JTextField connectTimeOut;
private JTextField responseTimeOut;
private JTextField protocol;
private JTextField contentEncoding;
private JTextField path;
private JLabeledTextField path;
private JCheckBox followRedirects;
@ -118,13 +101,9 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
private JLabeledChoice method;
private JLabeledChoice httpImplementation;
// set this false to suppress some items for use in HTTP Request defaults
private final boolean notConfigOnly;
private final boolean showImplementation; // Set false for AJP
// Body data
private JSyntaxTextArea postBodyContent;
@ -149,33 +128,28 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
* flag whether sampler fields should be shown.
*/
public UrlConfigGui(boolean showSamplerFields) {
this(showSamplerFields, true, true);
this(showSamplerFields, true);
}
/**
* @param showSamplerFields
* flag whether sampler fields should be shown
* @param showImplementation
* Show HTTP Implementation
* @param showRawBodyPane
* flag whether the raw body pane should be shown
*/
public UrlConfigGui(boolean showSamplerFields, boolean showImplementation, boolean showRawBodyPane) {
this(showSamplerFields, showImplementation, showRawBodyPane, false);
public UrlConfigGui(boolean showSamplerFields, boolean showRawBodyPane) {
this(showSamplerFields, showRawBodyPane, false);
}
/**
* @param showSamplerFields
* flag whether sampler fields should be shown
* @param showImplementation
* Show HTTP Implementation
* @param showRawBodyPane
* flag whether the raw body pane should be shown
* @param showFileUploadPane flag whether the file upload pane should be shown
*/
public UrlConfigGui(boolean showSamplerFields, boolean showImplementation, boolean showRawBodyPane, boolean showFileUploadPane) {
public UrlConfigGui(boolean showSamplerFields, boolean showRawBodyPane, boolean showFileUploadPane) {
this.notConfigOnly = showSamplerFields;
this.showImplementation = showImplementation;
this.showRawBodyPane = showRawBodyPane;
this.showFileUploadPane = showFileUploadPane;
init();
@ -191,17 +165,8 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
useMultipartForPost.setSelected(false);
useBrowserCompatibleMultipartMode.setSelected(HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT);
}
if (showImplementation) {
httpImplementation.setText(""); // $NON-NLS-1$
}
path.setText(""); // $NON-NLS-1$
port.setText(""); // $NON-NLS-1$
proxyHost.setText(""); // $NON-NLS-1$
proxyPort.setText(""); // $NON-NLS-1$
proxyUser.setText(""); // $NON-NLS-1$
proxyPass.setText(""); // $NON-NLS-1$
connectTimeOut.setText(""); // $NON-NLS-1$
responseTimeOut.setText(""); // $NON-NLS-1$
protocol.setText(""); // $NON-NLS-1$
contentEncoding.setText(""); // $NON-NLS-1$
argsPanel.clear();
@ -256,12 +221,6 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
element.setProperty(new TestElementProperty(HTTPSamplerBase.ARGUMENTS, args));
element.setProperty(HTTPSamplerBase.DOMAIN, domain.getText());
element.setProperty(HTTPSamplerBase.PORT, port.getText());
element.setProperty(HTTPSamplerBase.PROXYHOST, proxyHost.getText(),"");
element.setProperty(HTTPSamplerBase.PROXYPORT, proxyPort.getText(),"");
element.setProperty(HTTPSamplerBase.PROXYUSER, proxyUser.getText(),"");
element.setProperty(HTTPSamplerBase.PROXYPASS, String.valueOf(proxyPass.getPassword()),"");
element.setProperty(HTTPSamplerBase.CONNECT_TIMEOUT, connectTimeOut.getText());
element.setProperty(HTTPSamplerBase.RESPONSE_TIMEOUT, responseTimeOut.getText());
element.setProperty(HTTPSamplerBase.PROTOCOL, protocol.getText());
element.setProperty(HTTPSamplerBase.CONTENT_ENCODING, contentEncoding.getText());
element.setProperty(HTTPSamplerBase.PATH, path.getText());
@ -273,9 +232,6 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
element.setProperty(new BooleanProperty(HTTPSamplerBase.DO_MULTIPART_POST, useMultipartForPost.isSelected()));
element.setProperty(HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART, useBrowserCompatibleMultipartMode.isSelected(),HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT);
}
if (showImplementation) {
element.setProperty(HTTPSamplerBase.IMPLEMENTATION, httpImplementation.getText(),"");
}
}
// FIXME FACTOR WITH HTTPHC4Impl, HTTPHC3Impl
@ -342,12 +298,6 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
} else {
port.setText(portString);
}
proxyHost.setText(el.getPropertyAsString(HTTPSamplerBase.PROXYHOST));
proxyPort.setText(el.getPropertyAsString(HTTPSamplerBase.PROXYPORT));
proxyUser.setText(el.getPropertyAsString(HTTPSamplerBase.PROXYUSER));
proxyPass.setText(el.getPropertyAsString(HTTPSamplerBase.PROXYPASS));
connectTimeOut.setText(el.getPropertyAsString(HTTPSamplerBase.CONNECT_TIMEOUT));
responseTimeOut.setText(el.getPropertyAsString(HTTPSamplerBase.RESPONSE_TIMEOUT));
protocol.setText(el.getPropertyAsString(HTTPSamplerBase.PROTOCOL));
contentEncoding.setText(el.getPropertyAsString(HTTPSamplerBase.CONTENT_ENCODING));
path.setText(el.getPropertyAsString(HTTPSamplerBase.PATH));
@ -360,9 +310,6 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
useBrowserCompatibleMultipartMode.setSelected(el.getPropertyAsBoolean(
HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART, HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT));
}
if (showImplementation) {
httpImplementation.setText(el.getPropertyAsString(HTTPSamplerBase.IMPLEMENTATION));
}
}
private void init() {// called from ctor, so must not be overridable
@ -374,190 +321,52 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
webRequestPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("web_request"))); // $NON-NLS-1$
JPanel northPanel = new JPanel();
northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS));
northPanel.add(getProtocolAndMethodPanel());
northPanel.add(getPathPanel());
webRequestPanel.add(northPanel, BorderLayout.NORTH);
webRequestPanel.add(getPathPanel(), BorderLayout.NORTH);
webRequestPanel.add(getParameterPanel(), BorderLayout.CENTER);
this.add(getWebServerTimeoutPanel(), BorderLayout.NORTH);
this.add(getWebServerPanel(), BorderLayout.NORTH);
this.add(webRequestPanel, BorderLayout.CENTER);
this.add(getProxyServerPanel(), BorderLayout.SOUTH);
}
/**
* Create a panel containing the webserver (domain+port) and timeouts (connect+request).
* Create a panel containing the webserver (domain+port) and scheme.
*
* @return the panel
*/
protected final JPanel getWebServerTimeoutPanel() {
// WEB SERVER PANEL
protected final JPanel getWebServerPanel() {
// PROTOCOL
protocol = new JLabeledTextField(JMeterUtils.getResString("protocol"), 4); // $NON-NLS-1$
port = new JLabeledTextField(JMeterUtils.getResString("web_server_port"), 7); // $NON-NLS-1$
domain = new JLabeledTextField(JMeterUtils.getResString("web_server_domain"), 40); // $NON-NLS-1$
JPanel webServerPanel = new HorizontalPanel();
webServerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("web_server"))); // $NON-NLS-1$
final JPanel domainPanel = getDomainPanel();
final JPanel portPanel = getPortPanel();
webServerPanel.add(domainPanel, BorderLayout.CENTER);
webServerPanel.add(portPanel, BorderLayout.EAST);
JPanel timeOut = new HorizontalPanel();
timeOut.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("web_server_timeout_title"))); // $NON-NLS-1$
final JPanel connPanel = getConnectTimeOutPanel();
final JPanel reqPanel = getResponseTimeOutPanel();
timeOut.add(connPanel);
timeOut.add(reqPanel);
JPanel webServerTimeoutPanel = new VerticalPanel();
webServerTimeoutPanel.add(webServerPanel, BorderLayout.CENTER);
webServerTimeoutPanel.add(timeOut, BorderLayout.EAST);
JPanel bigPanel = new VerticalPanel();
bigPanel.add(webServerTimeoutPanel);
return bigPanel;
webServerPanel.add(protocol);
webServerPanel.add(domain);
webServerPanel.add(port);
return webServerPanel;
}
/**
* Create a panel containing the proxy server details
*
* @return the panel
*/
protected final JPanel getProxyServerPanel(){
JPanel proxyServer = new HorizontalPanel();
proxyServer.add(getProxyHostPanel(), BorderLayout.CENTER);
proxyServer.add(getProxyPortPanel(), BorderLayout.EAST);
JPanel proxyLogin = new HorizontalPanel();
proxyLogin.add(getProxyUserPanel());
proxyLogin.add(getProxyPassPanel());
JPanel proxyServerPanel = new HorizontalPanel();
proxyServerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("web_proxy_server_title"))); // $NON-NLS-1$
proxyServerPanel.add(proxyServer);
proxyServerPanel.add(proxyLogin);
return proxyServerPanel;
}
private JPanel getPortPanel() {
port = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_port")); // $NON-NLS-1$
label.setLabelFor(port);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(port, BorderLayout.CENTER);
return panel;
}
private JPanel getProxyPortPanel() {
proxyPort = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_port")); // $NON-NLS-1$
label.setLabelFor(proxyPort);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyPort, BorderLayout.CENTER);
return panel;
}
private JPanel getConnectTimeOutPanel() {
connectTimeOut = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_timeout_connect")); // $NON-NLS-1$
label.setLabelFor(connectTimeOut);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(connectTimeOut, BorderLayout.CENTER);
return panel;
}
private JPanel getResponseTimeOutPanel() {
responseTimeOut = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_timeout_response")); // $NON-NLS-1$
label.setLabelFor(responseTimeOut);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(responseTimeOut, BorderLayout.CENTER);
return panel;
}
private JPanel getDomainPanel() {
domain = new JTextField(20);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_domain")); // $NON-NLS-1$
label.setLabelFor(domain);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(domain, BorderLayout.CENTER);
return panel;
}
private JPanel getProxyHostPanel() {
proxyHost = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_domain")); // $NON-NLS-1$
label.setLabelFor(proxyHost);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyHost, BorderLayout.CENTER);
return panel;
}
private JPanel getProxyUserPanel() {
proxyUser = new JTextField(5);
JLabel label = new JLabel(JMeterUtils.getResString("username")); // $NON-NLS-1$
label.setLabelFor(proxyUser);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyUser, BorderLayout.CENTER);
return panel;
}
private JPanel getProxyPassPanel() {
proxyPass = new JPasswordField(5);
JLabel label = new JLabel(JMeterUtils.getResString("password")); // $NON-NLS-1$
label.setLabelFor(proxyPass);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyPass, BorderLayout.CENTER);
return panel;
}
/**
* This method defines the Panel for the HTTP path, 'Follow Redirects'
* 'Use KeepAlive', and 'Use multipart for HTTP POST' elements.
* This method defines the Panel for:
* the HTTP path, Method and Content Encoding
* 'Follow Redirects', 'Use KeepAlive', and 'Use multipart for HTTP POST' elements.
*
* @return JPanel The Panel for the path, 'Follow Redirects' and 'Use
* KeepAlive' elements.
*/
protected Component getPathPanel() {
path = new JTextField(15);
path = new JLabeledTextField(JMeterUtils.getResString("path"), 80); //$NON-NLS-1$
// CONTENT_ENCODING
contentEncoding = new JLabeledTextField(JMeterUtils.getResString("content_encoding"), 7); // $NON-NLS-1$
JLabel label = new JLabel(JMeterUtils.getResString("path")); //$NON-NLS-1$
label.setLabelFor(path);
if (notConfigOnly){
method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
HTTPSamplerBase.getValidMethodsAsArray(), true, false);
method.addChangeListener(this);
}
if (notConfigOnly){
followRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects")); // $NON-NLS-1$
@ -584,10 +393,12 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
}
JPanel pathPanel = new HorizontalPanel();
pathPanel.add(label);
JPanel pathPanel = new HorizontalPanel();
if (notConfigOnly){
pathPanel.add(method);
}
pathPanel.add(path);
pathPanel.add(contentEncoding);
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(pathPanel);
@ -606,52 +417,6 @@ public class UrlConfigGui extends JPanel implements ChangeListener {
return panel;
}
protected JPanel getProtocolAndMethodPanel() {
// Implementation
if (showImplementation) {
httpImplementation = new JLabeledChoice(JMeterUtils.getResString("http_implementation"), // $NON-NLS-1$
HTTPSamplerFactory.getImplementations());
httpImplementation.addValue("");
}
// PROTOCOL
protocol = new JTextField(4);
JLabel protocolLabel = new JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$
protocolLabel.setLabelFor(protocol);
// CONTENT_ENCODING
contentEncoding = new JTextField(10);
JLabel contentEncodingLabel = new JLabel(JMeterUtils.getResString("content_encoding")); // $NON-NLS-1$
contentEncodingLabel.setLabelFor(contentEncoding);
if (notConfigOnly){
method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
HTTPSamplerBase.getValidMethodsAsArray(), true, false);
method.addChangeListener(this);
}
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
if (showImplementation) {
panel.add(httpImplementation);
}
panel.add(protocolLabel);
panel.add(protocol);
panel.add(Box.createHorizontalStrut(5));
if (notConfigOnly){
panel.add(method);
}
panel.setMinimumSize(panel.getPreferredSize());
panel.add(Box.createHorizontalStrut(5));
panel.add(contentEncodingLabel);
panel.add(contentEncoding);
panel.setMinimumSize(panel.getPreferredSize());
return panel;
}
protected JTabbedPane getParameterPanel() {
postContentTabbedPane = new ValidationTabbedPane();
argsPanel = new HTTPArgumentsPanel();

View File

@ -20,24 +20,30 @@ package org.apache.jmeter.protocol.http.control.gui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.UIManager;
import org.apache.jmeter.gui.util.HorizontalPanel;
import org.apache.jmeter.gui.util.VerticalPanel;
import org.apache.jmeter.protocol.http.config.gui.UrlConfigGui;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerFactory;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.JLabeledChoice;
import org.apache.jorphan.gui.JLabeledTextField;
//For unit tests, @see TestHttpTestSampleGui
@ -50,6 +56,10 @@ public class HttpTestSampleGui extends AbstractSamplerGui {
private static final long serialVersionUID = 241L;
private static final Font FONT_DEFAULT = UIManager.getDefaults().getFont("TextField.font");
private static final Font FONT_SMALL = new Font("SansSerif", Font.PLAIN, (int) Math.round(FONT_DEFAULT.getSize() * 0.8));
private UrlConfigGui urlConfigGui;
private JCheckBox retrieveEmbeddedResources;
@ -68,6 +78,20 @@ public class HttpTestSampleGui extends AbstractSamplerGui {
private final boolean isAJP;
private JTextField proxyHost;
private JTextField proxyPort;
private JTextField proxyUser;
private JPasswordField proxyPass;
private JLabeledChoice httpImplementation;
private JTextField connectTimeOut;
private JTextField responseTimeOut;
public HttpTestSampleGui() {
isAJP = false;
init();
@ -95,6 +119,13 @@ public class HttpTestSampleGui extends AbstractSamplerGui {
if (!isAJP) {
sourceIpAddr.setText(samplerBase.getIpSource());
sourceIpType.setSelectedIndex(samplerBase.getIpSourceType());
proxyHost.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYHOST));
proxyPort.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYPORT));
proxyUser.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYUSER));
proxyPass.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYPASS));
httpImplementation.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.IMPLEMENTATION));
connectTimeOut.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.CONNECT_TIMEOUT));
responseTimeOut.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.RESPONSE_TIMEOUT));
}
}
@ -127,6 +158,13 @@ public class HttpTestSampleGui extends AbstractSamplerGui {
if (!isAJP) {
samplerBase.setIpSource(sourceIpAddr.getText());
samplerBase.setIpSourceType(sourceIpType.getSelectedIndex());
samplerBase.setProperty(HTTPSamplerBase.PROXYHOST, proxyHost.getText(),"");
samplerBase.setProperty(HTTPSamplerBase.PROXYPORT, proxyPort.getText(),"");
samplerBase.setProperty(HTTPSamplerBase.PROXYUSER, proxyUser.getText(),"");
samplerBase.setProperty(HTTPSamplerBase.PROXYPASS, String.valueOf(proxyPass.getPassword()),"");
samplerBase.setProperty(HTTPSamplerBase.IMPLEMENTATION, httpImplementation.getText(),"");
samplerBase.setProperty(HTTPSamplerBase.CONNECT_TIMEOUT, connectTimeOut.getText());
samplerBase.setProperty(HTTPSamplerBase.RESPONSE_TIMEOUT, responseTimeOut.getText());
}
super.configureTestElement(sampler);
}
@ -144,12 +182,18 @@ public class HttpTestSampleGui extends AbstractSamplerGui {
setBorder(makeBorder());
// URL CONFIG
urlConfigGui = new UrlConfigGui(true, !isAJP, true, true);
urlConfigGui = new UrlConfigGui(true, true, true);
// AdvancedPanel (embedded resources, source address and optional tasks)
JPanel advancedPanel = new VerticalPanel();
advancedPanel.add(createEmbeddedRsrcPanel());
advancedPanel.add(createSourceAddrPanel());
if (!isAJP) {
advancedPanel.add(getTimeOutPanel());
advancedPanel.add(getImplementationPanel());
advancedPanel.add(createSourceAddrPanel());
advancedPanel.add(getProxyServerPanel());
}
advancedPanel.add(createOptionalTasksPanel());
JTabbedPane tabbedPane = new JTabbedPane();
@ -166,6 +210,43 @@ public class HttpTestSampleGui extends AbstractSamplerGui {
add(emptyPanel, BorderLayout.SOUTH);
}
private JPanel getTimeOutPanel() {
JPanel timeOut = new HorizontalPanel();
timeOut.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("web_server_timeout_title"))); // $NON-NLS-1$
final JPanel connPanel = getConnectTimeOutPanel();
final JPanel reqPanel = getResponseTimeOutPanel();
timeOut.add(connPanel);
timeOut.add(reqPanel);
return timeOut;
}
private JPanel getConnectTimeOutPanel() {
connectTimeOut = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_timeout_connect")); // $NON-NLS-1$
label.setLabelFor(connectTimeOut);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(connectTimeOut, BorderLayout.CENTER);
return panel;
}
private JPanel getResponseTimeOutPanel() {
responseTimeOut = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_timeout_response")); // $NON-NLS-1$
label.setLabelFor(responseTimeOut);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(responseTimeOut, BorderLayout.CENTER);
return panel;
}
protected JPanel createEmbeddedRsrcPanel() {
// retrieve Embedded resources
retrieveEmbeddedResources = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$
@ -204,6 +285,20 @@ public class HttpTestSampleGui extends AbstractSamplerGui {
return embeddedRsrcPanel;
}
/**
* Create a panel containing the implementation details
*
* @return the panel
*/
protected final JPanel getImplementationPanel(){
JPanel implPanel = new HorizontalPanel();
httpImplementation = new JLabeledChoice(JMeterUtils.getResString("http_implementation"), // $NON-NLS-1$
HTTPSamplerFactory.getImplementations());
httpImplementation.addValue("");
implPanel.add(httpImplementation);
return implPanel;
}
protected JPanel createOptionalTasksPanel() {
// OPTIONAL TASKS
final JPanel checkBoxPanel = new VerticalPanel();
@ -222,14 +317,12 @@ public class HttpTestSampleGui extends AbstractSamplerGui {
sourceAddrPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils
.getResString("web_testing_source_ip"))); // $NON-NLS-1$
if (!isAJP) {
// Add a new field source ip address (for HC implementations only)
sourceIpType.setSelectedIndex(HTTPSamplerBase.SourceType.HOSTNAME.ordinal()); //default: IP/Hostname
sourceAddrPanel.add(sourceIpType);
// Add a new field source ip address (for HC implementations only)
sourceIpType.setSelectedIndex(HTTPSamplerBase.SourceType.HOSTNAME.ordinal()); //default: IP/Hostname
sourceAddrPanel.add(sourceIpType);
sourceIpAddr = new JTextField();
sourceAddrPanel.add(sourceIpAddr);
}
sourceIpAddr = new JTextField();
sourceAddrPanel.add(sourceIpAddr);
return sourceAddrPanel;
}
@ -257,6 +350,13 @@ public class HttpTestSampleGui extends AbstractSamplerGui {
if (!isAJP) {
sourceIpAddr.setText(""); // $NON-NLS-1$
sourceIpType.setSelectedIndex(HTTPSamplerBase.SourceType.HOSTNAME.ordinal()); //default: IP/Hostname
proxyHost.setText(""); // $NON-NLS-1$
proxyPort.setText(""); // $NON-NLS-1$
proxyUser.setText(""); // $NON-NLS-1$
proxyPass.setText(""); // $NON-NLS-1$
httpImplementation.setText(""); // $NON-NLS-1$
connectTimeOut.setText(""); // $NON-NLS-1$
responseTimeOut.setText(""); // $NON-NLS-1$
}
}
@ -273,4 +373,81 @@ public class HttpTestSampleGui extends AbstractSamplerGui {
embeddedRE.setEnabled(false);
}
}
/**
* Create a panel containing the proxy server details
*
* @return the panel
*/
protected final JPanel getProxyServerPanel(){
JPanel proxyServer = new HorizontalPanel();
proxyServer.add(getProxyHostPanel(), BorderLayout.CENTER);
proxyServer.add(getProxyPortPanel(), BorderLayout.EAST);
JPanel proxyLogin = new HorizontalPanel();
proxyLogin.add(getProxyUserPanel());
proxyLogin.add(getProxyPassPanel());
JPanel proxyServerPanel = new HorizontalPanel();
proxyServerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("web_proxy_server_title"))); // $NON-NLS-1$
proxyServerPanel.add(proxyServer);
proxyServerPanel.add(proxyLogin);
return proxyServerPanel;
}
private JPanel getProxyHostPanel() {
proxyHost = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_domain")); // $NON-NLS-1$
label.setLabelFor(proxyHost);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyHost, BorderLayout.CENTER);
return panel;
}
private JPanel getProxyPortPanel() {
proxyPort = new JTextField(10);
JLabel label = new JLabel(JMeterUtils.getResString("web_server_port")); // $NON-NLS-1$
label.setLabelFor(proxyPort);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyPort, BorderLayout.CENTER);
return panel;
}
private JPanel getProxyUserPanel() {
proxyUser = new JTextField(5);
JLabel label = new JLabel(JMeterUtils.getResString("username")); // $NON-NLS-1$
label.setLabelFor(proxyUser);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyUser, BorderLayout.CENTER);
return panel;
}
private JPanel getProxyPassPanel() {
proxyPass = new JPasswordField(5);
JLabel label = new JLabel(JMeterUtils.getResString("password")); // $NON-NLS-1$
label.setLabelFor(proxyPass);
label.setFont(FONT_SMALL);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyPass, BorderLayout.CENTER);
return panel;
}
}

View File

@ -108,6 +108,7 @@ Fill in some detail.
<h3>HTTP Samplers and Test Script Recorder</h3>
<ul>
<li><bug>59934</bug>Fix race-conditions in CssParser. Based on a patch by Jerome Loisel (loisel.jerome at gmail.com)</li>
<li><bug>60543</bug>HTTP Request / Http Request Defaults UX: Move to advanced panel Timeouts, Implementation, Proxy</li>
</ul>
<h3>Other samplers</h3>