Add classname field to TCP Sampler GUIs
git-svn-id: https://svn.apache.org/repos/asf/jakarta/jmeter/trunk@707243 13f79535-47bb-0310-9956-ffa450edef68
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.6 KiB |
|
|
@ -778,6 +778,7 @@ table_visualizer_status=Status
|
||||||
table_visualizer_success=Success
|
table_visualizer_success=Success
|
||||||
table_visualizer_thread_name=Thread Name
|
table_visualizer_thread_name=Thread Name
|
||||||
table_visualizer_warning=Warning
|
table_visualizer_warning=Warning
|
||||||
|
tcp_classname=TCPClient classname\:
|
||||||
tcp_config_title=TCP Sampler Config
|
tcp_config_title=TCP Sampler Config
|
||||||
tcp_nodelay=Set NoDelay
|
tcp_nodelay=Set NoDelay
|
||||||
tcp_port=Port Number\:
|
tcp_port=Port Number\:
|
||||||
|
|
|
||||||
|
|
@ -32,21 +32,11 @@ import org.apache.jmeter.gui.util.VerticalPanel;
|
||||||
import org.apache.jmeter.protocol.tcp.sampler.TCPSampler;
|
import org.apache.jmeter.protocol.tcp.sampler.TCPSampler;
|
||||||
import org.apache.jmeter.testelement.TestElement;
|
import org.apache.jmeter.testelement.TestElement;
|
||||||
import org.apache.jmeter.util.JMeterUtils;
|
import org.apache.jmeter.util.JMeterUtils;
|
||||||
|
import org.apache.jorphan.gui.JLabeledTextField;
|
||||||
|
|
||||||
public class TCPConfigGui extends AbstractConfigGui {
|
public class TCPConfigGui extends AbstractConfigGui {
|
||||||
private final static String SERVER = "server"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private final static String RE_USE_CONNECTION = "reUseConnection"; //$NON-NLS-1$
|
private JLabeledTextField classname;
|
||||||
|
|
||||||
private final static String PORT = "port"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
// NOTUSED yet private final static String FILENAME = "filename";
|
|
||||||
// //$NON-NLS-1$
|
|
||||||
private final static String TIMEOUT = "timeout"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private final static String NODELAY = "nodelay"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private final static String REQUEST = "request"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private JTextField server;
|
private JTextField server;
|
||||||
|
|
||||||
|
|
@ -78,6 +68,8 @@ public class TCPConfigGui extends AbstractConfigGui {
|
||||||
|
|
||||||
public void configure(TestElement element) {
|
public void configure(TestElement element) {
|
||||||
super.configure(element);
|
super.configure(element);
|
||||||
|
// N.B. this will be a config element, so we cannot use the getXXX() methods
|
||||||
|
classname.setText(element.getPropertyAsString(TCPSampler.CLASSNAME));
|
||||||
server.setText(element.getPropertyAsString(TCPSampler.SERVER));
|
server.setText(element.getPropertyAsString(TCPSampler.SERVER));
|
||||||
// Default to original behaviour, i.e. re-use connection
|
// Default to original behaviour, i.e. re-use connection
|
||||||
reUseConnection.setSelected(element.getPropertyAsBoolean(TCPSampler.RE_USE_CONNECTION,true));
|
reUseConnection.setSelected(element.getPropertyAsBoolean(TCPSampler.RE_USE_CONNECTION,true));
|
||||||
|
|
@ -101,6 +93,8 @@ public class TCPConfigGui extends AbstractConfigGui {
|
||||||
*/
|
*/
|
||||||
public void modifyTestElement(TestElement element) {
|
public void modifyTestElement(TestElement element) {
|
||||||
configureTestElement(element);
|
configureTestElement(element);
|
||||||
|
// N.B. this will be a config element, so we cannot use the setXXX() methods
|
||||||
|
element.setProperty(TCPSampler.CLASSNAME, classname.getText(), "");
|
||||||
element.setProperty(TCPSampler.SERVER, server.getText());
|
element.setProperty(TCPSampler.SERVER, server.getText());
|
||||||
element.setProperty(TCPSampler.RE_USE_CONNECTION, reUseConnection.isSelected());
|
element.setProperty(TCPSampler.RE_USE_CONNECTION, reUseConnection.isSelected());
|
||||||
element.setProperty(TCPSampler.PORT, port.getText());
|
element.setProperty(TCPSampler.PORT, port.getText());
|
||||||
|
|
@ -116,6 +110,7 @@ public class TCPConfigGui extends AbstractConfigGui {
|
||||||
public void clearGui() {
|
public void clearGui() {
|
||||||
super.clearGui();
|
super.clearGui();
|
||||||
|
|
||||||
|
classname.setText(""); //$NON-NLS-1$
|
||||||
server.setText(""); //$NON-NLS-1$
|
server.setText(""); //$NON-NLS-1$
|
||||||
port.setText(""); //$NON-NLS-1$
|
port.setText(""); //$NON-NLS-1$
|
||||||
timeout.setText(""); //$NON-NLS-1$
|
timeout.setText(""); //$NON-NLS-1$
|
||||||
|
|
@ -128,7 +123,6 @@ public class TCPConfigGui extends AbstractConfigGui {
|
||||||
JLabel label = new JLabel(JMeterUtils.getResString("tcp_timeout")); // $NON-NLS-1$
|
JLabel label = new JLabel(JMeterUtils.getResString("tcp_timeout")); // $NON-NLS-1$
|
||||||
|
|
||||||
timeout = new JTextField(10);
|
timeout = new JTextField(10);
|
||||||
timeout.setName(TIMEOUT);
|
|
||||||
label.setLabelFor(timeout);
|
label.setLabelFor(timeout);
|
||||||
|
|
||||||
JPanel timeoutPanel = new JPanel(new BorderLayout(5, 0));
|
JPanel timeoutPanel = new JPanel(new BorderLayout(5, 0));
|
||||||
|
|
@ -141,7 +135,6 @@ public class TCPConfigGui extends AbstractConfigGui {
|
||||||
JLabel label = new JLabel(JMeterUtils.getResString("tcp_nodelay")); // $NON-NLS-1$
|
JLabel label = new JLabel(JMeterUtils.getResString("tcp_nodelay")); // $NON-NLS-1$
|
||||||
|
|
||||||
setNoDelay = new JCheckBox();
|
setNoDelay = new JCheckBox();
|
||||||
setNoDelay.setName(NODELAY);
|
|
||||||
label.setLabelFor(setNoDelay);
|
label.setLabelFor(setNoDelay);
|
||||||
|
|
||||||
JPanel nodelayPanel = new JPanel(new BorderLayout(5, 0));
|
JPanel nodelayPanel = new JPanel(new BorderLayout(5, 0));
|
||||||
|
|
@ -154,7 +147,6 @@ public class TCPConfigGui extends AbstractConfigGui {
|
||||||
JLabel label = new JLabel(JMeterUtils.getResString("server")); // $NON-NLS-1$
|
JLabel label = new JLabel(JMeterUtils.getResString("server")); // $NON-NLS-1$
|
||||||
|
|
||||||
server = new JTextField(10);
|
server = new JTextField(10);
|
||||||
server.setName(SERVER);
|
|
||||||
label.setLabelFor(server);
|
label.setLabelFor(server);
|
||||||
|
|
||||||
JPanel serverPanel = new JPanel(new BorderLayout(5, 0));
|
JPanel serverPanel = new JPanel(new BorderLayout(5, 0));
|
||||||
|
|
@ -167,7 +159,6 @@ public class TCPConfigGui extends AbstractConfigGui {
|
||||||
JLabel label = new JLabel(JMeterUtils.getResString("reuseconnection")); //$NON-NLS-1$
|
JLabel label = new JLabel(JMeterUtils.getResString("reuseconnection")); //$NON-NLS-1$
|
||||||
|
|
||||||
reUseConnection = new JCheckBox("", true);
|
reUseConnection = new JCheckBox("", true);
|
||||||
reUseConnection.setName(RE_USE_CONNECTION);
|
|
||||||
label.setLabelFor(reUseConnection);
|
label.setLabelFor(reUseConnection);
|
||||||
|
|
||||||
JPanel closePortPanel = new JPanel(new BorderLayout(5, 0));
|
JPanel closePortPanel = new JPanel(new BorderLayout(5, 0));
|
||||||
|
|
@ -180,7 +171,6 @@ public class TCPConfigGui extends AbstractConfigGui {
|
||||||
JLabel label = new JLabel(JMeterUtils.getResString("tcp_port")); //$NON-NLS-1$
|
JLabel label = new JLabel(JMeterUtils.getResString("tcp_port")); //$NON-NLS-1$
|
||||||
|
|
||||||
port = new JTextField(10);
|
port = new JTextField(10);
|
||||||
port.setName(PORT);
|
|
||||||
label.setLabelFor(port);
|
label.setLabelFor(port);
|
||||||
|
|
||||||
JPanel PortPanel = new JPanel(new BorderLayout(5, 0));
|
JPanel PortPanel = new JPanel(new BorderLayout(5, 0));
|
||||||
|
|
@ -193,7 +183,6 @@ public class TCPConfigGui extends AbstractConfigGui {
|
||||||
JLabel reqLabel = new JLabel(JMeterUtils.getResString("tcp_request_data")); // $NON-NLS-1$
|
JLabel reqLabel = new JLabel(JMeterUtils.getResString("tcp_request_data")); // $NON-NLS-1$
|
||||||
requestData = new JTextArea(3, 0);
|
requestData = new JTextArea(3, 0);
|
||||||
requestData.setLineWrap(true);
|
requestData.setLineWrap(true);
|
||||||
requestData.setName(REQUEST);
|
|
||||||
reqLabel.setLabelFor(requestData);
|
reqLabel.setLabelFor(requestData);
|
||||||
|
|
||||||
JPanel reqDataPanel = new JPanel(new BorderLayout(5, 0));
|
JPanel reqDataPanel = new JPanel(new BorderLayout(5, 0));
|
||||||
|
|
@ -227,9 +216,12 @@ public class TCPConfigGui extends AbstractConfigGui {
|
||||||
}
|
}
|
||||||
|
|
||||||
VerticalPanel mainPanel = new VerticalPanel();
|
VerticalPanel mainPanel = new VerticalPanel();
|
||||||
mainPanel.add(createServerPanel());
|
classname = new JLabeledTextField(JMeterUtils.getResString("tcp_classname"));
|
||||||
|
mainPanel.add(classname);
|
||||||
|
final JPanel serverPanel = createServerPanel();
|
||||||
|
serverPanel.add(createPortPanel(), BorderLayout.EAST);
|
||||||
|
mainPanel.add(serverPanel);
|
||||||
mainPanel.add(createClosePortPanel());
|
mainPanel.add(createClosePortPanel());
|
||||||
mainPanel.add(createPortPanel());
|
|
||||||
mainPanel.add(createTimeoutPanel());
|
mainPanel.add(createTimeoutPanel());
|
||||||
mainPanel.add(createNoDelayPanel());
|
mainPanel.add(createNoDelayPanel());
|
||||||
mainPanel.add(createRequestPanel());
|
mainPanel.add(createRequestPanel());
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
|
|
||||||
private static final Logger log = LoggingManager.getLoggerForClass();
|
private static final Logger log = LoggingManager.getLoggerForClass();
|
||||||
|
|
||||||
|
//++ JMX file constants - do not change
|
||||||
public static final String SERVER = "TCPSampler.server"; //$NON-NLS-1$
|
public static final String SERVER = "TCPSampler.server"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String PORT = "TCPSampler.port"; //$NON-NLS-1$
|
public static final String PORT = "TCPSampler.port"; //$NON-NLS-1$
|
||||||
|
|
@ -64,6 +65,7 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
public static final String REQUEST = "TCPSampler.request"; //$NON-NLS-1$
|
public static final String REQUEST = "TCPSampler.request"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String RE_USE_CONNECTION = "TCPSampler.reUseConnection"; //$NON-NLS-1$
|
public static final String RE_USE_CONNECTION = "TCPSampler.reUseConnection"; //$NON-NLS-1$
|
||||||
|
//-- JMX file constants - do not change
|
||||||
|
|
||||||
private static final String TCPKEY = "TCP"; //$NON-NLS-1$ key for HashMap
|
private static final String TCPKEY = "TCP"; //$NON-NLS-1$ key for HashMap
|
||||||
|
|
||||||
|
|
@ -75,11 +77,11 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
// JMeterUtils.getPropDefault("tcp.status.regex","");
|
// JMeterUtils.getPropDefault("tcp.status.regex","");
|
||||||
|
|
||||||
// Otherwise, the response is scanned for these strings
|
// Otherwise, the response is scanned for these strings
|
||||||
private static final String STATUS_PREFIX = JMeterUtils.getPropDefault("tcp.status.prefix", "");
|
private static final String STATUS_PREFIX = JMeterUtils.getPropDefault("tcp.status.prefix", ""); //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String STATUS_SUFFIX = JMeterUtils.getPropDefault("tcp.status.suffix", "");
|
private static final String STATUS_SUFFIX = JMeterUtils.getPropDefault("tcp.status.suffix", ""); //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String STATUS_PROPERTIES = JMeterUtils.getPropDefault("tcp.status.properties", "");
|
private static final String STATUS_PROPERTIES = JMeterUtils.getPropDefault("tcp.status.properties", ""); //$NON-NLS-1$
|
||||||
|
|
||||||
private static final Properties statusProps = new Properties();
|
private static final Properties statusProps = new Properties();
|
||||||
|
|
||||||
|
|
@ -87,22 +89,21 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
boolean hsp = false;
|
boolean hsp = false;
|
||||||
log.debug("Protocol Handler name=" + getClassname());
|
log.debug("Status prefix=" + STATUS_PREFIX); //$NON-NLS-1$
|
||||||
log.debug("Status prefix=" + STATUS_PREFIX);
|
log.debug("Status suffix=" + STATUS_SUFFIX); //$NON-NLS-1$
|
||||||
log.debug("Status suffix=" + STATUS_SUFFIX);
|
log.debug("Status properties=" + STATUS_PROPERTIES); //$NON-NLS-1$
|
||||||
log.debug("Status properties=" + STATUS_PROPERTIES);
|
|
||||||
if (STATUS_PROPERTIES.length() > 0) {
|
if (STATUS_PROPERTIES.length() > 0) {
|
||||||
File f = new File(STATUS_PROPERTIES);
|
File f = new File(STATUS_PROPERTIES);
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
try {
|
try {
|
||||||
fis = new FileInputStream(f);
|
fis = new FileInputStream(f);
|
||||||
statusProps.load(fis);
|
statusProps.load(fis);
|
||||||
log.debug("Successfully loaded properties");
|
log.debug("Successfully loaded properties"); //$NON-NLS-1$
|
||||||
hsp = true;
|
hsp = true;
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
log.debug("Property file not found");
|
log.debug("Property file not found"); //$NON-NLS-1$
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.debug("Property file error " + e.toString());
|
log.debug("Property file error " + e.toString()); //$NON-NLS-1$
|
||||||
} finally {
|
} finally {
|
||||||
JOrphanUtils.closeQuietly(fis);
|
JOrphanUtils.closeQuietly(fis);
|
||||||
}
|
}
|
||||||
|
|
@ -120,9 +121,7 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
private transient TCPClient protocolHandler;
|
private transient TCPClient protocolHandler;
|
||||||
|
|
||||||
public TCPSampler() {
|
public TCPSampler() {
|
||||||
log.debug("Created " + this);
|
log.debug("Created " + this); //$NON-NLS-1$
|
||||||
protocolHandler = getProtocol();
|
|
||||||
log.debug("Using Protocol Handler: " + protocolHandler.getClass().getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getError() {
|
private String getError() {
|
||||||
|
|
@ -177,8 +176,8 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
return getPropertyAsString(SERVER);
|
return getPropertyAsString(SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReUseConnection(String newServer) {
|
public void setReUseConnection(String reuse) {
|
||||||
this.setProperty(RE_USE_CONNECTION, newServer);
|
this.setProperty(RE_USE_CONNECTION, reuse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReUseConnection() {
|
public boolean isReUseConnection() {
|
||||||
|
|
@ -225,6 +224,18 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
return getPropertyAsBoolean(NODELAY);
|
return getPropertyAsBoolean(NODELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setClassname(String classname) {
|
||||||
|
this.setProperty(CLASSNAME, classname, ""); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClassname() {
|
||||||
|
String clazz = getPropertyAsString(CLASSNAME,"");
|
||||||
|
if (clazz==null || clazz.length()==0){
|
||||||
|
clazz = JMeterUtils.getPropDefault("tcp.handler", "TCPClientImpl"); //$NON-NLS-1$ $NON-NLS-2$
|
||||||
|
}
|
||||||
|
return clazz;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a formatted string label describing this sampler Example output:
|
* Returns a formatted string label describing this sampler Example output:
|
||||||
* Tcp://Tcp.nowhere.com/pub/README.txt
|
* Tcp://Tcp.nowhere.com/pub/README.txt
|
||||||
|
|
@ -232,15 +243,10 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
* @return a formatted string label describing this sampler
|
* @return a formatted string label describing this sampler
|
||||||
*/
|
*/
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return ("tcp://" + this.getServer() + ":" + this.getPort());//$NON-NLS-1$
|
return ("tcp://" + this.getServer() + ":" + this.getPort());//$NON-NLS-1$ $NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getClassname() {
|
private static final String protoPrefix = "org.apache.jmeter.protocol.tcp.sampler."; //$NON-NLS-1$
|
||||||
String className = JMeterUtils.getPropDefault("tcp.handler", "TCPClientImpl");
|
|
||||||
return className;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String protoPrefix = "org.apache.jmeter.protocol.tcp.sampler.";
|
|
||||||
|
|
||||||
private Class getClass(String className) {
|
private Class getClass(String className) {
|
||||||
Class c = null;
|
Class c = null;
|
||||||
|
|
@ -250,7 +256,7 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
try {
|
try {
|
||||||
c = Class.forName(protoPrefix + className, false, Thread.currentThread().getContextClassLoader());
|
c = Class.forName(protoPrefix + className, false, Thread.currentThread().getContextClassLoader());
|
||||||
} catch (ClassNotFoundException e1) {
|
} catch (ClassNotFoundException e1) {
|
||||||
log.error("Could not find protocol class " + className);
|
log.error("Could not find protocol class '" + className+"'"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
|
|
@ -260,13 +266,16 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
private TCPClient getProtocol() {
|
private TCPClient getProtocol() {
|
||||||
TCPClient TCPClient = null;
|
TCPClient TCPClient = null;
|
||||||
Class javaClass = getClass(getClassname());
|
Class javaClass = getClass(getClassname());
|
||||||
|
if (javaClass == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
TCPClient = (TCPClient) javaClass.newInstance();
|
TCPClient = (TCPClient) javaClass.newInstance();
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug(this + "Created: " + getClassname() + "@" + Integer.toHexString(TCPClient.hashCode()));
|
log.debug(this + "Created: " + getClassname() + "@" + Integer.toHexString(TCPClient.hashCode())); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(this + " Exception creating: " + getClassname(), e);
|
log.error(this + " Exception creating: " + getClassname(), e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return TCPClient;
|
return TCPClient;
|
||||||
}
|
}
|
||||||
|
|
@ -276,15 +285,17 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
log.debug(getLabel() + " " + getFilename() + " " + getUsername() + " " + getPassword());
|
log.debug(getLabel() + " " + getFilename() + " " + getUsername() + " " + getPassword());
|
||||||
SampleResult res = new SampleResult();
|
SampleResult res = new SampleResult();
|
||||||
boolean isSuccessful = false;
|
boolean isSuccessful = false;
|
||||||
res.setSampleLabel(getName());// Use the test element name for the
|
res.setSampleLabel(getName());// Use the test element name for the label
|
||||||
// label
|
res.setSamplerData("Host: " + getServer() + " Port: " + getPort()); //$NON-NLS-1$ $NON-NLS-2$
|
||||||
res.setSamplerData("Host: " + getServer() + " Port: " + getPort());
|
|
||||||
res.sampleStart();
|
res.sampleStart();
|
||||||
try {
|
try {
|
||||||
Socket sock = getSocket();
|
Socket sock = getSocket();
|
||||||
if (sock == null) {
|
if (sock == null) {
|
||||||
res.setResponseCode("500");
|
res.setResponseCode("500"); //$NON-NLS-1$
|
||||||
res.setResponseMessage(getError());
|
res.setResponseMessage(getError());
|
||||||
|
} else if (protocolHandler == null){
|
||||||
|
res.setResponseCode("500"); //$NON-NLS-1$
|
||||||
|
res.setResponseMessage("Protocol handler not found");
|
||||||
} else {
|
} else {
|
||||||
InputStream is = sock.getInputStream();
|
InputStream is = sock.getInputStream();
|
||||||
OutputStream os = sock.getOutputStream();
|
OutputStream os = sock.getOutputStream();
|
||||||
|
|
@ -296,7 +307,7 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
res.setResponseData(in.getBytes());
|
res.setResponseData(in.getBytes());
|
||||||
res.setDataType(SampleResult.TEXT);
|
res.setDataType(SampleResult.TEXT);
|
||||||
res.setResponseCodeOK();
|
res.setResponseCodeOK();
|
||||||
res.setResponseMessage("OK");
|
res.setResponseMessage("OK"); //$NON-NLS-1$
|
||||||
isSuccessful = true;
|
isSuccessful = true;
|
||||||
// Reset the status code if the message contains one
|
// Reset the status code if the message contains one
|
||||||
if (STATUS_PREFIX.length() > 0) {
|
if (STATUS_PREFIX.length() > 0) {
|
||||||
|
|
@ -307,12 +318,12 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
res.setResponseCode(rc);
|
res.setResponseCode(rc);
|
||||||
isSuccessful = checkResponseCode(rc);
|
isSuccessful = checkResponseCode(rc);
|
||||||
if (haveStatusProps) {
|
if (haveStatusProps) {
|
||||||
res.setResponseMessage(statusProps.getProperty(rc, "Status code not found in properties"));
|
res.setResponseMessage(statusProps.getProperty(rc, "Status code not found in properties")); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
res.setResponseMessage("No status property file");
|
res.setResponseMessage("No status property file");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res.setResponseCode("999");
|
res.setResponseCode("999"); //$NON-NLS-1$
|
||||||
res.setResponseMessage("Status value not found");
|
res.setResponseMessage("Status value not found");
|
||||||
isSuccessful = false;
|
isSuccessful = false;
|
||||||
}
|
}
|
||||||
|
|
@ -320,7 +331,7 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
log.debug("", ex);
|
log.debug("", ex);
|
||||||
res.setResponseCode("500");
|
res.setResponseCode("500"); //$NON-NLS-1$
|
||||||
res.setResponseMessage(ex.toString());
|
res.setResponseMessage(ex.toString());
|
||||||
closeSocket();
|
closeSocket();
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -343,18 +354,21 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
* @return whether this represents success or not
|
* @return whether this represents success or not
|
||||||
*/
|
*/
|
||||||
private boolean checkResponseCode(String rc) {
|
private boolean checkResponseCode(String rc) {
|
||||||
if (rc.compareTo("400") >= 0 && rc.compareTo("499") <= 0) {
|
if (rc.compareTo("400") >= 0 && rc.compareTo("499") <= 0) { //$NON-NLS-1$ $NON-NLS-2$
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (rc.compareTo("500") >= 0 && rc.compareTo("599") <= 0) {
|
if (rc.compareTo("500") >= 0 && rc.compareTo("599") <= 0) { //$NON-NLS-1$ $NON-NLS-2$
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void threadStarted() {
|
public void threadStarted() {
|
||||||
log.debug("Thread Started");
|
log.debug("Thread Started"); //$NON-NLS-1$
|
||||||
}
|
protocolHandler = getProtocol();
|
||||||
|
log.debug("Using Protocol Handler: " + //$NON-NLS-1$
|
||||||
|
(protocolHandler == null ? "NONE" : protocolHandler.getClass().getName())); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
private void closeSocket() {
|
private void closeSocket() {
|
||||||
Map cp = (Map) tp.get();
|
Map cp = (Map) tp.get();
|
||||||
|
|
@ -364,13 +378,13 @@ public class TCPSampler extends AbstractSampler implements ThreadListener {
|
||||||
try {
|
try {
|
||||||
con.close();
|
con.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.warn("Error closing socket "+e);
|
log.warn("Error closing socket "+e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void threadFinished() {
|
public void threadFinished() {
|
||||||
log.debug("Thread Finished");
|
log.debug("Thread Finished"); //$NON-NLS-1$
|
||||||
closeSocket();
|
closeSocket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,7 @@ These are implemented in the AbstractTestElement class which all elements should
|
||||||
<li>Allow If Controller to use variable expressions (not just Javascript)</li>
|
<li>Allow If Controller to use variable expressions (not just Javascript)</li>
|
||||||
<li>Bug 45903 - allow Assertions to apply to sub-samples</li>
|
<li>Bug 45903 - allow Assertions to apply to sub-samples</li>
|
||||||
<li>Trim spaces from While Controller condition before comparing against LAST, blank or false</li>
|
<li>Trim spaces from While Controller condition before comparing against LAST, blank or false</li>
|
||||||
|
<li>Add classname field to TCP Sampler GUIs</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Non-functional changes</h3>
|
<h3>Non-functional changes</h3>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.6 KiB |
|
|
@ -965,8 +965,7 @@ Currently the only way to changes these is via the SampleResult methods:
|
||||||
</p>
|
</p>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
<component name="TCP Sampler" index="§-num;.1.12" width="596" height="347" screenshot="tcpsampler.png">
|
<component name="TCP Sampler" index="§-num;.1.12" width="477" height="343" screenshot="tcpsampler.png">
|
||||||
<note>ALPHA CODE</note>
|
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
The TCP Sampler opens a TCP/IP connection to the specified server.
|
The TCP Sampler opens a TCP/IP connection to the specified server.
|
||||||
|
|
@ -1018,9 +1017,10 @@ Currently the only way to changes these is via the SampleResult methods:
|
||||||
</description>
|
</description>
|
||||||
<properties>
|
<properties>
|
||||||
<property name="Name" required="">Descriptive name for this element that is shown in the tree.</property>
|
<property name="Name" required="">Descriptive name for this element that is shown in the tree.</property>
|
||||||
|
<property name="TCPClient classname" required="No">Name of the TCPClient class. Defaults to the property tcp.handler, failing that TCPClientImpl.</property>
|
||||||
<property name="ServerName or IP" required="Yes">Name or IP of TCP server</property>
|
<property name="ServerName or IP" required="Yes">Name or IP of TCP server</property>
|
||||||
<property name="Re-use connection" required="Yes">If selected, the connection is kept open. Otherwise it is closed when the data has been read.</property>
|
|
||||||
<property name="Port Number" required="Yes">Port to be used</property>
|
<property name="Port Number" required="Yes">Port to be used</property>
|
||||||
|
<property name="Re-use connection" required="Yes">If selected, the connection is kept open. Otherwise it is closed when the data has been read.</property>
|
||||||
<property name="Timeout (milliseconds)" required="No">Timeout for replies</property>
|
<property name="Timeout (milliseconds)" required="No">Timeout for replies</property>
|
||||||
<property name="Set Nodelay" required="No">Should the nodelay property be set?</property>
|
<property name="Set Nodelay" required="No">Should the nodelay property be set?</property>
|
||||||
<property name="Text to Send" required="Yes">Text to be sent</property>
|
<property name="Text to Send" required="Yes">Text to be sent</property>
|
||||||
|
|
@ -2714,8 +2714,7 @@ The Database URL and JDBC Driver class are defined by the provider of the JDBC i
|
||||||
|
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
<component name="TCP Sampler Config" index="§-num;.4.12" width="645" height="256" screenshot="tcpsamplerconfig.png">
|
<component name="TCP Sampler Config" index="§-num;.4.12" width="476" height="272" screenshot="tcpsamplerconfig.png">
|
||||||
<note>ALPHA CODE</note>
|
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
The TCP Sampler Config provides default data for the TCP Sampler
|
The TCP Sampler Config provides default data for the TCP Sampler
|
||||||
|
|
@ -2723,8 +2722,10 @@ The Database URL and JDBC Driver class are defined by the provider of the JDBC i
|
||||||
</description>
|
</description>
|
||||||
<properties>
|
<properties>
|
||||||
<property name="Name" required="">Descriptive name for this element that is shown in the tree.</property>
|
<property name="Name" required="">Descriptive name for this element that is shown in the tree.</property>
|
||||||
|
<property name="TCPClient classname" required="No">Name of the TCPClient class. Defaults to the property tcp.handler, failing that TCPClientImpl.</property>
|
||||||
<property name="ServerName or IP" required="">Name or IP of TCP server</property>
|
<property name="ServerName or IP" required="">Name or IP of TCP server</property>
|
||||||
<property name="Port Number" required="">Port to be used</property>
|
<property name="Port Number" required="">Port to be used</property>
|
||||||
|
<property name="Re-use connection" required="Yes">If selected, the connection is kept open. Otherwise it is closed when the data has been read.</property>
|
||||||
<property name="Timeout (milliseconds)" required="">Timeout for replies</property>
|
<property name="Timeout (milliseconds)" required="">Timeout for replies</property>
|
||||||
<property name="Set Nodelay" required="">Should the nodelay property be set?</property>
|
<property name="Set Nodelay" required="">Should the nodelay property be set?</property>
|
||||||
<property name="Text to Send" required="">Text to be sent</property>
|
<property name="Text to Send" required="">Text to be sent</property>
|
||||||
|
|
|
||||||