Author: ngn
Date: Mon Nov 17 13:43:30 2008
New Revision: 718394

URL: http://svn.apache.org/viewvc?rev=718394&view=rev
Log:
Complete the Javadocs for the public API (FTPSERVER-212)

Modified:
    
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ConnectionConfig.java
    
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ConnectionConfigFactory.java
    
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/DataConnectionConfiguration.java
    
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/DataConnectionConfigurationFactory.java
    
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/NativeFileSystemFactory.java
    
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/message/MessageResourceFactory.java
    
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
    
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetContainerTestTemplate.java

Modified: 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ConnectionConfig.java
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ConnectionConfig.java?rev=718394&r1=718393&r2=718394&view=diff
==============================================================================
--- 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ConnectionConfig.java
 (original)
+++ 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ConnectionConfig.java
 Mon Nov 17 13:43:30 2008
@@ -20,6 +20,8 @@
 package org.apache.ftpserver;
 
 /**
+ * Interface for providing the configuration for the control socket 
connections.
+ * 
  *
  * @author The Apache MINA Project ([EMAIL PROTECTED])
  * @version $Rev$, $Date$
@@ -27,13 +29,35 @@
  */
 public interface ConnectionConfig {
 
+    /**
+     * The maximum number of time an user can fail to login before getting 
disconnected
+     * @return The maximum number of failure login attempts
+     */
     int getMaxLoginFailures();
 
+    /**
+     * The delay in number of milliseconds between login failures. Important 
to 
+     * make brute force attacks harder.
+     * 
+     * @return The delay time in milliseconds
+     */
     int getLoginFailureDelay();
 
+    /**
+     * The maximum number of time an anonymous user can fail to login before 
getting disconnected
+     * @return The maximum number of failer login attempts
+     */
     int getMaxAnonymousLogins();
 
+    /**
+     * The maximum number of concurrently logged in users
+     * @return The maximum number of users
+     */
     int getMaxLogins();
 
+    /**
+     * Is anonymous logins allowed at the server?
+     * @return true if anonymous logins are enabled
+     */
     boolean isAnonymousLoginEnabled();
 }

Modified: 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ConnectionConfigFactory.java
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ConnectionConfigFactory.java?rev=718394&r1=718393&r2=718394&view=diff
==============================================================================
--- 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ConnectionConfigFactory.java
 (original)
+++ 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ConnectionConfigFactory.java
 Mon Nov 17 13:43:30 2008
@@ -28,7 +28,7 @@
  * @version $Rev$, $Date$
  *
  */
-public class ConnectionConfigFactory implements ConnectionConfig {
+public class ConnectionConfigFactory {
 
     private int maxLogins = 10;
 
@@ -41,8 +41,8 @@
     private int loginFailureDelay = 500;
 
     /**
-     * 
-     * @return
+     * Create a connection configuration instances based on the configuration 
on this factory
+     * @return The [EMAIL PROTECTED] ConnectionConfig} instance
      */
     public ConnectionConfig createConnectionConfig() {
         return new DefaultConnectionConfig(anonymousLoginEnabled,
@@ -50,42 +50,87 @@
                 maxLoginFailures);
     }
     
+    /**
+     * The delay in number of milliseconds between login failures. Important 
to 
+     * make brute force attacks harder.
+     * 
+     * @return The delay time in milliseconds
+     */
     public int getLoginFailureDelay() {
         return loginFailureDelay;
     }
 
+    /**
+     * The maximum number of time an anonymous user can fail to login before 
getting disconnected
+     * @return The maximum number of failer login attempts
+     */
     public int getMaxAnonymousLogins() {
         return maxAnonymousLogins;
     }
 
+    /**
+     * The maximum number of time an user can fail to login before getting 
disconnected
+     * @return The maximum number of failure login attempts
+     */
     public int getMaxLoginFailures() {
         return maxLoginFailures;
     }
 
+    /**
+     * The maximum number of concurrently logged in users
+     * @return The maximum number of users
+     */
     public int getMaxLogins() {
         return maxLogins;
     }
 
+    /**
+     * Is anonymous logins allowed at the server?
+     * @return true if anonymous logins are enabled
+     */
     public boolean isAnonymousLoginEnabled() {
         return anonymousLoginEnabled;
     }
 
+    /**
+     * Set she maximum number of concurrently logged in users
+     * @param maxLogins The maximum number of users
+     */
+
     public void setMaxLogins(final int maxLogins) {
         this.maxLogins = maxLogins;
     }
 
+    /**
+     * Set if anonymous logins are allowed at the server
+     * @param anonymousLoginEnabled true if anonymous logins should be enabled
+     */
     public void setAnonymousLoginEnabled(final boolean anonymousLoginEnabled) {
         this.anonymousLoginEnabled = anonymousLoginEnabled;
     }
 
+    /**
+     * Sets the maximum number of time an anonymous user can fail to login 
before getting disconnected
+     * @param maxAnonymousLogins The maximum number of failer login attempts
+     */
     public void setMaxAnonymousLogins(final int maxAnonymousLogins) {
         this.maxAnonymousLogins = maxAnonymousLogins;
     }
 
+    /**
+     * Set the maximum number of time an user can fail to login before getting 
disconnected
+     * @param maxLoginFailures The maximum number of failure login attempts
+     */
     public void setMaxLoginFailures(final int maxLoginFailures) {
         this.maxLoginFailures = maxLoginFailures;
     }
 
+    /**
+     * Set the delay in number of milliseconds between login failures. 
Important to 
+     * make brute force attacks harder.
+     * 
+     * @param loginFailureDelay The delay time in milliseconds
+     */
     public void setLoginFailureDelay(final int loginFailureDelay) {
         this.loginFailureDelay = loginFailureDelay;
     }

Modified: 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/DataConnectionConfiguration.java
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/DataConnectionConfiguration.java?rev=718394&r1=718393&r2=718394&view=diff
==============================================================================
--- 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/DataConnectionConfiguration.java
 (original)
+++ 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/DataConnectionConfiguration.java
 Mon Nov 17 13:43:30 2008
@@ -33,31 +33,37 @@
 
     /**
      * Get the maximum idle time in seconds.
+     * @return The maximum idle time
      */
     int getIdleTime();
 
     /**
      * Is active data connection enabled?
+     * @return true if active data connections are enabled
      */
     boolean isActiveEnabled();
 
     /**
      * Check the PORT IP with the client IP?
+     * @return true if the PORT IP is verified
      */
     boolean isActiveIpCheck();
 
     /**
      * Get the active data connection local host.
+     * @return The [EMAIL PROTECTED] InetAddress} for active connections
      */
     InetAddress getActiveLocalAddress();
 
     /**
      * Get the active data connection local port.
+     * @return The active data connection local port
      */
     int getActiveLocalPort();
 
     /**
      * Get passive server address. null, if not set in the configuration.
+     * @return The [EMAIL PROTECTED] InetAddress} used for passive connections
      */
     InetAddress getPassiveAddress();
 
@@ -71,7 +77,7 @@
     InetAddress getPassiveExernalAddress();
 
     /**
-     * Set the passive ports to be used for data connections. Ports can be
+     * Get the passive ports to be used for data connections. Ports can be
      * defined as single ports, closed or open ranges. Multiple definitions can
      * be separated by commas, for example:
      * <ul>
@@ -88,17 +94,20 @@
     String getPassivePorts();
 
     /**
-     * Request a passive port
+     * Request a passive port. Will block until a port is available
+     * @return A free passive part
      */
     int requestPassivePort();
 
     /**
      * Release passive port.
+     * @param port The port to be released
      */
     void releasePassivePort(int port);
 
     /**
      * Get SSL configuration for this data connection.
+     * @return The [EMAIL PROTECTED] SslConfiguration}
      */
     SslConfiguration getSslConfiguration();
 }

Modified: 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/DataConnectionConfigurationFactory.java
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/DataConnectionConfigurationFactory.java?rev=718394&r1=718393&r2=718394&view=diff
==============================================================================
--- 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/DataConnectionConfigurationFactory.java
 (original)
+++ 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/DataConnectionConfigurationFactory.java
 Mon Nov 17 13:43:30 2008
@@ -34,30 +34,6 @@
  */
 public class DataConnectionConfigurationFactory {
 
-    public void setIdleTime(int idleTime) {
-        this.idleTime = idleTime;
-    }
-
-    public void setActiveEnabled(boolean activeEnabled) {
-        this.activeEnabled = activeEnabled;
-    }
-
-    public void setActiveLocalAddress(InetAddress activeLocalAddress) {
-        this.activeLocalAddress = activeLocalAddress;
-    }
-
-    public void setActiveLocalPort(int activeLocalPort) {
-        this.activeLocalPort = activeLocalPort;
-    }
-
-    public void setActiveIpCheck(boolean activeIpCheck) {
-        this.activeIpCheck = activeIpCheck;
-    }
-
-    public void setPassiveAddress(InetAddress passiveAddress) {
-        this.passiveAddress = passiveAddress;
-    }
-
     // maximum idle time in seconds
     private int idleTime = 300;
     private SslConfiguration ssl;
@@ -71,6 +47,9 @@
     private InetAddress passiveExternalAddress;
     private PassivePorts passivePorts = new PassivePorts(new int[] { 0 });
 
+    /**
+     * Default constructor
+     */
     public DataConnectionConfigurationFactory() {
         try {
             activeLocalAddress = InetAddress.getLocalHost();
@@ -80,6 +59,11 @@
         }
     }
     
+    /**
+     * Create a [EMAIL PROTECTED] DataConnectionConfiguration} instance based 
on the 
+     * configuration on this factory
+     * @return The [EMAIL PROTECTED] DataConnectionConfiguration} instance
+     */
     public DataConnectionConfiguration createDataConnectionConfiguration() {
         return new DefaultDataConnectionConfiguration(idleTime,
                 ssl, activeEnabled, activeIpCheck,
@@ -90,53 +74,118 @@
     
     /**
      * Get the maximum idle time in seconds.
+     * @return The maximum idle time
      */
     public int getIdleTime() {
         return idleTime;
     }
 
     /**
+     * Set the maximum idle time in seconds.
+     * @param idleTime The maximum idle time
+     */
+    
+    public void setIdleTime(int idleTime) {
+        this.idleTime = idleTime;
+    }
+
+    /**
      * Is PORT enabled?
+     * @return true if active data connections are enabled
      */
     public boolean isActiveEnabled() {
         return activeEnabled;
     }
 
     /**
+     * Set if active data connections are enabled
+     * @param activeEnabled true if active data connections are enabled
+     */
+    public void setActiveEnabled(boolean activeEnabled) {
+        this.activeEnabled = activeEnabled;
+    }
+
+    /**
      * Check the PORT IP?
+     * @return true if the client IP is verified against the PORT IP
      */
     public boolean isActiveIpCheck() {
         return activeIpCheck;
     }
 
     /**
+     * Check the PORT IP with the client IP?
+     * @param activeIpCheck true if the PORT IP should be verified
+     */
+    public void setActiveIpCheck(boolean activeIpCheck) {
+        this.activeIpCheck = activeIpCheck;
+    }
+
+    /**
      * Get the local address for active mode data transfer.
+     * @return The [EMAIL PROTECTED] InetAddress} used for active data 
connections
      */
     public InetAddress getActiveLocalAddress() {
         return activeLocalAddress;
     }
 
     /**
+     * Set the active data connection local host.
+     * @param activeLocalAddress The [EMAIL PROTECTED] InetAddress} for active 
connections
+     */
+    public void setActiveLocalAddress(InetAddress activeLocalAddress) {
+        this.activeLocalAddress = activeLocalAddress;
+    }
+
+    /**
      * Get the active local port number.
+     * @return The port used for active data connections
      */
     public int getActiveLocalPort() {
         return activeLocalPort;
     }
 
     /**
+     * Set the active data connection local port.
+     * @param activeLocalPort The active data connection local port
+     */
+    public void setActiveLocalPort(int activeLocalPort) {
+        this.activeLocalPort = activeLocalPort;
+    }
+
+    /**
      * Get passive host.
+     * @return The [EMAIL PROTECTED] InetAddress} used for passive data 
connections
      */
     public InetAddress getPassiveAddress() {
         return passiveAddress;
     }
 
     /**
-     * Get external passive host.
+     * Set the passive server address. 
+     * @param passiveAddress The [EMAIL PROTECTED] InetAddress} used for 
passive connections
+     */
+    public void setPassiveAddress(InetAddress passiveAddress) {
+        this.passiveAddress = passiveAddress;
+    }
+
+    /**
+     * Get the passive address that will be returned to clients on the PASV
+     * command.
+     * 
+     * @return The passive address to be returned to clients, null if not
+     *         configured.
      */
     public InetAddress getPassiveExernalAddress() {
         return passiveExternalAddress;
     }
 
+    /**
+     * Set the passive address that will be returned to clients on the PASV
+     * command.
+     * 
+     * @param passiveExternalAddress The passive address to be returned to 
clients
+     */
     public void setPassiveExernalAddress(InetAddress passiveExternalAddress) {
         this.passiveExternalAddress = passiveExternalAddress;
     }
@@ -144,6 +193,7 @@
     /**
      * Get passive data port. Data port number zero (0) means that any 
available
      * port will be used.
+     * @return A passive port to use
      */
     public synchronized int requestPassivePort() {
         int dataPort = -1;
@@ -168,7 +218,7 @@
     }
 
     /**
-     * Retrive the passive ports configured for this data connection
+     * Retrieve the passive ports configured for this data connection
      * 
      * @return The String of passive ports
      */
@@ -176,6 +226,21 @@
         return passivePorts.toString();
     }
 
+    /**
+     * Set the passive ports to be used for data connections. Ports can be
+     * defined as single ports, closed or open ranges. Multiple definitions can
+     * be separated by commas, for example:
+     * <ul>
+     * <li>2300 : only use port 2300 as the passive port</li>
+     * <li>2300-2399 : use all ports in the range</li>
+     * <li>2300- : use all ports larger than 2300</li>
+     * <li>2300, 2305, 2400- : use 2300 or 2305 or any port larger than 
2400</li>
+     * </ul>
+     * 
+     * Defaults to using any available port
+     * 
+     * @param passivePorts The passive ports string
+     */
     public void setPassivePorts(String passivePorts) {
         this.passivePorts = new PassivePorts(passivePorts);
     }
@@ -183,6 +248,7 @@
     
     /**
      * Release data port
+     * @param port The port to release
      */
     public synchronized void releasePassivePort(final int port) {
         passivePorts.releasePort(port);
@@ -191,12 +257,17 @@
     }
 
     /**
-     * Get SSL component.
+     * Get the [EMAIL PROTECTED] SslConfiguration} to be used by data 
connections
+     * @return The [EMAIL PROTECTED] SslConfiguration} used by data connections
      */
     public SslConfiguration getSslConfiguration() {
         return ssl;
     }
-    
+
+    /**
+     * Set the [EMAIL PROTECTED] SslConfiguration} to be used by data 
connections
+     * @param ssl The [EMAIL PROTECTED] SslConfiguration}
+     */
     public void setSslConfiguration(SslConfiguration ssl) {
         this.ssl = ssl;
     }

Modified: 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/NativeFileSystemFactory.java
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/NativeFileSystemFactory.java?rev=718394&r1=718393&r2=718394&view=diff
==============================================================================
--- 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/NativeFileSystemFactory.java
 (original)
+++ 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/NativeFileSystemFactory.java
 Mon Nov 17 13:43:30 2008
@@ -44,18 +44,37 @@
 
     private boolean caseInsensitive;
 
+    /**
+     * Should the home directories be created automatically
+     * @return true if the file system will create the home directory if not 
available
+     */
     public boolean isCreateHome() {
         return createHome;
     }
 
+    /**
+     * Set if the home directories be created automatically
+     * @param createHome true if the file system will create the home 
directory if not available
+     */
+
     public void setCreateHome(boolean createHome) {
         this.createHome = createHome;
     }
 
+    /**
+     * Is this file system case insensitive. 
+     * Enabling might cause problems when working against case-sensitive file 
systems, like on Linux
+     * @return true if this file system is case insensitive
+     */
     public boolean isCaseInsensitive() {
         return caseInsensitive;
     }
 
+    /**
+     * Should this file system be case insensitive. 
+     * Enabling might cause problems when working against case-sensitive file 
systems, like on Linux
+     * @param caseInsensitive true if this file system should be case 
insensitive
+     */
     public void setCaseInsensitive(boolean caseInsensitive) {
         this.caseInsensitive = caseInsensitive;
     }
@@ -79,9 +98,10 @@
                             + homeDirStr);
                 }
             }
-            
-            FileSystemView fsView = new NativeFileSystemView(user, 
caseInsensitive);
-            return fsView;            
+
+            FileSystemView fsView = new NativeFileSystemView(user,
+                    caseInsensitive);
+            return fsView;
         }
     }
 

Modified: 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/message/MessageResourceFactory.java
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/message/MessageResourceFactory.java?rev=718394&r1=718393&r2=718394&view=diff
==============================================================================
--- 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/message/MessageResourceFactory.java
 (original)
+++ 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/message/MessageResourceFactory.java
 Mon Nov 17 13:43:30 2008
@@ -36,22 +36,43 @@
 
     private File customMessageDirectory;
 
+    /**
+     * Create an [EMAIL PROTECTED] MessageResource} based on the configuration 
on this factory
+     * @return The [EMAIL PROTECTED] MessageResource} instance
+     */
     public MessageResource createMessageResource() {
         return new DefaultMessageResource(languages, customMessageDirectory);
     }
     
+    /**
+     * The languages for which messages are available 
+     * @return The list of available languages
+     */
     public List<String> getLanguages() {
         return languages;
     }
 
+    /**
+     * Set the languages for which messages are available 
+     * @param languages The list of available languages
+     */
+    
     public void setLanguages(List<String> languages) {
         this.languages = languages;
     }
 
+    /**
+     * The directory where custom message bundles can be located
+     * @return The [EMAIL PROTECTED] File} denoting the directory with message 
bundles
+     */
     public File getCustomMessageDirectory() {
         return customMessageDirectory;
     }
 
+    /**
+     * Set the directory where custom message bundles can be located
+     * @param customMessageDirectory The [EMAIL PROTECTED] File} denoting the 
directory with message bundles
+     */
     public void setCustomMessageDirectory(File customMessageDirectory) {
         this.customMessageDirectory = customMessageDirectory;
     }

Modified: 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java?rev=718394&r1=718393&r2=718394&view=diff
==============================================================================
--- 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
 (original)
+++ 
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
 Mon Nov 17 13:43:30 2008
@@ -210,6 +210,10 @@
         this.keyPass = keyPass;
     }
 
+    /**
+     * Get the file used to load the truststore
+     * @return The [EMAIL PROTECTED] File} containing the truststore
+     */
     public File getTruststoreFile() {
         return trustStoreFile;
     }
@@ -255,7 +259,7 @@
     /**
      * Set the trust store type
      * 
-     * @param keystoreType
+     * @param trustStoreType
      *            The trust store type
      */
     public void setTruststoreType(String trustStoreType) {
@@ -308,7 +312,9 @@
     }
 
     /**
-     * Configure secure server related properties.
+     * Create an instance of [EMAIL PROTECTED] SslConfiguration} based on the 
configuration
+     * of this factory.
+     * @return The [EMAIL PROTECTED] SslConfiguration} instance
      */
     public SslConfiguration createSslConfiguration() {
 
@@ -362,14 +368,23 @@
     }
 
     /**
-     * @see SslConfiguration#getClientAuth()
+     * Return the required client authentication setting
+     * 
+     * @return [EMAIL PROTECTED] ClientAuth#NEED} if client authentication is 
required,
+     *         [EMAIL PROTECTED] ClientAuth#WANT} is client authentication is 
wanted or
+     *         [EMAIL PROTECTED] ClientAuth#NONE} if no client authentication 
is the be
+     *         performed
      */
     public ClientAuth getClientAuth() {
         return clientAuth;
     }
 
     /**
-     * @see SslConfiguration#getEnabledCipherSuites()
+     * Returns the cipher suites that should be enabled for this connection.
+     * Must return null if the default (as decided by the JVM) cipher suites
+     * should be used.
+     * 
+     * @return An array of cipher suites, or null.
      */
     public String[] getEnabledCipherSuites() {
         if (enabledCipherSuites != null) {

Modified: 
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetContainerTestTemplate.java
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetContainerTestTemplate.java?rev=718394&r1=718393&r2=718394&view=diff
==============================================================================
--- 
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetContainerTestTemplate.java
 (original)
+++ 
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetContainerTestTemplate.java
 Mon Nov 17 13:43:30 2008
@@ -701,4 +701,69 @@
         assertEquals("ftplet1", calls.get(0));
         assertEquals("ftplet2", calls.get(1));
     }
+
+    /**
+     * First test checking the call order of Ftplets
+     */
+    public void testFtpletCallOrder1() throws FtpException, IOException {
+        MockFtplet ftplet1 = new MockFtplet() {
+            public FtpletResult onConnect(FtpSession session)
+                    throws FtpException, IOException {
+                calls.add("ftplet1");
+                return super.onConnect(session);
+            }
+        };
+        MockFtplet ftplet2 = new MockFtplet() {
+            public FtpletResult onConnect(FtpSession session)
+                    throws FtpException, IOException {
+                calls.add("ftplet2");
+                return super.onConnect(session);
+            }
+        };
+
+        Map<String, Ftplet> ftplets = new LinkedHashMap<String, Ftplet>();
+        ftplets.put("ftplet1", ftplet1);
+        ftplets.put("ftplet2", ftplet2);
+
+        FtpletContainer container = createFtpletContainer(ftplets);
+
+        container.onConnect(new DefaultFtpSession(null));
+
+        assertEquals(2, calls.size());
+        assertEquals("ftplet1", calls.get(0));
+        assertEquals("ftplet2", calls.get(1));
+    }
+
+    /**
+     * First test checking the call order of Ftplets
+     */
+    public void testFtpletCallOrder2() throws FtpException, IOException {
+        MockFtplet ftplet1 = new MockFtplet() {
+            public FtpletResult onConnect(FtpSession session)
+                    throws FtpException, IOException {
+                calls.add("ftplet1");
+                return super.onConnect(session);
+            }
+        };
+        MockFtplet ftplet2 = new MockFtplet() {
+            public FtpletResult onConnect(FtpSession session)
+                    throws FtpException, IOException {
+                calls.add("ftplet2");
+                return super.onConnect(session);
+            }
+        };
+
+        Map<String, Ftplet> ftplets = new LinkedHashMap<String, Ftplet>();
+        ftplets.put("ftplet2", ftplet2);
+        ftplets.put("ftplet1", ftplet1);
+
+        FtpletContainer container = createFtpletContainer(ftplets);
+
+        container.onConnect(new DefaultFtpSession(null));
+
+        assertEquals(2, calls.size());
+        assertEquals("ftplet2", calls.get(0));
+        assertEquals("ftplet1", calls.get(1));
+    }
+
 }


Reply via email to