Author: bvahdat
Date: Tue Oct 30 20:48:08 2012
New Revision: 1403863

URL: http://svn.apache.org/viewvc?rev=1403863&view=rev
Log:
Added asserts verifying the effect of the disconnect option.

Modified:
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java

Modified: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java?rev=1403863&r1=1403862&r2=1403863&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java
 Tue Oct 30 20:48:08 2012
@@ -17,6 +17,9 @@
 package org.apache.camel.component.file.remote;
 
 import org.apache.camel.builder.RouteBuilder;
+
+import org.apache.commons.net.ftp.FTPClient;
+
 import org.junit.Test;
 
 public class FtpConsumerDisconnectTest extends FtpServerTestSupport {
@@ -28,6 +31,11 @@ public class FtpConsumerDisconnectTest e
     @Override
     public void setUp() throws Exception {
         super.setUp();
+        
+        // force the singleton FtpEndpoint to make use of a custom FTPClient
+        FtpEndpoint<?> endpoint = context.getEndpoint(getFtpUrl(), 
FtpEndpoint.class);
+        endpoint.setFtpClient(new FTPClient());
+
         sendFile(getFtpUrl(), "Hello World", "claus.txt");
     }
 
@@ -46,8 +54,14 @@ public class FtpConsumerDisconnectTest e
         getMockEndpoint("mock:result").expectedMessageCount(1);
         assertMockEndpointsSatisfied();
 
-        // give time for ftp consumer to disconnect
+        // give time for ftp consumer to disconnect (delay is 5000 which is 
long enough to avoid a second poll cycle)
         Thread.sleep(2000);
+
+        FtpEndpoint<?> endpoint = context.getEndpoint(getFtpUrl(), 
FtpEndpoint.class);
+        assertTrue("The FtpEndpoint is configured to disconnect after each 
poll", endpoint.isDisconnect());
+
+        FTPClient ftpClient = endpoint.getFtpClient();
+        assertFalse("The FTPClient should not be connected", 
ftpClient.isConnected());
     }
 
 }
\ No newline at end of file


Reply via email to