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 [13/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/config/spring/SpringConfigTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.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.config.spring;
@@ -37,65 +37,83 @@
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class SpringConfigTest extends TestCase {
public void test() throws Throwable {
- XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource("src/test/resources/spring-config/config-spring-1.xml"));
+ XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource(
+ "src/test/resources/spring-config/config-spring-1.xml"));
FtpServer server = (FtpServer) factory.getBean("server");
-
+
assertEquals(500, server.getConnectionConfig().getMaxLogins());
- assertEquals(false, server.getConnectionConfig().isAnonymousLoginEnabled());
+ assertEquals(false, server.getConnectionConfig()
+ .isAnonymousLoginEnabled());
assertEquals(123, server.getConnectionConfig().getMaxAnonymousLogins());
assertEquals(124, server.getConnectionConfig().getMaxLoginFailures());
assertEquals(125, server.getConnectionConfig().getLoginFailureDelay());
-
- Map<String, Listener> listeners = server.getServerContext().getListeners();
+
+ Map<String, Listener> listeners = server.getServerContext()
+ .getListeners();
assertEquals(3, listeners.size());
-
+
Listener listener = listeners.get("listener0");
assertNotNull(listener);
assertTrue(listener instanceof NioListener);
- assertEquals(2222, ((NioListener)listener).getPort());
- assertEquals(InetAddress.getByName("1.2.3.4"), ((NioListener)listener).getServerAddress());
- assertEquals(true, ((NioListener)listener).getDataConnectionConfiguration().isActiveEnabled());
- assertEquals(InetAddress.getByName("1.2.3.4"), ((NioListener)listener).getDataConnectionConfiguration().getActiveLocalAddress());
- assertEquals("123-125", ((NioListener)listener).getDataConnectionConfiguration().getPassivePorts());
-
- List<Subnet> subnets = ((NioListener)listener).getBlockedSubnets();
+ assertEquals(2222, ((NioListener) listener).getPort());
+ assertEquals(InetAddress.getByName("1.2.3.4"), ((NioListener) listener)
+ .getServerAddress());
+ assertEquals(true, ((NioListener) listener)
+ .getDataConnectionConfiguration().isActiveEnabled());
+ assertEquals(InetAddress.getByName("1.2.3.4"), ((NioListener) listener)
+ .getDataConnectionConfiguration().getActiveLocalAddress());
+ assertEquals("123-125", ((NioListener) listener)
+ .getDataConnectionConfiguration().getPassivePorts());
+
+ List<Subnet> subnets = ((NioListener) listener).getBlockedSubnets();
assertEquals(3, subnets.size());
- assertEquals(new Subnet(InetAddress.getByName("1.2.3.0"), 16), subnets.get(0));
- assertEquals(new Subnet(InetAddress.getByName("1.2.4.0"), 16), subnets.get(1));
- assertEquals(new Subnet(InetAddress.getByName("1.2.3.4"), 32), subnets.get(2));
-
- DefaultSslConfiguration ssl = (DefaultSslConfiguration) listener.getSslConfiguration();
+ assertEquals(new Subnet(InetAddress.getByName("1.2.3.0"), 16), subnets
+ .get(0));
+ assertEquals(new Subnet(InetAddress.getByName("1.2.4.0"), 16), subnets
+ .get(1));
+ assertEquals(new Subnet(InetAddress.getByName("1.2.3.4"), 32), subnets
+ .get(2));
+
+ DefaultSslConfiguration ssl = (DefaultSslConfiguration) listener
+ .getSslConfiguration();
assertEquals(new File("/tmp/tmp.jks"), ssl.getKeystoreFile());
assertEquals("password", ssl.getKeystorePassword());
// make sure the data connection got the same config
- ssl = (DefaultSslConfiguration) listener.getDataConnectionConfiguration().getSslConfiguration();
+ ssl = (DefaultSslConfiguration) listener
+ .getDataConnectionConfiguration().getSslConfiguration();
assertEquals(new File("/tmp/tmp.jks"), ssl.getKeystoreFile());
assertEquals("password", ssl.getKeystorePassword());
-
listener = listeners.get("listener1");
assertNotNull(listener);
assertTrue(listener instanceof NioListener);
- assertEquals(2223, ((NioListener)listener).getPort());
-
+ assertEquals(2223, ((NioListener) listener).getPort());
+
listener = listeners.get("listener2");
assertNotNull(listener);
assertTrue(listener instanceof NioListener);
- assertEquals(2224, ((NioListener)listener).getPort());
-
- DefaultCommandFactory cf = (DefaultCommandFactory) server.getServerContext().getCommandFactory();
+ assertEquals(2224, ((NioListener) listener).getPort());
+
+ DefaultCommandFactory cf = (DefaultCommandFactory) server
+ .getServerContext().getCommandFactory();
assertEquals(2, cf.getCommandMap().size());
assertTrue(cf.getCommand("FOO") instanceof HELP);
assertTrue(cf.getCommand("FOO2") instanceof STAT);
-
- String[] languages = server.getServerContext().getMessageResource().getAvailableLanguages();
-
+ String[] languages = server.getServerContext().getMessageResource()
+ .getAvailableLanguages();
+
assertEquals(3, languages.length);
assertEquals("se", languages[0]);
assertEquals("no", languages[1]);
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/TestFtplet.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/TestFtplet.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/TestFtplet.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/TestFtplet.java Sun Aug 17 12:52:42 2008
@@ -15,12 +15,18 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.config.spring;
import org.apache.ftpserver.ftplet.DefaultFtplet;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class TestFtplet extends DefaultFtplet {
private int foo;
@@ -32,5 +38,5 @@
public void setFoo(int foo) {
this.foo = foo;
}
-
+
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/XmlDbUserManagerConfigTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/XmlDbUserManagerConfigTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/XmlDbUserManagerConfigTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/XmlDbUserManagerConfigTest.java Sun Aug 17 12:52:42 2008
@@ -27,16 +27,24 @@
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class XmlDbUserManagerConfigTest extends TestCase {
public void test() throws Throwable {
- XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource(
- "src/test/resources/spring-config/config-spring-db-user-manager.xml"));
+ XmlBeanFactory factory = new XmlBeanFactory(
+ new FileSystemResource(
+ "src/test/resources/spring-config/config-spring-db-user-manager.xml"));
FtpServer server = (FtpServer) factory.getBean("server");
- DbUserManager um = (DbUserManager) server.getServerContext().getUserManager();
- assertTrue(um.getDataSource() instanceof jdbcDataSource);
+ DbUserManager um = (DbUserManager) server.getServerContext()
+ .getUserManager();
+ assertTrue(um.getDataSource() instanceof jdbcDataSource);
assertEquals("INSERT USER", um.getSqlUserInsert());
assertEquals("UPDATE USER", um.getSqlUserUpdate());
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/FileObjectTestTemplate.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/FileObjectTestTemplate.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/FileObjectTestTemplate.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/FileObjectTestTemplate.java Sun Aug 17 12:52:42 2008
@@ -15,11 +15,10 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.filesystem;
-
import junit.framework.TestCase;
import org.apache.ftpserver.ftplet.AuthorizationRequest;
@@ -27,57 +26,66 @@
import org.apache.ftpserver.ftplet.User;
import org.apache.ftpserver.usermanager.BaseUser;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public abstract class FileObjectTestTemplate extends TestCase {
protected static final String FILE2_PATH = "/dir1/file2";
+
protected static final String DIR1_PATH = "/dir1";
+
protected static final String DIR1_WITH_SLASH_PATH = "/dir1/";
+
protected static final String FILE1_PATH = "/file1";
+
protected static final String FILE3_PATH = "/file3";
-
+
protected static final User USER = new BaseUser() {
- private static final long serialVersionUID = 4906315989316879758L;
+ private static final long serialVersionUID = 4906315989316879758L;
- public AuthorizationRequest authorize(AuthorizationRequest request) {
+ public AuthorizationRequest authorize(AuthorizationRequest request) {
return request;
}
};
protected abstract FileObject createFileObject(String fileName, User user);
-
-
+
public void testNullFileName() {
- try{
+ try {
createFileObject(null, USER);
fail("Must throw IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// OK
}
}
public void testWhiteSpaceFileName() {
- try{
+ try {
createFileObject(" \t", USER);
- fail("Must throw IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ fail("Must throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
// OK
- }
+ }
}
-
+
public void testEmptyFileName() {
- try{
+ try {
createFileObject("", USER);
fail("Must throw IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// OK
}
}
public void testNonLeadingSlash() {
- try{
+ try {
createFileObject("foo", USER);
fail("Must throw IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// OK
}
}
@@ -85,10 +93,10 @@
public void testFullName() {
FileObject fileObject = createFileObject(FILE2_PATH, USER);
assertEquals("/dir1/file2", fileObject.getFullName());
-
+
fileObject = createFileObject("/dir1/", USER);
assertEquals("/dir1", fileObject.getFullName());
-
+
fileObject = createFileObject("/dir1", USER);
assertEquals("/dir1", fileObject.getFullName());
}
@@ -96,17 +104,17 @@
public void testShortName() {
FileObject fileObject = createFileObject("/dir1/file2", USER);
assertEquals("file2", fileObject.getShortName());
-
+
fileObject = createFileObject("/dir1/", USER);
assertEquals("dir1", fileObject.getShortName());
-
+
fileObject = createFileObject("/dir1", USER);
assertEquals("dir1", fileObject.getShortName());
}
-
+
public void testListFilesInOrder() {
FileObject root = createFileObject("/", USER);
-
+
FileObject[] files = root.listFiles();
assertEquals(3, files.length);
assertEquals("dir1", files[0].getShortName());
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/FileSystemViewTemplate.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/FileSystemViewTemplate.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/FileSystemViewTemplate.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/FileSystemViewTemplate.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.filesystem;
@@ -23,20 +23,25 @@
import org.apache.ftpserver.usermanager.BaseUser;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public abstract class FileSystemViewTemplate extends TestCase {
protected static final String DIR1_NAME = "dir1";
-
+
protected BaseUser user = new BaseUser();
-
public void testChangeDirectory() throws Exception {
NativeFileSystemView view = new NativeFileSystemView(user);
assertEquals("/", view.getCurrentDirectory().getFullName());
assertTrue(view.changeDirectory(DIR1_NAME));
assertEquals("/" + DIR1_NAME, view.getCurrentDirectory().getFullName());
-
+
assertTrue(view.changeDirectory("."));
assertEquals("/" + DIR1_NAME, view.getCurrentDirectory().getFullName());
@@ -53,11 +58,11 @@
public void testChangeDirectoryCaseInsensitive() throws Exception {
NativeFileSystemView view = new NativeFileSystemView(user, true);
assertEquals("/", view.getCurrentDirectory().getFullName());
-
+
assertTrue(view.changeDirectory("/DIR1"));
assertEquals("/dir1", view.getCurrentDirectory().getFullName());
assertTrue(view.getCurrentDirectory().doesExist());
-
+
assertTrue(view.changeDirectory("/dir1"));
assertEquals("/dir1", view.getCurrentDirectory().getFullName());
assertTrue(view.getCurrentDirectory().doesExist());
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/NativeFileObjectTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/NativeFileObjectTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/NativeFileObjectTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/NativeFileObjectTest.java Sun Aug 17 12:52:42 2008
@@ -28,17 +28,28 @@
import org.apache.ftpserver.ftplet.User;
import org.apache.ftpserver.util.IoUtils;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class NativeFileObjectTest extends FileObjectTestTemplate {
private static final File TEST_TMP_DIR = new File("test-tmp");
+
private static final File ROOT_DIR = new File(TEST_TMP_DIR, "ftproot");
+
private static final File TEST_DIR1 = new File(ROOT_DIR, "dir1");
+
private static final File TEST_FILE1 = new File(ROOT_DIR, "file1");
+
private static final File TEST_FILE2_IN_DIR1 = new File(TEST_DIR1, "file2");
+
private static final File TEST_FILE3 = new File(ROOT_DIR, "file3");
private static final Map<String, File> FILE_MAPPINGS = new HashMap<String, File>();
-
+
static {
FILE_MAPPINGS.put("/", ROOT_DIR);
FILE_MAPPINGS.put(FILE2_PATH, TEST_FILE2_IN_DIR1);
@@ -48,7 +59,7 @@
FILE_MAPPINGS.put(DIR1_WITH_SLASH_PATH, TEST_DIR1);
FILE_MAPPINGS.put(" \t", TEST_FILE2_IN_DIR1);
}
-
+
private static final String ROOT_DIR_PATH = ROOT_DIR.getAbsolutePath()
.replace(File.separatorChar, '/');
@@ -66,7 +77,6 @@
TEST_FILE2_IN_DIR1.createNewFile();
TEST_FILE3.createNewFile();
}
-
protected FileObject createFileObject(String fileName, User user) {
return new NativeFileObject(fileName, FILE_MAPPINGS.get(fileName), user);
@@ -135,17 +145,17 @@
}
public void testGetPhysicalNameCaseInsensitive() {
- assertEquals(FULL_PATH, NativeFileObject.getPhysicalName(
- ROOT_DIR.getAbsolutePath(), TEST_DIR1.getName(), TEST_FILE2_IN_DIR1.getName().toUpperCase(), true));
-
-
+ assertEquals(FULL_PATH, NativeFileObject.getPhysicalName(ROOT_DIR
+ .getAbsolutePath(), TEST_DIR1.getName(), TEST_FILE2_IN_DIR1
+ .getName().toUpperCase(), true));
+
}
public void testConstructorWithNullFile() {
- try{
+ try {
new NativeFileObject("foo", null, USER);
fail("Must throw IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// OK
}
}
@@ -170,5 +180,4 @@
}
}
-
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/NativeFileSystemViewTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/NativeFileSystemViewTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/NativeFileSystemViewTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/filesystem/NativeFileSystemViewTest.java Sun Aug 17 12:52:42 2008
@@ -25,6 +25,12 @@
import org.apache.ftpserver.ftplet.FtpException;
import org.apache.ftpserver.util.IoUtils;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class NativeFileSystemViewTest extends FileSystemViewTemplate {
private static final File TEST_TMP_DIR = new File("test-tmp");
@@ -45,30 +51,26 @@
NativeFileSystemView view = new NativeFileSystemView(user);
assertEquals("/", view.getCurrentDirectory().getFullName());
}
-
-
public void testConstructorWithNullUser() throws FtpException {
- try{
+ try {
new NativeFileSystemView(null);
fail("Must throw IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// OK
}
}
public void testConstructorWithNullHomeDir() throws FtpException {
user.setHomeDirectory(null);
- try{
+ try {
new NativeFileSystemView(user);
fail("Must throw IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// OK
}
}
-
-
-
+
/*
* (non-Javadoc)
*
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/DefaultFtpLetContainerTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/DefaultFtpLetContainerTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/DefaultFtpLetContainerTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/DefaultFtpLetContainerTest.java Sun Aug 17 12:52:42 2008
@@ -19,11 +19,14 @@
package org.apache.ftpserver.ftplet;
-
-
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class DefaultFtpLetContainerTest extends FtpLetContainerTestTemplate {
-
protected FtpletContainer createFtpletContainer() {
return new DefaultFtpletContainer();
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetContainerTestTemplate.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetContainerTestTemplate.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetContainerTestTemplate.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetContainerTestTemplate.java Sun Aug 17 12:52:42 2008
@@ -28,160 +28,170 @@
import org.apache.ftpserver.FtpRequestImpl;
import org.apache.ftpserver.FtpSessionImpl;
-
public abstract class FtpLetContainerTestTemplate extends TestCase {
private FtpletContainer container = createFtpletContainer();
+
private final List<String> calls = new ArrayList<String>();
-
+
protected void setUp() throws Exception {
MockFtplet.callback = new MockFtpletCallback();
MockFtpletCallback.returnValue = FtpletEnum.RET_DEFAULT;
- }
-
+ }
+
protected abstract FtpletContainer createFtpletContainer();
-
+
public void testAddAndGetFtplet() {
MockFtplet ftplet1 = new MockFtplet();
MockFtplet ftplet2 = new MockFtplet();
-
+
assertNull(container.getFtplet("ftplet1"));
assertNull(container.getFtplet("ftplet2"));
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
+
assertSame(ftplet1, container.getFtplet("ftplet1"));
assertSame(ftplet2, container.getFtplet("ftplet2"));
}
-
+
public void testAddFtpletWithDuplicateName() {
MockFtplet ftplet1 = new MockFtplet();
MockFtplet ftplet2 = new MockFtplet();
-
+
assertNull(container.getFtplet("ftplet1"));
-
+
container.addFtplet("ftplet1", ftplet1);
-
+
try {
container.addFtplet("ftplet1", ftplet2);
fail("IllegalArgumentException must be thrown");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// ok
}
-
+
assertSame(ftplet1, container.getFtplet("ftplet1"));
}
public void testRemoveFtplet() {
MockFtplet ftplet1 = new MockFtplet();
MockFtplet ftplet2 = new MockFtplet();
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
+
assertSame(ftplet1, container.getFtplet("ftplet1"));
assertSame(ftplet2, container.getFtplet("ftplet2"));
-
+
assertSame(ftplet1, container.removeFtplet("ftplet1"));
-
+
assertNull(container.getFtplet("ftplet1"));
assertSame(ftplet2, container.getFtplet("ftplet2"));
-
+
assertNull(container.removeFtplet("ftplet1"));
}
-
+
public void testOnConnect() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onConnect(FtpSession session) throws FtpException, IOException {
+ public FtpletEnum onConnect(FtpSession session)
+ throws FtpException, IOException {
calls.add("ftplet1");
return super.onConnect(session);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onConnect(FtpSession session) throws FtpException, IOException {
+ public FtpletEnum onConnect(FtpSession session)
+ throws FtpException, IOException {
calls.add("ftplet2");
return super.onConnect(session);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
+
container.onConnect(new FtpSessionImpl(null));
-
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnDisconnect() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onDisconnect(FtpSession session) throws FtpException, IOException {
+ public FtpletEnum onDisconnect(FtpSession session)
+ throws FtpException, IOException {
calls.add("ftplet1");
return super.onDisconnect(session);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onDisconnect(FtpSession session) throws FtpException, IOException {
+ public FtpletEnum onDisconnect(FtpSession session)
+ throws FtpException, IOException {
calls.add("ftplet2");
return super.onDisconnect(session);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
+
container.onDisconnect(new FtpSessionImpl(null));
-
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnLogin() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onLogin(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onLogin(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet1");
return super.onLogin(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onLogin(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onLogin(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet2");
return super.onLogin(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl("PASS"));
-
+
+ container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "PASS"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnDeleteStart() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onDeleteStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDeleteStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet1");
return super.onDeleteStart(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onDeleteStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDeleteStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet2");
return super.onDeleteStart(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl("DELE"));
-
+
+ container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "DELE"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
@@ -189,23 +199,26 @@
public void testOnDeleteEnd() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet1");
return super.onDeleteEnd(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet2");
return super.onDeleteEnd(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl("DELE"));
-
+
+ container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "DELE"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
@@ -213,23 +226,26 @@
public void testOnUploadStart() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onUploadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet1");
return super.onUploadStart(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onUploadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet2");
return super.onUploadStart(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
- container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl("STOR"));
-
+ container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "STOR"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
@@ -237,23 +253,26 @@
public void testOnUploadEnd() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet1");
return super.onUploadEnd(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet2");
return super.onUploadEnd(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
- container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl("STOR"));
-
+ container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "STOR"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
@@ -261,119 +280,134 @@
public void testOnDownloadStart() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDownloadStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet1");
return super.onDownloadStart(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDownloadStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet2");
return super.onDownloadStart(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl("RETR"));
-
+
+ container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "RETR"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnDownloadEnd() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onDownloadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDownloadEnd(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet1");
return super.onDownloadEnd(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onDownloadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDownloadEnd(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet2");
return super.onDownloadEnd(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl("RETR"));
-
+
+ container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "RETR"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnRmdirStart() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onRmdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRmdirStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet1");
return super.onRmdirStart(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onRmdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRmdirStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet2");
return super.onRmdirStart(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl("RMD"));
-
+
+ container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "RMD"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnRmdirEnd() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet1");
return super.onRmdirEnd(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet2");
return super.onRmdirEnd(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl("RMD"));
-
+
+ container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "RMD"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnMkdirStart() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onMkdirStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet1");
return super.onMkdirStart(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onMkdirStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet2");
return super.onMkdirStart(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl("MKD"));
-
+
+ container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "MKD"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
@@ -381,95 +415,107 @@
public void testOnMkdirEnd() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet1");
return super.onMkdirEnd(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet2");
return super.onMkdirEnd(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl("MKD"));
-
+
+ container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "MKD"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnAppendStart() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onAppendStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onAppendStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet1");
return super.onAppendStart(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onAppendStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onAppendStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet2");
return super.onAppendStart(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl("APPE"));
-
+
+ container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "APPE"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnAppendEnd() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet1");
return super.onAppendEnd(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet2");
return super.onAppendEnd(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl("APPE"));
-
+
+ container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "APPE"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnUploadUniqueStart() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadUniqueStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet1");
return super.onUploadUniqueStart(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadUniqueStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet2");
return super.onUploadUniqueStart(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl("STOU"));
-
+
+ container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "STOU"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
@@ -477,95 +523,107 @@
public void testOnUploadUniqueEnd() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onUploadUniqueEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadUniqueEnd(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet1");
return super.onUploadUniqueEnd(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onUploadUniqueEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadUniqueEnd(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet2");
return super.onUploadUniqueEnd(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl("STOU"));
-
+
+ container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "STOU"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnRenameStart() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onRenameStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRenameStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet1");
return super.onRenameStart(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onRenameStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRenameStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
calls.add("ftplet2");
return super.onRenameStart(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl("RNTO"));
-
+
+ container.beforeCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "RNTO"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnRenameEnd() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet1");
return super.onRenameEnd(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet2");
return super.onRenameEnd(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl("RNTO"));
-
+
+ container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "RNTO"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
}
-
+
public void testOnSite() throws FtpException, IOException {
MockFtplet ftplet1 = new MockFtplet() {
- public FtpletEnum onSite(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onSite(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet1");
return super.onSite(session, request);
}
};
MockFtplet ftplet2 = new MockFtplet() {
- public FtpletEnum onSite(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onSite(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
calls.add("ftplet2");
return super.onSite(session, request);
}
};
-
+
container.addFtplet("ftplet1", ftplet1);
container.addFtplet("ftplet2", ftplet2);
-
- container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl("SITE"));
-
+
+ container.afterCommand(new FtpSessionImpl(null), new FtpRequestImpl(
+ "SITE"));
+
assertEquals(2, calls.size());
assertEquals("ftplet1", calls.get(0));
assertEquals("ftplet2", calls.get(1));
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnDefaultTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnDefaultTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnDefaultTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnDefaultTest.java Sun Aug 17 12:52:42 2008
@@ -29,13 +29,23 @@
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 FtpLetReturnDefaultTest 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");;
-
+
/*
* (non-Javadoc)
*
@@ -54,29 +64,31 @@
}
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 {
+ public FtpletEnum onLogin(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
assertNotNull(session.getUserArgument());
-
+
return super.onLogin(session, request);
}
-
+
};
MockFtpletCallback.returnValue = FtpletEnum.RET_DEFAULT;
-
+
assertTrue(client.login(ADMIN_USERNAME, ADMIN_PASSWORD));
}
public void testDelete() throws Exception {
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertTrue(client.deleteFile(TEST_FILE1.getName()));
assertFalse(TEST_FILE1.exists());
@@ -90,7 +102,7 @@
public void testRmdir() throws Exception {
TEST_DIR1.mkdirs();
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertTrue(client.removeDirectory(TEST_DIR1.getName()));
assertFalse(TEST_DIR1.exists());
@@ -103,7 +115,7 @@
public void testRename() throws Exception {
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertTrue(client.rename(TEST_FILE1.getName(), TEST_FILE2.getName()));
@@ -113,9 +125,9 @@
public void testDownload() throws Exception {
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
client.retrieveFile(TEST_FILE1.getName(), baos);
@@ -124,25 +136,27 @@
public void testAppend() throws Exception {
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
-
- client.appendFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA));
-
+
+ client.appendFile(TEST_FILE1.getName(), new ByteArrayInputStream(
+ TESTDATA));
+
TestUtil.assertFileEqual(DOUBLE_TESTDATA, TEST_FILE1);
}
public void testUpload() throws Exception {
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
- client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA));
-
+ client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(
+ TESTDATA));
+
TestUtil.assertFileEqual(TESTDATA, TEST_FILE1);
}
-
+
public void testUploadUnique() throws Exception {
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
client.storeUniqueFile(new ByteArrayInputStream(TESTDATA));
-
+
TestUtil.assertFileEqual(TESTDATA, ROOT_DIR.listFiles()[0]);
}
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnDisconnectTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnDisconnectTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnDisconnectTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftplet/FtpLetReturnDisconnectTest.java Sun Aug 17 12:52:42 2008
@@ -30,15 +30,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 FtpLetReturnDisconnectTest 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_DISCONNECT;
-
+
/*
* (non-Javadoc)
*
@@ -46,7 +56,7 @@
*/
protected void setUp() throws Exception {
MockFtplet.callback = new MockFtpletCallback();
-
+
initDirs();
initServer();
@@ -55,9 +65,10 @@
}
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;
}
@@ -83,22 +94,22 @@
public void testExceptionDuringDeleteStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onDeleteStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDeleteStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
throwException();
return mockReturnValue;
}
};
-
+
TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
-
+
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
try {
client.deleteFile(TEST_FILE1.getName());
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
- }
- catch (SocketException e) {
+ } catch (SocketException e) {
// OK
}
@@ -107,14 +118,15 @@
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()));
try {
@@ -131,7 +143,8 @@
public void testExceptionDuringMkdirStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onMkdirStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
throwException();
return mockReturnValue;
}
@@ -143,8 +156,7 @@
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
- }
- catch (SocketException e) {
+ } catch (SocketException e) {
// OK
}
@@ -153,7 +165,8 @@
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;
}
@@ -175,7 +188,8 @@
public void testExceptionDuringRmdirStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onRmdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRmdirStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
throwException();
return mockReturnValue;
}
@@ -189,8 +203,7 @@
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
- }
- catch (SocketException e) {
+ } catch (SocketException e) {
// OK
}
@@ -199,7 +212,8 @@
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;
}
@@ -223,7 +237,8 @@
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;
}
@@ -236,15 +251,15 @@
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
- }
- catch (SocketException e) {
+ } catch (SocketException e) {
// OK
}
}
public void testExceptionDuringRenameStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onRenameStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onRenameStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
throwException();
return mockReturnValue;
}
@@ -258,8 +273,7 @@
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
- }
- catch (SocketException e) {
+ } catch (SocketException e) {
// OK
}
@@ -269,7 +283,8 @@
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;
}
@@ -295,7 +310,8 @@
public void testExceptionDuringDownloadStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDownloadStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
throwException();
return mockReturnValue;
}
@@ -309,15 +325,15 @@
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
- }
- catch (SocketException e) {
+ } catch (SocketException e) {
// OK
}
}
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;
}
@@ -333,8 +349,7 @@
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
- }
- catch (SocketException e) {
+ } catch (SocketException e) {
// OK
}
@@ -343,7 +358,8 @@
public void testExceptionDuringAppendStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onAppendStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onAppendStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
throwException();
return mockReturnValue;
}
@@ -353,12 +369,12 @@
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
try {
- client.appendFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA));
+ client.appendFile(TEST_FILE1.getName(), new ByteArrayInputStream(
+ TESTDATA));
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
- }
- catch (SocketException e) {
+ } catch (SocketException e) {
// OK
}
@@ -367,8 +383,9 @@
public void testExceptionDuringAppendEnd() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
- //throwException();
+ public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ // throwException();
return mockReturnValue;
}
};
@@ -376,14 +393,14 @@
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)));
try {
client.noop();
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
- }
- catch (SocketException e) {
+ } catch (SocketException e) {
// OK
}
@@ -392,7 +409,8 @@
public void testExceptionDuringUploadStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onUploadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
throwException();
return mockReturnValue;
}
@@ -400,12 +418,12 @@
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
try {
- client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA));
+ client.storeFile(TEST_FILE1.getName(), new ByteArrayInputStream(
+ TESTDATA));
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
- }
- catch (SocketException e) {
+ } catch (SocketException e) {
// OK
}
@@ -414,14 +432,16 @@
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)));
try {
client.noop();
fail("Must throw FTPConnectionClosedException");
@@ -431,13 +451,13 @@
// OK
}
-
TestUtil.assertFileEqual(TESTDATA, TEST_FILE1);
}
public void testExceptionDuringUploadUniqueStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
- public FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onUploadUniqueStart(FtpSession session,
+ FtpRequest request) throws FtpException, IOException {
throwException();
return mockReturnValue;
}
@@ -445,7 +465,8 @@
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
try {
- client.storeUniqueFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA));
+ client.storeUniqueFile(TEST_FILE1.getName(),
+ new ByteArrayInputStream(TESTDATA));
fail("Must throw FTPConnectionClosedException");
} catch (FTPConnectionClosedException e) {
// OK
@@ -458,7 +479,8 @@
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;