Author: sebb
Date: Sun Mar 30 09:11:07 2008
New Revision: 642766
URL: http://svn.apache.org/viewvc?rev=642766&view=rev
Log:
FTP Sampler sets a URL if it can
Modified:
jakarta/jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java
jakarta/jmeter/trunk/xdocs/changes.xml
Modified:
jakarta/jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java?rev=642766&r1=642765&r2=642766&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java
Sun Mar 30 09:11:07 2008
@@ -26,10 +26,13 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.io.output.TeeOutputStream;
+import org.apache.commons.lang.text.StrBuilder;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
@@ -37,13 +40,17 @@
import org.apache.jmeter.samplers.AbstractSampler;
import org.apache.jmeter.samplers.Entry;
import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
/**
* A sampler which understands FTP file requests.
*
*/
public class FTPSampler extends AbstractSampler {
- public final static String SERVER = "FTPSampler.server"; // $NON-NLS-1$
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ public final static String SERVER = "FTPSampler.server"; // $NON-NLS-1$
// N.B. Originally there was only one filename, and only get(RETR) was
supported
// To maintain backwards compatibility, the property name needs to
remain the same
@@ -113,10 +120,16 @@
* @return a formatted string label describing this sampler
*/
public String getLabel() {
- return ("ftp://" + getServer() + "/" + getRemoteFilename() //
$NON-NLS-1$ $NON-NLS-2$
- + (isBinaryMode() ? " (Binary) " : " (Ascii) ")
// $NON-NLS-1$ $NON-NLS-2$
- + (isUpload() ? " <- " : " -> ")
// $NON-NLS-1$ $NON-NLS-2$
- + getLocalFilename());
+ StrBuilder sb = new StrBuilder();
+ sb.setNullText("null");// $NON-NLS-1$
+ sb.append("ftp://");// $NON-NLS-1$
+ sb.append(getServer());
+ sb.append("/");// $NON-NLS-1$
+ sb.append(getRemoteFilename());
+ sb.append(isBinaryMode() ? " (Binary) " : " (Ascii) ");//
$NON-NLS-1$ $NON-NLS-2$
+ sb.append(isUpload() ? " <- " : " -> "); // $NON-NLS-1$
$NON-NLS-2$
+ sb.append(getLocalFilename());
+ return sb.toString();
}
public SampleResult sample(Entry e) {
@@ -126,7 +139,13 @@
String local = getLocalFilename();
boolean binaryTransfer = isBinaryMode();
res.setSampleLabel(getName());
- res.setSamplerData(getLabel());
+ final String label = getLabel();
+ res.setSamplerData(label);
+ try {
+ res.setURL(new URL(label));
+ } catch (MalformedURLException e1) {
+ log.warn("Cannot set URL: "+e1.getLocalizedMessage());
+ }
InputStream input = null;
OutputStream output = null;
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=642766&r1=642765&r2=642766&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sun Mar 30 09:11:07 2008
@@ -130,6 +130,7 @@
<li>Bug 44632 - Text input enhancement to FTP Sampler</li>
<li>Bug 42204 - add thread group name to Aggregate and Summary reports</li>
<li>FTP Sampler sets latency = time to login</li>
+<li>FTP Sampler sets a URL if it can</li>
</ul>
<h4>Non-functional changes</h4>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]