You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2006/04/30 13:55:13 UTC
svn commit: r398317 -
/jakarta/jmeter/branches/rel-2-1/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java
Author: sebb
Date: Sun Apr 30 04:55:12 2006
New Revision: 398317
URL: http://svn.apache.org/viewcvs?rev=398317&view=rev
Log:
Set up SampleResult fields
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java
Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java?rev=398317&r1=398316&r2=398317&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java Sun Apr 30 04:55:12 2006
@@ -1,6 +1,5 @@
-// $Header$
/*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,12 +25,11 @@
/**
* A sampler which understands FTP file requests.
*
- * @version $Revision$ last updated $Date$
*/
public class FTPSampler extends AbstractSampler {
- public final static String SERVER = "FTPSampler.server";
+ public final static String SERVER = "FTPSampler.server"; // $NON-NLS-1$
- public final static String FILENAME = "FTPSampler.filename";
+ public final static String FILENAME = "FTPSampler.filename"; // $NON-NLS-1$
public FTPSampler() {
}
@@ -67,7 +65,7 @@
* @return a formatted string label describing this sampler
*/
public String getLabel() {
- return ("ftp://" + this.getServer() + "/" + this.getFilename());
+ return ("ftp://" + this.getServer() + "/" + this.getFilename()); // $NON-NLS-1$ $NON-NLS-2$
}
public SampleResult sample(Entry e) {
@@ -75,28 +73,31 @@
boolean isSuccessful = false;
// FtpConfig ftpConfig = (FtpConfig)e.getConfigElement(FtpConfig.class);
res.setSampleLabel(getName());
+ res.setSamplerData(getLabel());
// LoginConfig loginConfig =
// (LoginConfig)e.getConfigElement(LoginConfig.class);
res.sampleStart();
+ FtpClient ftp = new FtpClient();
try {
- FtpClient ftp = new FtpClient();
ftp.connect(getServer(), getUsername(), getPassword());
- ftp.setPassive(true);
- // this should probably come from the setup dialog
+ ftp.setPassive(true);// should probably come from the setup dialog
String s = ftp.get(getFilename());
res.setResponseData(s.getBytes());
- // TODO set the response code here somewhere
- ftp.disconnect();
+ res.setResponseCodeOK();
+ res.setResponseMessageOK();
+ ftp.disconnect();
isSuccessful = true;
- } catch (java.net.ConnectException cex) {
+ } catch (java.net.ConnectException ex) {
// java.net.ConnectException -- 502 error code?
// in the future, possibly define and place error codes into the
// result so we know exactly what happened.
- res.setResponseData(cex.toString().getBytes());
+ res.setResponseData(ex.toString().getBytes());
+ res.setResponseMessage(ex.getLocalizedMessage());
} catch (Exception ex) {
// general exception
res.setResponseData(ex.toString().getBytes());
- }
+ res.setResponseMessage(ex.getLocalizedMessage());
+ }
res.sampleEnd();
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org