camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r999783 - in /camel/trunk/components/camel-ftp/src: main/java/org/apache/camel/component/file/remote/ test/java/org/apache/camel/component/file/remote/
Date Wed, 22 Sep 2010 07:07:38 GMT
Author: davsclaus
Date: Wed Sep 22 07:07:38 2010
New Revision: 999783

URL: http://svn.apache.org/viewvc?rev=999783&view=rev
Log:
CAMEL-3144: Added unit test in camel-ftp.

Added:
    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRootFileExistFailTest.java
      - copied, changed from r999771, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistFailTest.java
Modified:
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java?rev=999783&r1=999782&r2=999783&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
Wed Sep 22 07:07:38 2010
@@ -458,15 +458,17 @@ public class FtpOperations implements Re
         if (log.isTraceEnabled()) {
             log.trace("existsFile(" + name + ")");
         }
+
         // check whether a file already exists
         String directory = FileUtil.onlyPath(name);
-        if (directory == null) {
-            return false;
-        }
-
         String onlyName = FileUtil.stripPath(name);
         try {
-            String[] names = client.listNames(directory);
+            String[] names;
+            if (directory != null) {
+                names = client.listNames(directory);
+            } else {
+                names = client.listNames();
+            }
             // can return either null or an empty list depending on FTP servers
             if (names == null) {
                 return false;

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java?rev=999783&r1=999782&r2=999783&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java
Wed Sep 22 07:07:38 2010
@@ -49,8 +49,7 @@ public class RemoteFile<T> extends Gener
         this.hostname = hostname;
     }
     
-    @Override
-    public char getFileSeparator() {
+    public static char getFileSeparator() {
         // always use / as separator for FTP
         return '/';
     }

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java?rev=999783&r1=999782&r2=999783&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
Wed Sep 22 07:07:38 2010
@@ -524,10 +524,11 @@ public class SftpOperations implements R
         // check whether a file already exists
         String directory = FileUtil.onlyPath(name);
         if (directory == null) {
-            return false;
+            // assume current dir if no path could be extracted
+            directory = "";
         }
-
         String onlyName = FileUtil.stripPath(name);
+
         try {
             Vector files = channel.ls(directory);
             // can return either null or an empty list depending on FTP servers

Copied: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRootFileExistFailTest.java
(from r999771, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistFailTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRootFileExistFailTest.java?p2=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRootFileExistFailTest.java&p1=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistFailTest.java&r1=999771&r2=999783&rev=999783&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistFailTest.java
(original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRootFileExistFailTest.java
Wed Sep 22 07:07:38 2010
@@ -27,18 +27,16 @@ import org.junit.Test;
 /**
  * @version $Revision$
  */
-public class FtpProducerFileExistFailTest extends FtpServerTestSupport {
+public class FtpProducerRootFileExistFailTest extends FtpServerTestSupport {
 
     private String getFtpUrl() {
-        return "ftp://admin@localhost:" + getPort() + "/exist?password=admin&delay=2000&noop=true&fileExist=Fail";
+        return "ftp://admin@localhost:" + getPort() + "?password=admin&delay=2000&noop=true&fileExist=Fail";
     }
 
     @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("target/exist");
-
         template.sendBodyAndHeader(getFtpUrl(), "Hello World", Exchange.FILE_NAME, "hello.txt");
     }
 
@@ -46,14 +44,14 @@ public class FtpProducerFileExistFailTes
     public void testFail() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
-        mock.expectedFileExists(FTP_ROOT_DIR + "exist/hello.txt", "Hello World");
+        mock.expectedFileExists(FTP_ROOT_DIR + "/hello.txt", "Hello World");
 
         try {
             template.sendBodyAndHeader(getFtpUrl(), "Bye World", Exchange.FILE_NAME, "hello.txt");
             fail("Should have thrown an exception");
         } catch (CamelExecutionException e) {
             GenericFileOperationFailedException cause = assertIsInstanceOf(GenericFileOperationFailedException.class,
e.getCause());
-            assertEquals("File already exist: exist/hello.txt. Cannot write new file.", cause.getMessage());
+            assertEquals("File already exist: hello.txt. Cannot write new file.", cause.getMessage());
         }
 
         assertMockEndpointsSatisfied();



Mime
View raw message