Author: davsclaus
Date: Tue Jan 27 07:40:21 2009
New Revision: 738019

URL: http://svn.apache.org/viewvc?rev=738019&view=rev
Log:
CAMEL-1296: camel-ftp should condigure the endpoint with the full uri (caused 
by CAMEL-941).

Modified:
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileComponent.java
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMultipleDirectoriesTest.java
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java

Modified: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileComponent.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileComponent.java?rev=738019&r1=738018&r2=738019&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileComponent.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileComponent.java
 Tue Jan 27 07:40:21 2009
@@ -38,15 +38,17 @@
 
     @Override
     protected GenericFileEndpoint<FTPFile> buildFileEndpoint(String uri, 
String remaining, Map parameters) throws Exception {
-        // get the uri part before the options as they can be non URI valid 
such
-        // as the expression using $ chars
+        // get the base uri part before the options as they can be non URI 
valid such as the expression using $ chars
+        // and the URI constructor will regard $ as an illegal character and 
we dont want to enforce end users to
+        // to espace the $ for the expression (file language)
+        String baseUri = uri;
         if (uri.indexOf("?") != -1) {
-            uri = uri.substring(0, uri.indexOf("?"));
+            baseUri = uri.substring(0, uri.indexOf("?"));
         }
 
-        // lets make sure we create a new configuration as each endpoint can
-        // customize its own version
-        FtpRemoteFileConfiguration config = new FtpRemoteFileConfiguration(new 
URI(uri));
+        // lets make sure we create a new configuration as each endpoint can 
customize its own version
+        // must pass on baseUri to the configuration (see above)
+        FtpRemoteFileConfiguration config = new FtpRemoteFileConfiguration(new 
URI(baseUri));
 
         FtpRemoteFileOperations operations = new FtpRemoteFileOperations();
         return new FtpRemoteFileEndpoint(uri, this, operations, config);

Modified: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMultipleDirectoriesTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMultipleDirectoriesTest.java?rev=738019&r1=738018&r2=738019&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMultipleDirectoriesTest.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMultipleDirectoriesTest.java
 Tue Jan 27 07:40:21 2009
@@ -50,19 +50,19 @@
 
         RemoteFileExchange exchange = (RemoteFileExchange) 
mock.getExchanges().get(0);
         RemoteFile file = (RemoteFile) exchange.getGenericFile();
-        assertEquals("multidir/bye.txt", file.getAbsoluteFileName());
+        assertEquals("/multidir/bye.txt", file.getAbsoluteFileName());
         assertEquals("bye.txt", file.getRelativeFileName());
         assertEquals("bye.txt", file.getFileName());
 
         exchange = (RemoteFileExchange) mock.getExchanges().get(1);
         file = (RemoteFile) exchange.getGenericFile();
-        assertEquals("multidir/sub/hello.txt", file.getAbsoluteFileName());
+        assertEquals("/multidir/sub/hello.txt", file.getAbsoluteFileName());
         assertEquals("sub/hello.txt", file.getRelativeFileName());
         assertEquals("hello.txt", file.getFileName());
 
         exchange = (RemoteFileExchange) mock.getExchanges().get(2);
         file = (RemoteFile) exchange.getGenericFile();
-        assertEquals("multidir/sub/sub2/godday.txt", 
file.getAbsoluteFileName());
+        assertEquals("/multidir/sub/sub2/godday.txt", 
file.getAbsoluteFileName());
         assertEquals("sub/sub2/godday.txt", file.getRelativeFileName());
         assertEquals("godday.txt", file.getFileName());
     }

Modified: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java?rev=738019&r1=738018&r2=738019&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java
 Tue Jan 27 07:40:21 2009
@@ -40,7 +40,7 @@
         assertNull(config.getUsername());
         assertNull(config.getPassword());
         assertEquals(false, config.isBinary());
-        assertEquals(true, config.isDirectory());
+        assertEquals(true, ftpEndpoint.isDirectory());
     }
 
     public void testSftpConfigurationDefaults() {
@@ -55,7 +55,7 @@
         assertNull(config.getUsername());
         assertNull(config.getPassword());
         assertEquals(false, config.isBinary());
-        assertEquals(true, config.isDirectory());
+        assertEquals(true, sftpEndpoint.isDirectory());
     }
 
     public void testFtpExplicitConfiguration() {
@@ -70,7 +70,7 @@
         assertEquals("user", config.getUsername());
         assertEquals("secret", config.getPassword());
         assertEquals(true, config.isBinary());
-        assertEquals(false, config.isDirectory());
+        assertEquals(false, ftpEndpoint.isDirectory());
     }
 
     public void testSftpExplicitConfiguration() {
@@ -85,18 +85,18 @@
         assertEquals("user", config.getUsername());
         assertEquals("secret", config.getPassword());
         assertEquals(true, config.isBinary());
-        assertEquals(false, config.isDirectory());
+        assertEquals(false, sftpEndpoint.isDirectory());
     }
 
     public void testRemoteFileEndpointFiles() {
-        assertRemoteFileEndpointFile("ftp://hostname/foo/bar";, "foo/bar");
-        assertRemoteFileEndpointFile("ftp://hostname/foo/";, "foo/");
-        assertRemoteFileEndpointFile("ftp://hostname/foo";, "foo");
-        assertRemoteFileEndpointFile("ftp://hostname/";, "");
+        assertRemoteFileEndpointFile("ftp://hostname/foo/bar";, "/foo/bar");
+        assertRemoteFileEndpointFile("ftp://hostname/foo/";, "/foo/");
+        assertRemoteFileEndpointFile("ftp://hostname/foo";, "/foo");
+        assertRemoteFileEndpointFile("ftp://hostname/";, "/");
         assertRemoteFileEndpointFile("ftp://hostname";, "");
-        assertRemoteFileEndpointFile("ftp://hostname//";, "/");
-        assertRemoteFileEndpointFile("ftp://hostname//foo/bar";, "/foo/bar");
-        
assertRemoteFileEndpointFile("sftp://u...@hostname:123//foo/bar?password=secret";,
 "/foo/bar");
+        assertRemoteFileEndpointFile("ftp://hostname//";, "//");
+        assertRemoteFileEndpointFile("ftp://hostname//foo/bar";, "//foo/bar");
+        
assertRemoteFileEndpointFile("sftp://u...@hostname:123//foo/bar?password=secret";,
 "//foo/bar");
     }
 
     private void assertRemoteFileEndpointFile(String endpointUri, String 
expectedFile) {
@@ -119,7 +119,7 @@
         assertEquals("user", config.getUsername());
         assertEquals("secret", config.getPassword());
         assertEquals(true, config.isBinary());
-        assertEquals(false, config.isDirectory());
+        assertEquals(false, sftpEndpoint.isDirectory());
         assertEquals("/home/janstey/.ssh/known_hosts", 
config.getKnownHostsFile());
     }
 }


Reply via email to