mstover1 01/06/07 16:38:47
Modified: src/org/apache/jmeter/protocol/http/config UrlConfig.java
src/org/apache/jmeter/protocol/http/config/gui
UrlConfigGui.java
src/org/apache/jmeter/protocol/http/control
HttpTestSample.java
src/org/apache/jmeter/protocol/http/sampler HTTPSampler.java
Log:
Fixing GET processing for URL requests. slight UI mods
Revision Changes Path
1.10 +47 -6
jakarta-jmeter/src/org/apache/jmeter/protocol/http/config/UrlConfig.java
Index: UrlConfig.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/config/UrlConfig.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- UrlConfig.java 2001/04/11 17:23:45 1.9
+++ UrlConfig.java 2001/06/07 23:38:46 1.10
@@ -64,8 +64,8 @@
* Apache Foundation
*
*@author Michael Stover
- *@created $Date: 2001/04/11 17:23:45 $
- *@version $Revision: 1.9 $
+ *@created $Date: 2001/06/07 23:38:46 $
+ *@version $Revision: 1.10 $
***********************************************************/
public class UrlConfig extends AbstractConfigElement
@@ -99,20 +99,35 @@
***********************************************************/
public URL getUrl() throws MalformedURLException
{
- if(!getPath().startsWith("/"))
+ String pathAndQuery = null;
+ if(this.getMethod().equals(this.GET))
{
- setPath("/"+getPath());
+ pathAndQuery = this.getPath()+"?"+getQueryString();
}
+ else
+ {
+ pathAndQuery = this.getPath();
+ }
+ if(!pathAndQuery.startsWith("/"))
+ {
+ pathAndQuery = "/" + pathAndQuery;
+ }
if(getPort() == 0)
{
- return new URL(getProtocol(),getDomain(),getPath());
+ return new URL(getProtocol(),getDomain(),pathAndQuery);
}
else
{
- return new URL(getProtocol(), (String)properties.get(DOMAIN),
getPort(), (String)properties.get(PATH));
+ return new URL(getProtocol(), (String)properties.get(DOMAIN),
getPort(),
+ pathAndQuery);
}
}
+ public void setMethod(String meth)
+ {
+ properties.put(METHOD,meth);
+ }
+
public int getPort() {
Object port = properties.get(PORT);
if(port == null)
@@ -206,6 +221,32 @@
{
updatePropertyIfAbsent((UrlConfig)config);
}
+ }
+
+ public Arguments getArguments()
+ {
+ return (Arguments)getProperty(this.ARGUMENTS);
+ }
+
+ public String getQueryString()
+ {
+ StringBuffer buf = new StringBuffer();
+ Iterator iter = getArguments().iterator();
+ boolean first = true;
+ while (iter.hasNext())
+ {
+ Argument item = (Argument)iter.next();
+ if (!first)
+ {
+ buf.append("&");
+ }
+ else
+ {
+ first = false;
+ }
+ buf.append(item.getName() + "=" + item.getValue());
+ }
+ return buf.toString();
}
public Class getGuiClass()
1.7 +3 -3
jakarta-jmeter/src/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
Index: UrlConfigGui.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- UrlConfigGui.java 2001/04/11 17:23:46 1.6
+++ UrlConfigGui.java 2001/06/07 23:38:46 1.7
@@ -138,7 +138,7 @@
private void init()
{
- this.setLayout(new VerticalLayout(5,VerticalLayout.LEFT));
+ this.setLayout(new VerticalLayout(2,VerticalLayout.LEFT));
if(displayName)
{
namePanel = new NamePanel();
@@ -206,7 +206,7 @@
https.setActionCommand(HTTPS);
http.addActionListener(this);
https.addActionListener(this);
- JPanel buttons = new JPanel(new
VerticalLayout(0,VerticalLayout.LEFT));
+ JPanel buttons = new JPanel();
JPanel postButton = new JPanel();
postButton.add(http);
@@ -239,7 +239,7 @@
get.setActionCommand(GET);
post.addActionListener(this);
get.addActionListener(this);
- JPanel buttons = new JPanel(new
VerticalLayout(0,VerticalLayout.LEFT));
+ JPanel buttons = new JPanel();
JPanel postButton = new JPanel();
postButton.add(post);
1.13 +5 -1
jakarta-jmeter/src/org/apache/jmeter/protocol/http/control/HttpTestSample.java
Index: HttpTestSample.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/control/HttpTestSample.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- HttpTestSample.java 2001/03/17 22:25:49 1.12
+++ HttpTestSample.java 2001/06/07 23:38:46 1.13
@@ -71,7 +71,7 @@
* Apache Foundation
*
*@author Michael Stover
- *@created $Date: 2001/03/17 22:25:49 $
+ *@created $Date: 2001/06/07 23:38:46 $
*@version 1.0
*/
@@ -90,6 +90,10 @@
super();
urls = new LinkedList();
defaultUrl = new UrlConfig();
+ defaultUrl.setPort(80);
+ defaultUrl.setProtocol("http");
+ defaultUrl.setMethod(UrlConfig.GET);
+
}
public void uncompile()
1.11 +4 -23
jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
Index: HTTPSampler.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- HTTPSampler.java 2001/04/10 12:50:17 1.10
+++ HTTPSampler.java 2001/06/07 23:38:47 1.11
@@ -72,8 +72,8 @@
* HTTP requests, including cookies and authentication.
*
*@author Michael Stover
- *@created $Date: 2001/04/10 12:50:17 $
- *@version $Revision: 1.10 $
+ *@created $Date: 2001/06/07 23:38:47 $
+ *@version $Revision: 1.11 $
***********************************************************/
public class HTTPSampler implements Sampler
{
@@ -122,7 +122,7 @@
throws IOException
{
((HttpURLConnection)connection).setRequestMethod("POST");
- String postData =
getPostData((Arguments)url.getProperty(UrlConfig.ARGUMENTS));
+ String postData = url.getQueryString();
connection.setRequestProperty("Content-length", "" +
postData.length());
connection.setRequestProperty("Content-type",
"application/x-www-form-urlencoded");
connection.setDoOutput(true);
@@ -181,26 +181,7 @@
}
}
- private String getPostData(Arguments args)
- {
- StringBuffer buf = new StringBuffer();
- Iterator iter = args.iterator();
- boolean first = true;
- while (iter.hasNext())
- {
- Argument item = (Argument)iter.next();
- if (!first)
- {
- buf.append("&");
- }
- else
- {
- first = false;
- }
- buf.append(item.getName() + "=" + item.getValue());
- }
- return buf.toString();
- }
+
private int getErrorLevel(HttpURLConnection conn, SampleResult res, long time)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]