svn commit: r642719 - in /activemq/camel/trunk/components/camel-ftp/src/test: java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java resources/log4j.properties

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r642719 - in /activemq/camel/trunk/components/camel-ftp/src/test: java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java resources/log4j.properties

davsclaus-2
Author: davsclaus
Date: Sun Mar 30 05:01:12 2008
New Revision: 642719

URL: http://svn.apache.org/viewvc?rev=642719&view=rev
Log:
Added unit test to see if there is a problem in Camel according to the topic:
http://www.nabble.com/FTP-to-FILE-td16354813s22882.html

Added:
    activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java
Modified:
    activemq/camel/trunk/components/camel-ftp/src/test/resources/log4j.properties

Added: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java?rev=642719&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java (added)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java Sun Mar 30 05:01:12 2008
@@ -0,0 +1,54 @@
+package org.apache.camel.component.file.remote;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Producer;
+import org.apache.camel.Exchange;
+
+/**
+ * Unit test to verify that we can pool an ASCII file from the FTP Server and store it on a local file path
+ */
+public class FromFtpToAsciiFileTest extends FtpRouteTest {
+
+    public void testFtpRoute() throws Exception {
+        resultEndpoint.expectedMinimumMessageCount(1);
+        resultEndpoint.expectedBodiesReceived("Hello World from FTPServer");
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    protected String createFtpUrl() {
+        return "ftp://admin@localhost:" + port + "/tmp3/camel?password=admin&binary=false";
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        // prepares the FTP Server by creating a file on the server that we want to unit
+        // test that we can pool and store as a local file
+        Endpoint endpoint = context.getEndpoint(ftpUrl);
+        Exchange exchange = endpoint.createExchange();
+        exchange.getIn().setBody("Hello World from FTPServer");
+        exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
+        Producer producer = endpoint.createProducer();
+        producer.start();
+        producer.process(exchange);
+        producer.stop();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                String fileUrl = "file:target/ftptest/?append=false&noop=true";
+                from(ftpUrl).setHeader(FileComponent.HEADER_FILE_NAME, constant("deleteme.txt")).
+                        convertBodyTo(String.class).to(fileUrl).to("mock:result");
+            }
+        };
+    }
+
+}
+

Modified: activemq/camel/trunk/components/camel-ftp/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/resources/log4j.properties?rev=642719&r1=642718&r2=642719&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/resources/log4j.properties (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/resources/log4j.properties Sun Mar 30 05:01:12 2008
@@ -18,16 +18,21 @@
 #
 # The logging properties used for eclipse testing, We want to see debug output on the console.
 #
-log4j.rootLogger=WARN, out
+log4j.rootLogger=INFO, file
 
 # uncomment the following to enable camel debugging
-log4j.logger.org.apache.camel.component.file=WARN
-
-log4j.logger.org.apache.mina=WARN
-log4j.logger.org.apache.ftpserver=WARN
+log4j.logger.org.apache.camel.component.file=DEBUG
+#log4j.logger.org.apache.mina=WARN
+#log4j.logger.org.apache.ftpserver=WARN
 
 # CONSOLE appender not used by default
 log4j.appender.out=org.apache.log4j.ConsoleAppender
 log4j.appender.out.layout=org.apache.log4j.PatternLayout
 log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
 #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d %-5p %c{1} - %m %n
+log4j.appender.file.file=target/camel-ftp-test.log
\ No newline at end of file