Author: davsclaus
Date: Thu Nov 12 07:38:40 2009
New Revision: 835283

URL: http://svn.apache.org/viewvc?rev=835283&view=rev
Log:
CAMEL-2160: FTP component is now much more flexible in configuration of 
FTPClient and FTPClientConfig parameters.

Added:
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java
   (with props)
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
   (with props)
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java
   (with props)
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java
   (with props)
Modified:
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConfiguration.java
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
    
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/SftpComponent.java

Modified: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java?rev=835283&r1=835282&r2=835283&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java
 Thu Nov 12 07:38:40 2009
@@ -21,6 +21,7 @@
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.component.file.GenericFileEndpoint;
+import org.apache.camel.util.IntrospectionSupport;
 import org.apache.commons.net.ftp.FTPFile;
 
 /**
@@ -39,7 +40,7 @@
     protected GenericFileEndpoint<FTPFile> buildFileEndpoint(String uri, 
String remaining, Map<String, Object> parameters) throws Exception {
         // 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)
+        // to escape the $ for the expression (file language)
         String baseUri = uri;
         if (uri.indexOf("?") != -1) {
             baseUri = uri.substring(0, uri.indexOf("?"));
@@ -49,7 +50,23 @@
         // must pass on baseUri to the configuration (see above)
         FtpConfiguration config = new FtpConfiguration(new URI(baseUri));
 
-        return new FtpEndpoint(uri, this, config);
+        FtpEndpoint answer = new FtpEndpoint(uri, this, config);
+
+        // additional client configuration options
+        if (IntrospectionSupport.hasProperties(parameters, 
"ftpClientConfig.")) {
+            Map<String, Object> param = 
IntrospectionSupport.extractProperties(parameters, "ftpClientConfig.");
+            // remember these parameters so we can use them when creating a 
client
+            answer.setFtpClientConfigParameters(param);
+        }
+
+        // additional client options
+        if (IntrospectionSupport.hasProperties(parameters, "ftpClient.")) {
+            Map<String, Object> param = 
IntrospectionSupport.extractProperties(parameters, "ftpClient.");
+            // remember these parameters so we can use them when creating a 
client
+            answer.setFtpClientParameters(param);
+        }
+
+        return answer;
     }
 
     protected void afterPropertiesSet(GenericFileEndpoint<FTPFile> endpoint) 
throws Exception {

Modified: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConfiguration.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConfiguration.java?rev=835283&r1=835282&r2=835283&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConfiguration.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConfiguration.java
 Thu Nov 12 07:38:40 2009
@@ -26,7 +26,6 @@
 public class FtpConfiguration extends RemoteFileConfiguration {
 
     public static final int DEFAULT_FTP_PORT = 21;
-    private FTPClientConfig ftpClientConfig;
 
     public FtpConfiguration() {
         setProtocol("ftp");
@@ -41,12 +40,4 @@
         setPort(DEFAULT_FTP_PORT);
     }
 
-    public FTPClientConfig getFtpClientConfig() {
-        return ftpClientConfig;
-    }
-
-    public void setFtpClientConfig(FTPClientConfig ftpClientConfig) {
-        this.ftpClientConfig = ftpClientConfig;
-    }
-
 }

Modified: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java?rev=835283&r1=835282&r2=835283&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
 Thu Nov 12 07:38:40 2009
@@ -16,8 +16,15 @@
  */
 package org.apache.camel.component.file.remote;
 
+import java.util.Map;
+
+import org.apache.camel.FailedToCreateConsumerException;
+import org.apache.camel.FailedToCreateProducerException;
 import org.apache.camel.Processor;
 import org.apache.camel.component.file.GenericFileProducer;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPClientConfig;
 import org.apache.commons.net.ftp.FTPFile;
 
 /**
@@ -25,6 +32,11 @@
  */
 public class FtpEndpoint extends RemoteFileEndpoint<FTPFile> {
 
+    private FTPClient ftpClient;
+    private FTPClientConfig ftpClientConfig;
+    private Map<String, Object> ftpClientParameters;
+    private Map<String, Object> ftpClientConfigParameters;
+
     public FtpEndpoint() {
     }
 
@@ -33,22 +45,78 @@
     }
 
     @Override
+    public String getScheme() {
+        return "ftp";
+    }
+
+    @Override
     protected RemoteFileConsumer<FTPFile> buildConsumer(Processor processor) {
-        return new FtpConsumer(this, processor, createRemoteFileOperations());
+        try {
+            return new FtpConsumer(this, processor, 
createRemoteFileOperations());
+        } catch (Exception e) {
+            throw new FailedToCreateConsumerException(this, e);
+        }
     }
 
     protected GenericFileProducer<FTPFile> buildProducer() {
-        return new RemoteFileProducer<FTPFile>(this, 
createRemoteFileOperations());
+        try {
+            return new RemoteFileProducer<FTPFile>(this, 
createRemoteFileOperations());
+        } catch (Exception e) {
+            throw new FailedToCreateProducerException(this, e);
+        }
     }
     
-    protected RemoteFileOperations<FTPFile> createRemoteFileOperations() {
-        FtpOperations operations = new FtpOperations();
+    protected RemoteFileOperations<FTPFile> createRemoteFileOperations() 
throws Exception {
+        // configure ftp client
+        FTPClient client = ftpClient;
+        if (client == null) {
+            // must use a new client if not explicit configured to use a 
custom client
+            client = new FTPClient();
+        }
+
+        if (ftpClientParameters != null) {
+            IntrospectionSupport.setProperties(client, ftpClientParameters);
+        }
+        if (ftpClientConfigParameters != null) {
+            // client config is optional so create a new one if we have 
parameter for it
+            if (ftpClientConfig == null) {
+                ftpClientConfig = new FTPClientConfig();
+            }
+            IntrospectionSupport.setProperties(ftpClientConfig, 
ftpClientConfigParameters);
+        }
+
+        FtpOperations operations = new FtpOperations(client, 
getFtpClientConfig());
         operations.setEndpoint(this);
         return operations;
     }
 
-    @Override
-    public String getScheme() {
-        return "ftp";
+    public FTPClient getFtpClient() {
+        return ftpClient;
+    }
+
+    public void setFtpClient(FTPClient ftpClient) {
+        this.ftpClient = ftpClient;
+    }
+
+    public FTPClientConfig getFtpClientConfig() {
+        return ftpClientConfig;
+    }
+
+    public void setFtpClientConfig(FTPClientConfig ftpClientConfig) {
+        this.ftpClientConfig = ftpClientConfig;
+    }
+
+    /**
+     * Used by FtpComponent to provide additional parameters for the FTPClient
+     */
+    void setFtpClientParameters(Map<String, Object> ftpClientParameters) {
+        this.ftpClientParameters = ftpClientParameters;
+    }
+
+    /**
+     * Used by FtpComponent to provide additional parameters for the 
FTPClientConfig
+     */
+    void setFtpClientConfigParameters(Map<String, Object> 
ftpClientConfigParameters) {
+        this.ftpClientConfigParameters = ftpClientConfigParameters;
     }
 }

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=835283&r1=835282&r2=835283&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
 Thu Nov 12 07:38:40 2009
@@ -38,6 +38,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPClientConfig;
 import org.apache.commons.net.ftp.FTPFile;
 import org.apache.commons.net.ftp.FTPReply;
 
@@ -47,14 +48,12 @@
 public class FtpOperations implements RemoteFileOperations<FTPFile> {
     private static final transient Log LOG = 
LogFactory.getLog(FtpOperations.class);
     private final FTPClient client;
+    private final FTPClientConfig clientConfig;
     private RemoteFileEndpoint endpoint;
 
-    public FtpOperations() {
-        this.client = new FTPClient();
-    }
-
-    public FtpOperations(FTPClient client) {
+    public FtpOperations(FTPClient client, FTPClientConfig clientConfig) {
         this.client = client;
+        this.clientConfig = clientConfig;
     }
 
     public void setEndpoint(GenericFileEndpoint endpoint) {
@@ -70,11 +69,9 @@
         int port = configuration.getPort();
         String username = configuration.getUsername();
 
-        FtpConfiguration ftpConfig = (FtpConfiguration) configuration;
-
-        if (ftpConfig.getFtpClientConfig() != null) {
-            LOG.trace("Configuring FTPClient with config: " + 
ftpConfig.getFtpClientConfig());
-            client.configure(ftpConfig.getFtpClientConfig());
+        if (clientConfig != null) {
+            LOG.trace("Configuring FTPClient with config: " + clientConfig);
+            client.configure(clientConfig);
         }
 
         if (LOG.isTraceEnabled()) {

Modified: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java?rev=835283&r1=835282&r2=835283&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java
 Thu Nov 12 07:38:40 2009
@@ -39,7 +39,7 @@
     protected GenericFileEndpoint<ChannelSftp.LsEntry> 
buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) 
throws Exception {
         // 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)
+        // to escape the $ for the expression (file language)
         String baseUri = uri;
         if (uri.indexOf("?") != -1) {
             baseUri = uri.substring(0, uri.indexOf("?"));

Added: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java?rev=835283&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java
 Thu Nov 12 07:38:40 2009
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file.remote;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.commons.net.ftp.FTPClientConfig;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class FromFtpClientConfigRefTest extends FtpServerTestSupport {
+
+    private String getFtpUrl() {
+        return "ftp://ad...@localhost:"; + getPort() + 
"/timeout/?password=admin&ftpClientConfig=#myConfig";
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+
+        FTPClientConfig config = new FTPClientConfig();
+        config.setServerLanguageCode("fr");
+        config.setLenientFutureDates(true);
+
+        jndi.bind("myConfig", config);
+        return jndi;
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        deleteDirectory(FTP_ROOT_DIR + "timeout");
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        // prepares the FTP Server by creating a file on the server
+        Endpoint endpoint = context.getEndpoint(getFtpUrl());
+        Exchange exchange = endpoint.createExchange();
+        exchange.getIn().setBody("Hello World");
+        exchange.getIn().setHeader(Exchange.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 {
+                from(getFtpUrl()).to("mock:result");
+            }
+        };
+    }
+
+    @Test
+    public void testTimeout() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+        mock.assertIsSatisfied();
+    }
+
+}
\ No newline at end of file

Propchange: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java?rev=835283&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
 Thu Nov 12 07:38:40 2009
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file.remote;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class FromFtpClientDataTimeoutTest extends FtpServerTestSupport {
+
+    private String getFtpUrl() {
+        return "ftp://ad...@localhost:"; + getPort() + 
"/timeout/?password=admin&ftpClient.dataTimeout=5000";
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        deleteDirectory(FTP_ROOT_DIR + "timeout");
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        // prepares the FTP Server by creating a file on the server
+        Endpoint endpoint = context.getEndpoint(getFtpUrl());
+        Exchange exchange = endpoint.createExchange();
+        exchange.getIn().setBody("Hello World");
+        exchange.getIn().setHeader(Exchange.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 {
+                from(getFtpUrl()).to("mock:result");
+            }
+        };
+    }
+
+    @Test
+    public void testTimeout() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+        mock.assertIsSatisfied();
+    }
+
+}
\ No newline at end of file

Propchange: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java?rev=835283&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java
 Thu Nov 12 07:38:40 2009
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file.remote;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class FromFtpServerLanguageCodeAndTimeoutTest extends 
FtpServerTestSupport {
+
+    private String getFtpUrl() {
+        return "ftp://ad...@localhost:"; + getPort()
+            + 
"/codetimeout/?password=admin&ftpClientConfig.serverLanguageCode=fr&ftpClient.dataTimeout=4000";
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        deleteDirectory(FTP_ROOT_DIR + "codetimeout");
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        // prepares the FTP Server by creating a file on the server
+        Endpoint endpoint = context.getEndpoint(getFtpUrl());
+        Exchange exchange = endpoint.createExchange();
+        exchange.getIn().setBody("Hello World");
+        exchange.getIn().setHeader(Exchange.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 {
+                from(getFtpUrl()).to("mock:result");
+            }
+        };
+    }
+
+    @Test
+    public void testLanguageCodeAndTimeout() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+        mock.assertIsSatisfied();
+    }
+
+}
\ No newline at end of file

Propchange: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java?rev=835283&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java
 Thu Nov 12 07:38:40 2009
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file.remote;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class FromFtpServerLanguageCodeTest extends FtpServerTestSupport {
+
+    private String getFtpUrl() {
+        return "ftp://ad...@localhost:"; + getPort() + 
"/code/?password=admin&ftpClientConfig.serverLanguageCode=fr";
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        deleteDirectory(FTP_ROOT_DIR + "code");
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        // prepares the FTP Server by creating a file on the server
+        Endpoint endpoint = context.getEndpoint(getFtpUrl());
+        Exchange exchange = endpoint.createExchange();
+        exchange.getIn().setBody("Hello World");
+        exchange.getIn().setHeader(Exchange.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 {
+                from(getFtpUrl()).to("mock:result");
+            }
+        };
+    }
+
+    @Test
+    public void testLanguageCode() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+        mock.assertIsSatisfied();
+    }
+
+}
\ No newline at end of file

Propchange: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date


Reply via email to