You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2008/08/17 21:52:49 UTC
svn commit: r686637 [14/16] - in /mina/ftpserver/trunk:
core/src/main/java/org/apache/ftpserver/
core/src/main/java/org/apache/ftpserver/command/
core/src/main/java/org/apache/ftpserver/config/spring/
core/src/main/java/org/apache/ftpserver/filesystem/...
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnSkipTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnSkipTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnSkipTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnSkipTest.java Sun Aug 17 12:52:42 2008
@@ -29,15 +29,25 @@
import org.apache.ftpserver.clienttests.ClientTestTemplate;
import org.apache.ftpserver.test.TestUtil;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class FtpLetReturnSkipTest extends ClientTestTemplate {
private static final byte[] TESTDATA = "TESTDATA".getBytes();
+
private static final byte[] DOUBLE_TESTDATA = "TESTDATATESTDATA".getBytes();
+
private static final File TEST_FILE1 = new File(ROOT_DIR, "test1.txt");
+
private static final File TEST_FILE2 = new File(ROOT_DIR, "test2.txt");
+
private static final File TEST_DIR1 = new File(ROOT_DIR, "dir1");;
protected FtpletEnum mockReturnValue = FtpletEnum.RET_SKIP;
-
+
/*
* (non-Javadoc)
*
@@ -45,7 +55,7 @@
*/
protected void setUp() throws Exception {
MockFtplet.callback = new MockFtpletCallback();
-
+
initDirs();
initServer();
@@ -54,16 +64,19 @@
}
protected FtpServer createServer() throws Exception {
- FtpServer server = super.createServer();
+ FtpServer server = super.createServer();
- server.getServerContext().getFtpletContainer().addFtplet("f1", new MockFtplet());
+ server.getServerContext().getFtpletContainer().addFtplet("f1",
+ new MockFtplet());
return server;
}
public void testLogin() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onLogin(FtpSession session, FtpRequest request) throws FtpException, IOException {
- session.write(new DefaultFtpReply(FtpReply.REPLY_530_NOT_LOGGED_IN, "foo"));
+ public FtpletEnum onLogin(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_530_NOT_LOGGED_IN, "foo"));
throwException();
return mockReturnValue;
@@ -75,32 +88,36 @@
public void testExceptionDuringDeleteStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onDeleteStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
-
- session.write(new DefaultFtpReply(FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "foo"));
+ public FtpletEnum onDeleteStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
+
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN,
+ "foo"));
throwException();
return mockReturnValue;
}
};
-
+
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertFalse(client.deleteFile(TEST_FILE1.getName()));
-
+
assertTrue(TEST_FILE1.exists());
}
public void testExceptionDuringDeleteEnd() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
throwException();
return mockReturnValue;
}
};
-
+
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertTrue(client.deleteFile(TEST_FILE1.getName()));
@@ -109,110 +126,123 @@
public void testExceptionDuringMkdirStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
-
- session.write(new DefaultFtpReply(FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
+ public FtpletEnum onMkdirStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
+
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
throwException();
return mockReturnValue;
}
};
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertFalse(client.makeDirectory(TEST_DIR1.getName()));
-
+
assertFalse(TEST_DIR1.exists());
}
public void testExceptionDuringMkdirEnd() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
throwException();
return mockReturnValue;
}
};
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertTrue(client.makeDirectory(TEST_DIR1.getName()));
-
+
assertTrue(TEST_DIR1.exists());
}
public void testExceptionDuringRmdirStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onRmdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
- session.write(new DefaultFtpReply(FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "foo"));
+ public FtpletEnum onRmdirStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN,
+ "foo"));
throwException();
return mockReturnValue;
}
};
-
+
TEST_DIR1.mkdirs();
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertFalse(client.removeDirectory(TEST_DIR1.getName()));
-
+
assertTrue(TEST_DIR1.exists());
}
public void testExceptionDuringRmdirEnd() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
throwException();
return mockReturnValue;
}
};
-
+
TEST_DIR1.mkdirs();
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertTrue(client.removeDirectory(TEST_DIR1.getName()));
-
+
assertFalse(TEST_DIR1.exists());
}
public void testExceptionDuringSite() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onSite(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onSite(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
throwException();
return mockReturnValue;
}
};
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
-
+
client.site("HELP");
}
public void testExceptionDuringRenameStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onRenameStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
- session.write(new DefaultFtpReply(FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED, "foo"));
-
+ public FtpletEnum onRenameStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
+ session
+ .write(new DefaultFtpReply(
+ FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
+ "foo"));
+
throwException();
return mockReturnValue;
}
};
-
+
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertFalse(client.rename(TEST_FILE1.getName(), TEST_FILE2.getName()));
-
+
assertTrue(TEST_FILE1.exists());
assertFalse(TEST_FILE2.exists());
}
-
+
public void testExceptionDuringRenameEnd() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
throwException();
return mockReturnValue;
}
};
-
+
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertTrue(client.rename(TEST_FILE1.getName(), TEST_FILE2.getName()));
@@ -223,130 +253,147 @@
public void testExceptionDuringDownloadStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
- session.write(new DefaultFtpReply(FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
-
+ public FtpletEnum onDownloadStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
+
throwException();
return mockReturnValue;
}
};
-
+
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
client.retrieveFileStream(TEST_FILE1.getName());
-
+
assertTrue(FTPReply.isNegativePermanent(client.getReplyCode()));
}
public void testExceptionDuringDownloadEnd() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onDownloadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDownloadEnd(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
throwException();
return mockReturnValue;
}
};
-
+
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
assertTrue(client.retrieveFile(TEST_FILE1.getName(), baos));
-
+
TestUtil.assertArraysEqual(TESTDATA, baos.toByteArray());
}
public void testExceptionDuringAppendStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onAppendStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
- session.write(new DefaultFtpReply(FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
+ public FtpletEnum onAppendStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
throwException();
return mockReturnValue;
}
};
-
+
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
- assertFalse(client.appendFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA)));
-
+ assertFalse(client.appendFile(TEST_FILE1.getName(),
+ new ByteArrayInputStream(TESTDATA)));
+
TestUtil.assertFileEqual(TESTDATA, TEST_FILE1);
}
-
+
public void testExceptionDuringAppendEnd() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
throwException();
return mockReturnValue;
}
};
-
+
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
- assertTrue(client.appendFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA)));
-
+ assertTrue(client.appendFile(TEST_FILE1.getName(),
+ new ByteArrayInputStream(TESTDATA)));
+
TestUtil.assertFileEqual(DOUBLE_TESTDATA, TEST_FILE1);
}
public void testExceptionDuringUploadStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onUploadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
- session.write(new DefaultFtpReply(FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
-
+ public FtpletEnum onUploadStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
+
throwException();
return mockReturnValue;
}
};
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
- assertFalse(client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA)));
-
+ assertFalse(client.storeFile(TEST_FILE1.getName(),
+ new ByteArrayInputStream(TESTDATA)));
+
assertFalse(TEST_FILE1.exists());
}
-
+
public void testExceptionDuringUploadEnd() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
throwException();
return mockReturnValue;
}
};
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
- assertTrue(client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA)));
-
+ assertTrue(client.storeFile(TEST_FILE1.getName(),
+ new ByteArrayInputStream(TESTDATA)));
+
TestUtil.assertFileEqual(TESTDATA, TEST_FILE1);
}
-
+
public void testExceptionDuringUploadUniqueStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
- session.write(new DefaultFtpReply(FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
+ public FtpletEnum onUploadUniqueStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
throwException();
return mockReturnValue;
}
};
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
- assertFalse(client.storeUniqueFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA)));
-
+ assertFalse(client.storeUniqueFile(TEST_FILE1.getName(),
+ new ByteArrayInputStream(TESTDATA)));
+
assertEquals(ROOT_DIR.listFiles().length, 0);
}
-
+
public void testExceptionDuringUploadUniqueEnd() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onUploadUniqueEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadUniqueEnd(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
throwException();
-
+
return mockReturnValue;
}
};
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertTrue(client.storeUniqueFile(new ByteArrayInputStream(TESTDATA)));
-
+
TestUtil.assertFileEqual(TESTDATA, ROOT_DIR.listFiles()[0]);
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowFtpExceptionTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowFtpExceptionTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowFtpExceptionTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowFtpExceptionTest.java Sun Aug 17 12:52:42 2008
@@ -21,6 +21,12 @@
import java.io.IOException;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class FtpLetThrowFtpExceptionTest extends FtpLetReturnDisconnectTest {
protected void throwException() throws FtpException, IOException {
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowIOExceptionTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowIOExceptionTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowIOExceptionTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowIOExceptionTest.java Sun Aug 17 12:52:42 2008
@@ -21,7 +21,12 @@
import java.io.IOException;
-
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class FtpLetThrowIOExceptionTest extends FtpLetThrowFtpExceptionTest {
protected void throwException() throws IOException {
throw new IOException();
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowRuntimeExceptionTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowRuntimeExceptionTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowRuntimeExceptionTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetThrowRuntimeExceptionTest.java Sun Aug 17 12:52:42 2008
@@ -21,8 +21,14 @@
import java.io.IOException;
-
-public class FtpLetThrowRuntimeExceptionTest extends FtpLetThrowFtpExceptionTest {
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
+public class FtpLetThrowRuntimeExceptionTest extends
+ FtpLetThrowFtpExceptionTest {
protected void throwException() throws IOException {
throw new IOException();
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/MockFtplet.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/MockFtplet.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/MockFtplet.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/MockFtplet.java Sun Aug 17 12:52:42 2008
@@ -15,16 +15,22 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ftplet;
import java.io.IOException;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class MockFtplet extends DefaultFtplet {
protected static MockFtpletCallback callback = new MockFtpletCallback();
-
+
public void destroy() {
callback.destroy();
}
@@ -33,84 +39,103 @@
callback.init(ftpletContext);
}
- public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onAppendEnd(session, request);
}
- public FtpletEnum onAppendStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onAppendStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onAppendStart(session, request);
}
- public FtpletEnum onConnect(FtpSession session) throws FtpException, IOException {
+ public FtpletEnum onConnect(FtpSession session) throws FtpException,
+ IOException {
return callback.onConnect(session);
}
- public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onDeleteEnd(session, request);
}
- public FtpletEnum onDeleteStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDeleteStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onDeleteStart(session, request);
}
- public FtpletEnum onDisconnect(FtpSession session) throws FtpException, IOException {
+ public FtpletEnum onDisconnect(FtpSession session) throws FtpException,
+ IOException {
return callback.onDisconnect(session);
}
- public FtpletEnum onDownloadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDownloadEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onDownloadEnd(session, request);
}
- public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onDownloadStart(session, request);
}
- public FtpletEnum onLogin(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onLogin(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onLogin(session, request);
}
- public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onMkdirEnd(session, request);
}
- public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onMkdirStart(session, request);
}
- public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onRenameEnd(session, request);
}
- public FtpletEnum onRenameStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRenameStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onRenameStart(session, request);
}
- public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onRmdirEnd(session, request);
}
- public FtpletEnum onRmdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRmdirStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onRmdirStart(session, request);
}
- public FtpletEnum onSite(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onSite(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onSite(session, request);
}
- public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onUploadEnd(session, request);
}
- public FtpletEnum onUploadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onUploadStart(session, request);
}
- public FtpletEnum onUploadUniqueEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadUniqueEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onUploadUniqueEnd(session, request);
}
- public FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return callback.onUploadUniqueStart(session, request);
}
}
-
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/MockFtpletCallback.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/MockFtpletCallback.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/MockFtpletCallback.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/MockFtpletCallback.java Sun Aug 17 12:52:42 2008
@@ -15,101 +15,126 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ftplet;
import java.io.IOException;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class MockFtpletCallback extends DefaultFtplet {
public static FtpletEnum returnValue;
-
+
public void destroy() {
}
public void init(FtpletContext ftpletContext) throws FtpException {
}
- public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onAppendStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onAppendStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onConnect(FtpSession session) throws FtpException, IOException {
+ public FtpletEnum onConnect(FtpSession session) throws FtpException,
+ IOException {
return returnValue;
}
- public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onDeleteStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDeleteStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onDisconnect(FtpSession session) throws FtpException, IOException {
+ public FtpletEnum onDisconnect(FtpSession session) throws FtpException,
+ IOException {
return returnValue;
}
- public FtpletEnum onDownloadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDownloadEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onLogin(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onLogin(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onRenameStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRenameStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onRmdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRmdirStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onSite(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onSite(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onUploadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onUploadUniqueEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadUniqueEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
- public FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
return returnValue;
}
-
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/interfaces/ServerFtpStatisticsTestTemplate.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/interfaces/ServerFtpStatisticsTestTemplate.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/interfaces/ServerFtpStatisticsTestTemplate.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/interfaces/ServerFtpStatisticsTestTemplate.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.interfaces;
@@ -25,12 +25,17 @@
import org.apache.ftpserver.FtpStatisticsImpl;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public abstract class ServerFtpStatisticsTestTemplate extends TestCase {
-
public void testConnectionCount() {
ServerFtpStatistics stats = createStatistics();
-
+
assertEquals(0, stats.getTotalConnectionNumber());
assertEquals(0, stats.getCurrentConnectionNumber());
@@ -41,7 +46,7 @@
stats.setOpenConnection(new FtpIoSession(null, null));
assertEquals(2, stats.getTotalConnectionNumber());
assertEquals(2, stats.getCurrentConnectionNumber());
-
+
stats.setCloseConnection(new FtpIoSession(null, null));
assertEquals(2, stats.getTotalConnectionNumber());
assertEquals(1, stats.getCurrentConnectionNumber());
@@ -55,17 +60,17 @@
assertEquals(2, stats.getTotalConnectionNumber());
assertEquals(0, stats.getCurrentConnectionNumber());
}
-
+
@SuppressWarnings("deprecation")
- public void testStartDateImmutable() {
+ public void testStartDateImmutable() {
ServerFtpStatistics stats = createStatistics();
Date date = stats.getStartTime();
date.setYear(1);
-
+
Date actual = stats.getStartTime();
-
+
assertFalse(1 == actual.getYear());
-
+
}
protected abstract FtpStatisticsImpl createStatistics();
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/DirectoryListerTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/DirectoryListerTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/DirectoryListerTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/DirectoryListerTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listing;
@@ -29,22 +29,33 @@
import org.apache.ftpserver.usermanager.BaseUser;
import org.apache.ftpserver.util.IoUtils;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class DirectoryListerTest extends TestCase {
private static final File TEST_TMP_DIR = new File("test-tmp");
+
protected static final File ROOT_DIR = new File(TEST_TMP_DIR, "ftproot");
-
+
private static final File TEST_FILE1 = new File(ROOT_DIR, "test1.txt");
private static final File TEST_DIR1 = new File(ROOT_DIR, "dir1");
+
private static final File TEST_DIR2 = new File(ROOT_DIR, "dir2");
- private static final File TEST_FILE1_IN_DIR1 = new File(TEST_DIR1, "test3.txt");
- private static final File TEST_FILE2_IN_DIR1 = new File(TEST_DIR1, "test4.txt");
+ private static final File TEST_FILE1_IN_DIR1 = new File(TEST_DIR1,
+ "test3.txt");
+
+ private static final File TEST_FILE2_IN_DIR1 = new File(TEST_DIR1,
+ "test4.txt");
+
private static final File TEST_DIR_IN_DIR1 = new File(TEST_DIR1, "dir3");
private static final byte[] TEST_DATA = "TESTDATA".getBytes();
-
-
+
private DirectoryLister directoryLister;
private FileSystemView fileSystemView;
@@ -52,9 +63,10 @@
protected void setUp() throws Exception {
BaseUser baseUser = new BaseUser();
baseUser.setHomeDirectory(ROOT_DIR.getAbsolutePath());
- fileSystemView = new NativeFileSystemView(baseUser) {};
+ fileSystemView = new NativeFileSystemView(baseUser) {
+ };
directoryLister = new DirectoryLister();
-
+
assertTrue(ROOT_DIR.mkdirs());
assertTrue(TEST_DIR1.mkdirs());
assertTrue(TEST_DIR2.mkdirs());
@@ -64,21 +76,23 @@
assertTrue(TEST_DIR_IN_DIR1.mkdir());
}
-
public void testListFiles() throws Exception {
ListArgument arg = new ListArgument(TEST_DIR1.getName(), null, null);
FileFormater formater = new NLSTFileFormater();
-
- String actual = directoryLister.listFiles(arg, fileSystemView, formater);
-
+
+ String actual = directoryLister
+ .listFiles(arg, fileSystemView, formater);
+
assertEquals("dir3\r\ntest3.txt\r\ntest4.txt\r\n", actual);
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
- if(TEST_TMP_DIR.exists()) {
+ if (TEST_TMP_DIR.exists()) {
IoUtils.delete(TEST_TMP_DIR);
}
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/LISTFileFormaterTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/LISTFileFormaterTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/LISTFileFormaterTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/LISTFileFormaterTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listing;
@@ -28,16 +28,25 @@
import org.apache.ftpserver.ftplet.FileObject;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
@SuppressWarnings("deprecation")
public class LISTFileFormaterTest extends TestCase {
private static final Date LAST_MODIFIED_IN_2005 = new Date(105, 1, 2, 3, 4);
+
private static final FileObject TEST_FILE = new MockFileObject();
+
private static final String TEST_FILE_FORMAT = "-r-------- 1 owner group 13 Feb 2 2005 short\r\n";
- private static final String TEST_DIR_FORMAT = "dr-------- 3 owner group 0 Feb 2 2005 short\r\n";
-
+
+ private static final String TEST_DIR_FORMAT = "dr-------- 3 owner group 0 Feb 2 2005 short\r\n";
+
public LISTFileFormater formater = new LISTFileFormater();
-
+
public static class MockFileObject implements FileObject {
public InputStream createInputStream(long offset) throws IOException {
return null;
@@ -119,7 +128,7 @@
return false;
}
}
-
+
public void testSingleFile() {
assertEquals(TEST_FILE_FORMAT, formater.format(TEST_FILE));
}
@@ -137,9 +146,9 @@
public boolean isFile() {
return false;
}
-
+
};
-
+
assertEquals(TEST_DIR_FORMAT, formater.format(dir));
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/ListArgumentParserTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/ListArgumentParserTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/ListArgumentParserTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/ListArgumentParserTest.java Sun Aug 17 12:52:42 2008
@@ -15,18 +15,23 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listing;
import junit.framework.TestCase;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class ListArgumentParserTest extends TestCase {
-
public void testParseOnlyFile() {
ListArgument arg = ListArgumentParser.parse("foo");
-
+
assertEquals("foo", arg.getFile());
assertNull(arg.getPattern());
assertEquals(0, arg.getOptions().length);
@@ -34,7 +39,7 @@
public void testParseOnlyFileWithDir() {
ListArgument arg = ListArgumentParser.parse("bar/foo");
-
+
assertEquals("bar/foo", arg.getFile());
assertNull(arg.getPattern());
assertEquals(0, arg.getOptions().length);
@@ -42,32 +47,31 @@
public void testParseOnlyPatternWithDir() {
ListArgument arg = ListArgumentParser.parse("bar/foo*");
-
+
assertEquals("bar/", arg.getFile());
assertEquals("foo*", arg.getPattern());
assertEquals(0, arg.getOptions().length);
}
-
public void testParseFileWithSpace() {
ListArgument arg = ListArgumentParser.parse("foo bar");
-
+
assertEquals("foo bar", arg.getFile());
assertNull(arg.getPattern());
assertEquals(0, arg.getOptions().length);
}
-
+
public void testParseWithTrailingOptions() {
ListArgument arg = ListArgumentParser.parse("foo -la");
-
+
assertEquals("foo -la", arg.getFile());
assertNull(arg.getPattern());
assertEquals(0, arg.getOptions().length);
}
-
+
public void testParseNullArgument() {
ListArgument arg = ListArgumentParser.parse(null);
-
+
assertEquals("./", arg.getFile());
assertNull(arg.getPattern());
assertEquals(0, arg.getOptions().length);
@@ -75,7 +79,7 @@
public void testParseFileAndOptions() {
ListArgument arg = ListArgumentParser.parse("-la foo");
-
+
assertEquals("foo", arg.getFile());
assertNull(arg.getPattern());
assertEquals(2, arg.getOptions().length);
@@ -85,14 +89,14 @@
public void testParseOnlyOptions() {
ListArgument arg = ListArgumentParser.parse("-la");
-
+
assertEquals("./", arg.getFile());
assertNull(arg.getPattern());
assertEquals(2, arg.getOptions().length);
assertTrue(arg.hasOption('l'));
assertTrue(arg.hasOption('a'));
}
-
+
public void testPatternDetection() {
assertNull(ListArgumentParser.parse("foo").getPattern());
assertNotNull(ListArgumentParser.parse("foo*").getPattern());
@@ -104,10 +108,10 @@
assertNotNull(ListArgumentParser.parse("foo[").getPattern());
assertNotNull(ListArgumentParser.parse("[foo").getPattern());
}
-
+
public void testParseSimplePattern() {
ListArgument arg = ListArgumentParser.parse("foo*");
-
+
assertEquals("./", arg.getFile());
assertEquals("foo*", arg.getPattern());
assertEquals(0, arg.getOptions().length);
@@ -115,7 +119,7 @@
public void testParseDirAndPattern() {
ListArgument arg = ListArgumentParser.parse("bar/foo*");
-
+
assertEquals("bar/", arg.getFile());
assertEquals("foo*", arg.getPattern());
assertEquals(0, arg.getOptions().length);
@@ -125,7 +129,7 @@
try {
ListArgumentParser.parse("bar*/foo");
fail("IllegalArgumentException must be thrown");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// OK
}
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/ListArgumentTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/ListArgumentTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/ListArgumentTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/ListArgumentTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listing;
@@ -23,46 +23,52 @@
import junit.framework.TestCase;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class ListArgumentTest extends TestCase {
- private static final char[] OPTIONS = new char[]{'a', 'b', 'c'};
- private static final char[] OPTIONS_EMPTY = new char[]{};
-
+ private static final char[] OPTIONS = new char[] { 'a', 'b', 'c' };
+
+ private static final char[] OPTIONS_EMPTY = new char[] {};
+
public void testFilePatternAndOptions() {
ListArgument arg = new ListArgument("bar", "foo", OPTIONS);
-
+
assertEquals("bar", arg.getFile());
assertEquals("foo", arg.getPattern());
-
+
assertTrue(Arrays.equals(OPTIONS, arg.getOptions()));
}
public void testArgumentAndEmptyOptions() {
ListArgument arg = new ListArgument("bar", "foo", OPTIONS_EMPTY);
-
+
assertEquals(0, arg.getOptions().length);
}
public void testArgumentAndNullOptions() {
ListArgument arg = new ListArgument("bar", "foo", null);
-
+
assertNotNull(arg.getOptions());
assertEquals(0, arg.getOptions().length);
}
-
+
public void testNullFile() {
ListArgument arg = new ListArgument(null, "foo", null);
-
+
assertNull(arg.getFile());
assertEquals("foo", arg.getPattern());
}
public void testNullPattern() {
ListArgument arg = new ListArgument("bar", null, null);
-
+
assertEquals("bar", arg.getFile());
assertNull(arg.getPattern());
}
-
}
\ No newline at end of file
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/MLSTFileFormaterTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/MLSTFileFormaterTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/MLSTFileFormaterTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/MLSTFileFormaterTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listing;
@@ -28,14 +28,21 @@
import org.apache.ftpserver.ftplet.FileObject;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
@SuppressWarnings("deprecation")
public class MLSTFileFormaterTest extends TestCase {
private static final Date LAST_MODIFIED_IN_2005 = new Date(105, 1, 2, 3, 4);
+
private static final FileObject TEST_FILE = new MockFileObject();
public MLSTFileFormater formater = new MLSTFileFormater(null);
-
+
public static class MockFileObject implements FileObject {
public InputStream createInputStream(long offset) throws IOException {
return null;
@@ -117,9 +124,10 @@
return false;
}
}
-
+
public void testSingleFile() {
- assertEquals("Size=13;Modify=20050202030400.000;Type=file; short\r\n", formater.format(TEST_FILE));
+ assertEquals("Size=13;Modify=20050202030400.000;Type=file; short\r\n",
+ formater.format(TEST_FILE));
}
public void testSingleDir() {
@@ -135,11 +143,11 @@
public long getSize() {
return 0;
}
-
-
+
};
-
- assertEquals("Size=0;Modify=20050202030400.000;Type=dir; short\r\n", formater.format(dir));
+
+ assertEquals("Size=0;Modify=20050202030400.000;Type=dir; short\r\n",
+ formater.format(dir));
}
}
\ No newline at end of file
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/NLSTFileFormaterTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/NLSTFileFormaterTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/NLSTFileFormaterTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/listing/NLSTFileFormaterTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.listing;
@@ -27,12 +27,18 @@
import org.apache.ftpserver.ftplet.FileObject;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class NLSTFileFormaterTest extends TestCase {
private static final FileObject TEST_FILE = new MockFileObject();
public NLSTFileFormater formater = new NLSTFileFormater();
-
+
public static class MockFileObject implements FileObject {
public InputStream createInputStream(long offset) throws IOException {
return null;
@@ -114,7 +120,7 @@
return false;
}
}
-
+
public void testSingleFile() {
assertEquals("short\r\n", formater.format(TEST_FILE));
}
@@ -128,9 +134,9 @@
public boolean isFile() {
return false;
}
-
+
};
-
+
assertEquals("short\r\n", formater.format(dir));
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/AliasKeymanagerTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/AliasKeymanagerTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/AliasKeymanagerTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/AliasKeymanagerTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ssl;
@@ -27,50 +27,55 @@
import junit.framework.TestCase;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class AliasKeymanagerTest extends TestCase {
-
-
- private KeyManager km;
-
- protected void setUp() throws Exception {
- KeyStore ks = KeyStore.getInstance("JKS");
-
- FileInputStream fis = new FileInputStream("src/test/resources/keymanager-test.jks");
- ks.load(fis, "".toCharArray());
-
- KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
- kmf.init(ks, "".toCharArray());
-
- km = kmf.getKeyManagers()[0];
- }
-
- public void testServerAliasWithAliasDSAKey() throws Exception {
- AliasKeyManager akm = new AliasKeyManager(km, "dsakey");
-
- assertEquals("dsakey", akm.chooseServerAlias("DSA", null, null));
- assertEquals(null, akm.chooseServerAlias("RSA", null, null));
- }
-
- public void testServerAliasWithAliasRSAKey() throws Exception {
- AliasKeyManager akm = new AliasKeyManager(km, "rsakey");
-
- assertEquals(null, akm.chooseServerAlias("DSA", null, null));
- assertEquals("rsakey", akm.chooseServerAlias("RSA", null, null));
- }
-
- public void testServerAliasWithoutAlias() throws Exception {
- AliasKeyManager akm = new AliasKeyManager(km, null);
-
- assertEquals("dsakey", akm.chooseServerAlias("DSA", null, null));
- assertEquals("rsakey", akm.chooseServerAlias("RSA", null, null));
- }
-
- public void testServerAliasNonExistingKey() throws Exception {
- AliasKeyManager akm = new AliasKeyManager(km, "nonexisting");
-
- assertEquals(null, akm.chooseServerAlias("DSA", null, null));
- assertEquals(null, akm.chooseServerAlias("RSA", null, null));
- }
+ private KeyManager km;
+
+ protected void setUp() throws Exception {
+ KeyStore ks = KeyStore.getInstance("JKS");
+
+ FileInputStream fis = new FileInputStream(
+ "src/test/resources/keymanager-test.jks");
+ ks.load(fis, "".toCharArray());
+
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+ kmf.init(ks, "".toCharArray());
+
+ km = kmf.getKeyManagers()[0];
+ }
+
+ public void testServerAliasWithAliasDSAKey() throws Exception {
+ AliasKeyManager akm = new AliasKeyManager(km, "dsakey");
+
+ assertEquals("dsakey", akm.chooseServerAlias("DSA", null, null));
+ assertEquals(null, akm.chooseServerAlias("RSA", null, null));
+ }
+
+ public void testServerAliasWithAliasRSAKey() throws Exception {
+ AliasKeyManager akm = new AliasKeyManager(km, "rsakey");
+
+ assertEquals(null, akm.chooseServerAlias("DSA", null, null));
+ assertEquals("rsakey", akm.chooseServerAlias("RSA", null, null));
+ }
+
+ public void testServerAliasWithoutAlias() throws Exception {
+ AliasKeyManager akm = new AliasKeyManager(km, null);
+
+ assertEquals("dsakey", akm.chooseServerAlias("DSA", null, null));
+ assertEquals("rsakey", akm.chooseServerAlias("RSA", null, null));
+ }
+
+ public void testServerAliasNonExistingKey() throws Exception {
+ AliasKeyManager akm = new AliasKeyManager(km, "nonexisting");
+
+ assertEquals(null, akm.chooseServerAlias("DSA", null, null));
+ assertEquals(null, akm.chooseServerAlias("RSA", null, null));
+ }
}
\ No newline at end of file
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ExplicitSecurityTestTemplate.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ExplicitSecurityTestTemplate.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ExplicitSecurityTestTemplate.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ExplicitSecurityTestTemplate.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ssl;
@@ -28,13 +28,20 @@
import org.apache.ftpserver.interfaces.FtpIoSession;
import org.apache.ftpserver.util.IoUtils;
-
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public abstract class ExplicitSecurityTestTemplate extends SSLTestTemplate {
private static final File TEST_FILE1 = new File(ROOT_DIR, "test1.txt");
+
private static final File TEST_FILE2 = new File(ROOT_DIR, "test2.txt");
+
private static final byte[] TEST_DATA = "TESTDATA".getBytes();
-
+
protected void setUp() throws Exception {
super.setUp();
@@ -42,123 +49,129 @@
}
private FtpIoSession getActiveSession() {
- return server.getListener("default").getActiveSessions().iterator().next();
+ return server.getListener("default").getActiveSessions().iterator()
+ .next();
}
/**
- * Tests that we can send command over the command channel.
- * This is, in fact already tested by login in setup but
- * an explicit test is good anyways.
+ * Tests that we can send command over the command channel. This is, in fact
+ * already tested by login in setup but an explicit test is good anyways.
*/
public void testCommandChannel() throws Exception {
assertTrue(getActiveSession().isSecure());
assertTrue(FTPReply.isPositiveCompletion(client.noop()));
}
-
public void testReissueAuth() throws Exception {
- assertTrue(getActiveSession().isSecure());
+ assertTrue(getActiveSession().isSecure());
assertTrue(FTPReply.isPositiveCompletion(client.noop()));
-
+
// we do not accept reissued AUTH or AUTH on implicitly secured socket
assertEquals(534, client.sendCommand("AUTH SSL"));
}
-
public void testIsSecure() {
assertTrue(getActiveSession().isSecure());
}
-
+
public void testStoreWithProtPInPassiveMode() throws Exception {
client.setRemoteVerificationEnabled(false);
client.enterLocalPassiveMode();
-
- ((FTPSClient)client).execPROT("P");
+
+ ((FTPSClient) client).execPROT("P");
assertTrue(getActiveSession().getDataConnection().isSecure());
-
- client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(TEST_DATA));
-
+
+ client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(
+ TEST_DATA));
+
assertTrue(TEST_FILE1.exists());
assertEquals(TEST_DATA.length, TEST_FILE1.length());
}
- public void testStoreWithProtPAndReturnToProtCInPassiveMode() throws Exception {
+ public void testStoreWithProtPAndReturnToProtCInPassiveMode()
+ throws Exception {
client.setRemoteVerificationEnabled(false);
client.enterLocalPassiveMode();
-
- ((FTPSClient)client).execPROT("P");
+
+ ((FTPSClient) client).execPROT("P");
assertTrue(getActiveSession().getDataConnection().isSecure());
-
- client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(TEST_DATA));
-
+
+ client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(
+ TEST_DATA));
+
assertTrue(TEST_FILE1.exists());
assertEquals(TEST_DATA.length, TEST_FILE1.length());
- ((FTPSClient)client).execPROT("C");
-
+ ((FTPSClient) client).execPROT("C");
+
assertFalse(getActiveSession().getDataConnection().isSecure());
- client.storeFile(TEST_FILE2.getName(), new ByteArrayInputStream(TEST_DATA));
-
+ client.storeFile(TEST_FILE2.getName(), new ByteArrayInputStream(
+ TEST_DATA));
+
assertTrue(TEST_FILE2.exists());
assertEquals(TEST_DATA.length, TEST_FILE2.length());
}
public void testStoreWithProtPInActiveMode() throws Exception {
- ((FTPSClient)client).execPROT("P");
+ ((FTPSClient) client).execPROT("P");
assertTrue(getActiveSession().getDataConnection().isSecure());
-
- client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(TEST_DATA));
-
+
+ client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(
+ TEST_DATA));
+
assertTrue(TEST_FILE1.exists());
assertEquals(TEST_DATA.length, TEST_FILE1.length());
}
- public void testStoreWithProtPAndReturnToProtCInActiveMode() throws Exception {
- ((FTPSClient)client).execPROT("P");
+ public void testStoreWithProtPAndReturnToProtCInActiveMode()
+ throws Exception {
+ ((FTPSClient) client).execPROT("P");
assertTrue(getActiveSession().getDataConnection().isSecure());
-
- client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(TEST_DATA));
-
+
+ client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(
+ TEST_DATA));
+
assertTrue(TEST_FILE1.exists());
assertEquals(TEST_DATA.length, TEST_FILE1.length());
// needed due to bug in commons-net
client.setServerSocketFactory(null);
-
- ((FTPSClient)client).execPROT("C");
-
- client.storeFile(TEST_FILE2.getName(), new ByteArrayInputStream(TEST_DATA));
-
+
+ ((FTPSClient) client).execPROT("C");
+
+ client.storeFile(TEST_FILE2.getName(), new ByteArrayInputStream(
+ TEST_DATA));
+
assertTrue(TEST_FILE2.exists());
assertEquals(TEST_DATA.length, TEST_FILE2.length());
}
-
+
public void testListEmptyDir() throws Exception {
client.setRemoteVerificationEnabled(false);
client.enterLocalPassiveMode();
-
- ((FTPSClient)client).execPROT("P");
+
+ ((FTPSClient) client).execPROT("P");
assertTrue(getActiveSession().getDataConnection().isSecure());
-
+
File dir = new File(ROOT_DIR, "dir");
dir.mkdir();
-
+
client.listFiles(dir.getName());
}
public void testReceiveEmptyFile() throws Exception {
client.setRemoteVerificationEnabled(false);
client.enterLocalPassiveMode();
-
- ((FTPSClient)client).execPROT("P");
+
+ ((FTPSClient) client).execPROT("P");
assertTrue(getActiveSession().getDataConnection().isSecure());
-
+
File file = new File(ROOT_DIR, "foo");
file.createNewFile();
-
+
InputStream is = null;
try {
is = client.retrieveFileStream(file.getName());
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ExtendedAliasKeymanagerTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ExtendedAliasKeymanagerTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ExtendedAliasKeymanagerTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ExtendedAliasKeymanagerTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ssl;
@@ -27,77 +27,84 @@
import junit.framework.TestCase;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class ExtendedAliasKeymanagerTest extends TestCase {
-
-
- private KeyManager km;
-
- protected void setUp() throws Exception {
- KeyStore ks = KeyStore.getInstance("JKS");
-
- FileInputStream fis = new FileInputStream("src/test/resources/keymanager-test.jks");
- ks.load(fis, "".toCharArray());
-
- KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
- kmf.init(ks, "".toCharArray());
-
- km = kmf.getKeyManagers()[0];
- }
-
- public void testServerAliasWithAliasDSAKey() throws Exception {
- ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, "dsakey");
-
- assertEquals("dsakey", akm.chooseServerAlias("DSA", null, null));
- assertEquals(null, akm.chooseServerAlias("RSA", null, null));
- }
-
- public void testServerAliasWithAliasRSAKey() throws Exception {
- ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, "rsakey");
-
- assertEquals(null, akm.chooseServerAlias("DSA", null, null));
- assertEquals("rsakey", akm.chooseServerAlias("RSA", null, null));
- }
-
- public void testServerAliasWithoutAlias() throws Exception {
- ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, null);
-
- assertEquals("dsakey", akm.chooseServerAlias("DSA", null, null));
- assertEquals("rsakey", akm.chooseServerAlias("RSA", null, null));
- }
-
- public void testServerAliasNonExistingKey() throws Exception {
- ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, "nonexisting");
-
- assertEquals(null, akm.chooseServerAlias("DSA", null, null));
- assertEquals(null, akm.chooseServerAlias("RSA", null, null));
- }
-
- public void testEngineServerAliasWithAliasDSAKey() throws Exception {
- ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, "dsakey");
-
- assertEquals("dsakey", akm.chooseEngineServerAlias("DSA", null, null));
- assertEquals(null, akm.chooseEngineServerAlias("RSA", null, null));
- }
-
- public void testEngineServerAliasWithAliasRSAKey() throws Exception {
- ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, "rsakey");
-
- assertEquals(null, akm.chooseEngineServerAlias("DSA", null, null));
- assertEquals("rsakey", akm.chooseEngineServerAlias("RSA", null, null));
- }
-
- public void testEngineServerAliasWithoutAlias() throws Exception {
- ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, null);
-
- assertEquals("dsakey", akm.chooseEngineServerAlias("DSA", null, null));
- assertEquals("rsakey", akm.chooseEngineServerAlias("RSA", null, null));
- }
-
- public void testEngineServerAliasNonExistingKey() throws Exception {
- ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, "nonexisting");
-
- assertEquals(null, akm.chooseEngineServerAlias("DSA", null, null));
- assertEquals(null, akm.chooseEngineServerAlias("RSA", null, null));
- }
+ private KeyManager km;
+
+ protected void setUp() throws Exception {
+ KeyStore ks = KeyStore.getInstance("JKS");
+
+ FileInputStream fis = new FileInputStream(
+ "src/test/resources/keymanager-test.jks");
+ ks.load(fis, "".toCharArray());
+
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+ kmf.init(ks, "".toCharArray());
+
+ km = kmf.getKeyManagers()[0];
+ }
+
+ public void testServerAliasWithAliasDSAKey() throws Exception {
+ ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, "dsakey");
+
+ assertEquals("dsakey", akm.chooseServerAlias("DSA", null, null));
+ assertEquals(null, akm.chooseServerAlias("RSA", null, null));
+ }
+
+ public void testServerAliasWithAliasRSAKey() throws Exception {
+ ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, "rsakey");
+
+ assertEquals(null, akm.chooseServerAlias("DSA", null, null));
+ assertEquals("rsakey", akm.chooseServerAlias("RSA", null, null));
+ }
+
+ public void testServerAliasWithoutAlias() throws Exception {
+ ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, null);
+
+ assertEquals("dsakey", akm.chooseServerAlias("DSA", null, null));
+ assertEquals("rsakey", akm.chooseServerAlias("RSA", null, null));
+ }
+
+ public void testServerAliasNonExistingKey() throws Exception {
+ ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km,
+ "nonexisting");
+
+ assertEquals(null, akm.chooseServerAlias("DSA", null, null));
+ assertEquals(null, akm.chooseServerAlias("RSA", null, null));
+ }
+
+ public void testEngineServerAliasWithAliasDSAKey() throws Exception {
+ ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, "dsakey");
+
+ assertEquals("dsakey", akm.chooseEngineServerAlias("DSA", null, null));
+ assertEquals(null, akm.chooseEngineServerAlias("RSA", null, null));
+ }
+
+ public void testEngineServerAliasWithAliasRSAKey() throws Exception {
+ ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, "rsakey");
+
+ assertEquals(null, akm.chooseEngineServerAlias("DSA", null, null));
+ assertEquals("rsakey", akm.chooseEngineServerAlias("RSA", null, null));
+ }
+
+ public void testEngineServerAliasWithoutAlias() throws Exception {
+ ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km, null);
+
+ assertEquals("dsakey", akm.chooseEngineServerAlias("DSA", null, null));
+ assertEquals("rsakey", akm.chooseEngineServerAlias("RSA", null, null));
+ }
+
+ public void testEngineServerAliasNonExistingKey() throws Exception {
+ ExtendedAliasKeyManager akm = new ExtendedAliasKeyManager(km,
+ "nonexisting");
+
+ assertEquals(null, akm.chooseEngineServerAlias("DSA", null, null));
+ assertEquals(null, akm.chooseEngineServerAlias("RSA", null, null));
+ }
}
\ No newline at end of file
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ImplicitSecurityTestTemplate.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ImplicitSecurityTestTemplate.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ImplicitSecurityTestTemplate.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/ImplicitSecurityTestTemplate.java Sun Aug 17 12:52:42 2008
@@ -19,10 +19,16 @@
package org.apache.ftpserver.ssl;
-
-public abstract class ImplicitSecurityTestTemplate extends ExplicitSecurityTestTemplate {
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
+public abstract class ImplicitSecurityTestTemplate extends
+ ExplicitSecurityTestTemplate {
protected boolean useImplicit() {
- return true;
+ return true;
}
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaCipherSuitesTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaCipherSuitesTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaCipherSuitesTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaCipherSuitesTest.java Sun Aug 17 12:52:42 2008
@@ -26,58 +26,65 @@
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.listener.nio.NioListener;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class MinaCipherSuitesTest extends SSLTestTemplate {
protected String getAuthValue() {
return "TLS";
}
-
+
protected boolean useImplicit() {
- return true;
+ return true;
}
-
+
protected FtpServer createServer() throws Exception {
- FtpServer server = super.createServer();
- DefaultFtpServerContext context = (DefaultFtpServerContext) server.getServerContext();
+ FtpServer server = super.createServer();
+ DefaultFtpServerContext context = (DefaultFtpServerContext) server
+ .getServerContext();
NioListener listener = (NioListener) context.getListener("default");
- DefaultSslConfiguration sslConfig = (DefaultSslConfiguration) listener.getSslConfiguration();
- sslConfig.setEnabledCipherSuites(new String[]{"SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"});
+ DefaultSslConfiguration sslConfig = (DefaultSslConfiguration) listener
+ .getSslConfiguration();
+ sslConfig
+ .setEnabledCipherSuites(new String[] { "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA" });
return server;
}
-
+
protected FTPSClient createFTPClient() throws Exception {
return new FTPSClient(true);
}
- protected boolean isConnectClient() {
- return false;
- }
-
- /*
- * Only certain cipher suites will work with the keys and protocol
- * we're using for this test.
- * Two suites known to work is:
- * * SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA
- * * SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
+ protected boolean isConnectClient() {
+ return false;
+ }
+
+ /*
+ * Only certain cipher suites will work with the keys and protocol we're
+ * using for this test. Two suites known to work is:
+ * SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
*/
public void testEnabled() throws Exception {
-
- ((FTPSClient)client).setEnabledCipherSuites(new String[]{
- "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"});
-
+
+ ((FTPSClient) client)
+ .setEnabledCipherSuites(new String[] { "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA" });
+
connectClient();
}
-
+
public void testDisabled() throws Exception {
- ((FTPSClient)client).setEnabledCipherSuites(new String[]{
- "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"});
-
+ ((FTPSClient) client)
+ .setEnabledCipherSuites(new String[] { "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" });
+
try {
- doConnect();
- fail("Must throw SSLHandshakeException");
- } catch(SSLHandshakeException e) {
+ doConnect();
+ fail("Must throw SSLHandshakeException");
+ } catch (SSLHandshakeException e) {
// OK
}
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaClientAuthTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaClientAuthTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaClientAuthTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaClientAuthTest.java Sun Aug 17 12:52:42 2008
@@ -29,19 +29,25 @@
import org.apache.commons.net.ftp.FTPSClient;
import org.apache.ftpserver.interfaces.FtpIoSession;
-
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class MinaClientAuthTest extends SSLTestTemplate {
protected FTPSClient createFTPClient() throws Exception {
FTPSClient client = new FTPSClient(useImplicit());
client.setNeedClientAuth(true);
-
+
KeyStore ks = KeyStore.getInstance("JKS");
FileInputStream fis = new FileInputStream(FTPCLIENT_KEYSTORE);
ks.load(fis, KEYSTORE_PASSWORD.toCharArray());
fis.close();
-
- KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory
+ .getDefaultAlgorithm());
kmf.init(ks, KEYSTORE_PASSWORD.toCharArray());
client.setKeyManager(kmf.getKeyManagers()[0]);
@@ -52,23 +58,24 @@
protected String getAuthValue() {
return "TLS";
}
-
+
protected String getClientAuth() {
return "true";
}
-
+
public void testCommandChannel() throws Exception {
assertTrue(client.login(ADMIN_USERNAME, ADMIN_PASSWORD));
assertTrue(FTPReply.isPositiveCompletion(client.noop()));
}
-
public void testClientCertificates() throws Exception {
- FtpIoSession session = server.getListener("default").getActiveSessions().iterator().next();
+ FtpIoSession session = server.getListener("default")
+ .getActiveSessions().iterator().next();
assertEquals(1, session.getClientCertificates().length);
-
- X509Certificate cert = (X509Certificate) session.getClientCertificates()[0];
-
+
+ X509Certificate cert = (X509Certificate) session
+ .getClientCertificates()[0];
+
assertTrue(cert.getSubjectDN().toString().contains("FtpClient"));
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaExplicitSSLTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaExplicitSSLTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaExplicitSSLTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaExplicitSSLTest.java Sun Aug 17 12:52:42 2008
@@ -19,7 +19,12 @@
package org.apache.ftpserver.ssl;
-
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class MinaExplicitSSLTest extends ExplicitSecurityTestTemplate {
protected String getAuthValue() {
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaExplicitTLSTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaExplicitTLSTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaExplicitTLSTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaExplicitTLSTest.java Sun Aug 17 12:52:42 2008
@@ -19,7 +19,12 @@
package org.apache.ftpserver.ssl;
-
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class MinaExplicitTLSTest extends ExplicitSecurityTestTemplate {
protected String getAuthValue() {
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitClientAuthTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitClientAuthTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitClientAuthTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitClientAuthTest.java Sun Aug 17 12:52:42 2008
@@ -19,11 +19,15 @@
package org.apache.ftpserver.ssl;
-
-
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class MinaImplicitClientAuthTest extends MinaClientAuthTest {
protected boolean useImplicit() {
- return true;
+ return true;
}
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitSSLTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitSSLTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitSSLTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitSSLTest.java Sun Aug 17 12:52:42 2008
@@ -19,7 +19,12 @@
package org.apache.ftpserver.ssl;
-
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class MinaImplicitSSLTest extends ImplicitSecurityTestTemplate {
protected String getAuthValue() {
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitTLSTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitTLSTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitTLSTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitTLSTest.java Sun Aug 17 12:52:42 2008
@@ -19,7 +19,12 @@
package org.apache.ftpserver.ssl;
-
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class MinaImplicitTLSTest extends ImplicitSecurityTestTemplate {
protected String getAuthValue() {
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/SSLTestTemplate.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/SSLTestTemplate.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/SSLTestTemplate.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/SSLTestTemplate.java Sun Aug 17 12:52:42 2008
@@ -37,22 +37,32 @@
import org.apache.ftpserver.test.TestUtil;
import org.apache.ftpserver.util.IoUtils;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public abstract class SSLTestTemplate extends ClientTestTemplate {
- protected static final File FTPCLIENT_KEYSTORE = new File(TestUtil.getBaseDir(), "src/test/resources/client.jks");
+ protected static final File FTPCLIENT_KEYSTORE = new File(TestUtil
+ .getBaseDir(), "src/test/resources/client.jks");
+
protected static final String KEYSTORE_PASSWORD = "password";
- private static final File FTPSERVER_KEYSTORE = new File(TestUtil.getBaseDir(), "src/test/resources/ftpserver.jks");
+ private static final File FTPSERVER_KEYSTORE = new File(TestUtil
+ .getBaseDir(), "src/test/resources/ftpserver.jks");
protected FtpServer createServer() throws Exception {
assertTrue(FTPSERVER_KEYSTORE.exists());
FtpServer server = super.createServer();
- DefaultFtpServerContext context = (DefaultFtpServerContext) server.getServerContext();
+ DefaultFtpServerContext context = (DefaultFtpServerContext) server
+ .getServerContext();
NioListener listener = (NioListener) context.getListener("default");
-
+
listener.setImplicitSsl(useImplicit());
-
+
DefaultSslConfiguration sslConfig = new DefaultSslConfiguration();
sslConfig.setKeystoreFile(FTPSERVER_KEYSTORE);
sslConfig.setKeystorePassword(KEYSTORE_PASSWORD);
@@ -61,53 +71,53 @@
sslConfig.setKeyPassword(KEYSTORE_PASSWORD);
listener.setSslConfiguration(sslConfig);
-
+
DefaultSslConfiguration dataSslConfig = new DefaultSslConfiguration();
dataSslConfig.setKeystoreFile(FTPSERVER_KEYSTORE);
dataSslConfig.setKeystorePassword(KEYSTORE_PASSWORD);
dataSslConfig.setSslProtocol(getAuthValue());
dataSslConfig.setClientAuthentication(getClientAuth());
dataSslConfig.setKeyPassword(KEYSTORE_PASSWORD);
-
+
DefaultDataConnectionConfiguration dataConfig = new DefaultDataConnectionConfiguration();
dataConfig.setSslConfiguration(dataSslConfig);
-
+
listener.setDataConnectionConfiguration(dataConfig);
-
+
return server;
}
protected boolean useImplicit() {
return false;
}
-
+
protected String getClientAuth() {
return "false";
}
protected FTPSClient createFTPClient() throws Exception {
FTPSClient ftpsClient = new FTPSClient(useImplicit());
-
+
FileInputStream fin = new FileInputStream(FTPCLIENT_KEYSTORE);
KeyStore store = KeyStore.getInstance("jks");
store.load(fin, KEYSTORE_PASSWORD.toCharArray());
fin.close();
-
-
+
// initialize key manager factory
- KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
+ KeyManagerFactory keyManagerFactory = KeyManagerFactory
+ .getInstance("SunX509");
keyManagerFactory.init(store, KEYSTORE_PASSWORD.toCharArray());
-
+
// initialize trust manager factory
- TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509");
+ TrustManagerFactory trustManagerFactory = TrustManagerFactory
+ .getInstance("SunX509");
trustManagerFactory.init(store);
ftpsClient.setKeyManager(keyManagerFactory.getKeyManagers()[0]);
ftpsClient.setTrustManager(trustManagerFactory.getTrustManagers()[0]);
-
String auth = getAuthValue();
- if(auth != null) {
+ if (auth != null) {
ftpsClient.setAuthValue(auth);
}
return ftpsClient;
@@ -127,5 +137,4 @@
}
}
-
}