Author: bvahdat Date: Wed Oct 31 18:50:59 2012 New Revision: 1404295 URL: http://svn.apache.org/viewvc?rev=1404295&view=rev Log: Merged revisions 1404291 via svnmerge from https://svn.apache.org/repos/asf/camel/trunk
........ r1404291 | bvahdat | 2012-10-31 19:46:44 +0100 (Mi, 31 Okt 2012) | 1 line Added asserts verifying the effect of the disconnect option by the ftp producer as well. Also polished a bit. ........ Modified: camel/branches/camel-2.10.x/ (props changed) camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectTest.java Propchange: camel/branches/camel-2.10.x/ ------------------------------------------------------------------------------ Merged /camel/trunk:r1404291 Propchange: camel/branches/camel-2.10.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java?rev=1404295&r1=1404294&r2=1404295&view=diff ============================================================================== --- camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java (original) +++ camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java Wed Oct 31 18:50:59 2012 @@ -17,10 +17,11 @@ 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 { - + private String getFtpUrl() { return "ftp://admin@localhost:" + getPort() + "/done?password=admin&disconnect=true&delay=5000"; } @@ -28,10 +29,11 @@ public class FtpConsumerDisconnectTest e @Override public void setUp() throws Exception { super.setUp(); - - // force the singleton FtpEndpoint to make use of a custom FTPClient + + // ask the singleton FtpEndpoint to make use of a custom FTPClient + // so that we can hold a reference on it inside the test below FtpEndpoint<?> endpoint = context.getEndpoint(getFtpUrl(), FtpEndpoint.class); - endpoint.setFtpClient(endpoint.createFtpClient()); + endpoint.setFtpClient(new FTPClient()); sendFile(getFtpUrl(), "Hello World", "claus.txt"); } @@ -51,13 +53,14 @@ public class FtpConsumerDisconnectTest e getMockEndpoint("mock:result").expectedMessageCount(1); assertMockEndpointsSatisfied(); - // give time for ftp consumer to disconnect (delay is 5000 ms which is long enough to avoid a second poll cycle) + // give time for ftp consumer to disconnect, delay is 5000 ms which is long + // enough to avoid a second poll cycle before we are done with the asserts + // below inside the main thread Thread.sleep(2000); FtpEndpoint<?> endpoint = context.getEndpoint(getFtpUrl(), FtpEndpoint.class); assertFalse("The FTPClient should be already disconnected", endpoint.getFtpClient().isConnected()); - assertTrue("The FtpEndpoint is configured to disconnect after each poll", endpoint.isDisconnect()); - + assertTrue("The FtpEndpoint should be configured to disconnect", endpoint.isDisconnect()); } } \ No newline at end of file Modified: camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectTest.java?rev=1404295&r1=1404294&r2=1404295&view=diff ============================================================================== --- camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectTest.java (original) +++ camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectTest.java Wed Oct 31 18:50:59 2012 @@ -16,10 +16,21 @@ */ package org.apache.camel.component.file.remote; +import org.apache.commons.net.ftp.FTPClient; import org.junit.Test; public class FtpProducerDisconnectTest extends FtpServerTestSupport { + @Override + public void setUp() throws Exception { + super.setUp(); + + // ask the singleton FtpEndpoint to make use of a custom FTPClient + // so that we can hold a reference on it inside the test below + FtpEndpoint<?> endpoint = context.getEndpoint(getFtpUrl(), FtpEndpoint.class); + endpoint.setFtpClient(new FTPClient()); + } + private String getFtpUrl() { return "ftp://admin@localhost:" + getPort() + "/done?password=admin&disconnect=true"; } @@ -27,6 +38,10 @@ public class FtpProducerDisconnectTest e @Test public void testDisconnectOnDone() throws Exception { sendFile(getFtpUrl(), "Hello World", "claus.txt"); + + FtpEndpoint<?> endpoint = context.getEndpoint(getFtpUrl(), FtpEndpoint.class); + assertFalse("The FTPClient should be already disconnected", endpoint.getFtpClient().isConnected()); + assertTrue("The FtpEndpoint should be configured to disconnect", endpoint.isDisconnect()); } } \ No newline at end of file