camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r737677 [2/2] - in /camel/trunk/components/camel-ftp/src: main/java/org/apache/camel/component/file/remote/ main/java/org/apache/camel/component/file/remote/strategy/ main/resources/META-INF/services/org/apache/camel/component/ test/java/or...
Date Mon, 26 Jan 2009 11:52:07 GMT
Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java (original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java Mon Jan 26 11:52:06 2009
@@ -17,179 +17,68 @@
 package org.apache.camel.component.file.remote;
 
 import java.io.IOException;
-import java.io.InputStream;
 
 import org.apache.camel.Exchange;
-import org.apache.camel.Expression;
-import org.apache.camel.component.file.FileComponent;
-import org.apache.camel.impl.DefaultProducer;
-import org.apache.camel.language.simple.FileLanguage;
+import org.apache.camel.component.file.GenericFileExchange;
+import org.apache.camel.component.file.GenericFileOperationFailedException;
+import org.apache.camel.component.file.GenericFileProducer;
 import org.apache.camel.util.ExchangeHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
- * Remote file producer
+ * Remote file producer. Handles connecting and disconnecting if we are not.
+ * Generic type F is the remote system implementation of a file.
  */
-public class RemoteFileProducer extends DefaultProducer {
-    private static final transient Log LOG = LogFactory.getLog(RemoteFileProducer.class);
-    private RemoteFileEndpoint endpoint;
-    private RemoteFileOperations operations;
+public class RemoteFileProducer<F> extends GenericFileProducer<F> {
+
     private boolean loggedIn;
 
-    protected RemoteFileProducer(RemoteFileEndpoint endpoint, RemoteFileOperations operations) {
-        super(endpoint);
-        this.endpoint = endpoint;
-        this.operations = operations;
+    protected RemoteFileProducer(RemoteFileEndpoint<F> endpoint, RemoteFileOperations<F> operations) {
+        super(endpoint, operations);
     }
 
     public void process(Exchange exchange) throws Exception {
-        RemoteFileExchange remoteExchange = (RemoteFileExchange) endpoint.createExchange(exchange);
+        GenericFileExchange remoteExchange = (GenericFileExchange) getEndpoint().createExchange(exchange);
         processExchange(remoteExchange);
         ExchangeHelper.copyResults(exchange, remoteExchange);
     }
 
-    protected void processExchange(RemoteFileExchange exchange) throws Exception {
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("Processing " + exchange);
-        }
-
-        try {
-            connectIfNecessary();
-
-            if (!loggedIn) {
-                // must be logged in to be able to upload the file
-                String message = "Could not connect/login to: " + endpoint.remoteServerInformation();
-                throw new RemoteFileOperationFailedException(message);
-            }
-
-            String target = createFileName(exchange);
-
-            // should we write to a temporary name and then afterwards rename to real target
-            boolean writeAsTempAndRename = ObjectHelper.isNotEmpty(endpoint.getTempPrefix());
-            String tempTarget = null;
-            if (writeAsTempAndRename) {
-                // compute temporary name with the temp prefix
-                tempTarget = createTempFileName(target);
-            }
-
-            // upload the file
-            writeFile(exchange, tempTarget != null ? tempTarget : target);
-
-            // if we did write to a temporary name then rename it to the real name after we have written the file
-            if (tempTarget != null) {
-                if (LOG.isTraceEnabled()) {
-                    LOG.trace("Renaming file: " + tempTarget + " to: " + target);
-                }
-                boolean renamed = operations.renameFile(tempTarget, target);
-                if (!renamed) {
-                    throw new RemoteFileOperationFailedException("Cannot rename file from: " + tempTarget + " to: " + target);
-                }
-            }
-
-            // lets store the name we really used in the header, so end-users can retrieve it
-            exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME_PRODUCED, target);
-
-        } catch (Exception e) {
-            loggedIn = false;
-            if (isStopping() || isStopped()) {
-                // if we are stopping then ignore any exception during a poll
-                LOG.debug("Exception occurd during stopping. " + e.getMessage());
-            } else {
-                LOG.debug("Exception occurd during processing.", e);
-                disconnect();
-                // Rethrow to signify that we didn't poll
-                throw e;
-            }
-        }
-    }
-
-    protected void writeFile(Exchange exchange, String fileName) throws RemoteFileOperationFailedException, IOException {
-        InputStream payload = exchange.getIn().getBody(InputStream.class);
-        try {
-            // build directory
-            int lastPathIndex = fileName.lastIndexOf('/');
-            if (lastPathIndex != -1) {
-                String directory = fileName.substring(0, lastPathIndex);
-                if (!operations.buildDirectory(directory)) {
-                    LOG.warn("Couldn't build directory: " + directory + " (could be because of denied permissions)");
-                }
-            }
-
-            // upload
-            if (LOG.isTraceEnabled()) {
-                LOG.trace("About to send: " + fileName + " to: " + remoteServer() + " from exchange: " + exchange);
-            }
-
-            boolean success = operations.storeFile(fileName, payload);
-            if (!success) {
-                throw new RemoteFileOperationFailedException("Error sending file: " + fileName + " to: " + remoteServer());
-            }
-
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Sent: " + fileName + " to: " + remoteServer());
-            }
-        } finally {
-            ObjectHelper.close(payload, "Closing payload", LOG);
+    /**
+     * The file could not be written. We need to disconnect from the remote server.
+     */
+    protected void handleFailedWrite(GenericFileExchange exchange, Exception exception) throws Exception {
+        loggedIn = false;
+        if (isStopping() || isStopped()) {
+            // if we are stopping then ignore any exception during a poll
+            log.debug("Exception occured during stopping. " + exception.getMessage());
+        } else {
+            log.debug("Exception occured during processing.", exception);
+            disconnect();
+            // Rethrow to signify that we didn't poll
+            throw exception;
         }
     }
 
-    protected String createFileName(Exchange exchange) {
-        String answer;
-
-        String name = exchange.getIn().getHeader(FileComponent.HEADER_FILE_NAME, String.class);
-
-        // expression support
-        Expression expression = endpoint.getExpression();
-        if (name != null) {
-            // the header name can be an expression too, that should override whatever configured on the endpoint
-            if (name.indexOf("${") > -1) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug(FileComponent.HEADER_FILE_NAME + " contains a FileLanguage expression: " + name);
-                }
-                expression = FileLanguage.file(name);
-            }
-        }
-        if (expression != null) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Filename evaluated as expression: " + expression);
-            }
-            Object result = expression.evaluate(exchange);
-            name = exchange.getContext().getTypeConverter().convertTo(String.class, result);
-        }
-
-        String endpointFile = endpoint.getConfiguration().getFile();
-        if (endpoint.getConfiguration().isDirectory()) {
-            // If the path isn't empty, we need to add a trailing / if it isn't already there
-            String baseDir = "";
-            if (endpointFile.length() > 0) {
-                baseDir = endpointFile + (endpointFile.endsWith("/") ? "" : "/");
-            }
-            String fileName = (name != null) ? name : endpoint.getGeneratedFileName(exchange.getIn());
-            answer = baseDir + fileName;
-        } else {
-            answer = endpointFile;
+    public void disconnect() throws IOException {
+        loggedIn = false;
+        if (log.isDebugEnabled()) {
+            log.debug("Disconnecting from " + getEndpoint());
         }
-
-        return answer;
+        ((RemoteFileOperations) getOperations()).disconnect();
     }
 
-    protected String createTempFileName(String fileName) {
-        int path = fileName.lastIndexOf("/");
-        if (path == -1) {
-            // no path
-            return endpoint.getTempPrefix() + fileName;
-        } else {
-            StringBuilder sb = new StringBuilder(fileName);
-            sb.insert(path + 1, endpoint.getTempPrefix());
-            return sb.toString();
+    @Override
+    protected void preWriteCheck() throws Exception {
+        connectIfNecessary();
+        if (!loggedIn) {
+            // must be logged in to be able to upload the file
+            String message = "Could not connect/login to: " + ((RemoteFileEndpoint) getEndpoint()).remoteServerInformation();
+            throw new GenericFileOperationFailedException(message);
         }
     }
 
     @Override
     protected void doStart() throws Exception {
-        LOG.debug("Starting");
+        log.debug("Starting");
         // do not connect when component starts, just wait until we process as we will
         // connect at that time if needed
         super.doStart();
@@ -197,38 +86,27 @@
 
     @Override
     protected void doStop() throws Exception {
-        LOG.debug("Stopping");
         try {
             disconnect();
         } catch (Exception e) {
-            // ignore by logging it
-            LOG.debug("Exception occured during disconnecting from " + remoteServer() + " " + e.getMessage());
+            log.debug("Exception occured during disconnecting from " + getEndpoint() + " " + e.getMessage());
         }
         super.doStop();
     }
 
     protected void connectIfNecessary() throws IOException {
-        if (!operations.isConnected() || !loggedIn) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Not connected/logged in, connecting to " + remoteServer());
-            }
-            loggedIn = operations.connect(endpoint.getConfiguration());
+        if (!((RemoteFileOperations) getOperations()).isConnected() || !loggedIn) {
+            if (log.isDebugEnabled()) {
+                log.debug("Not connected/logged in, connecting to " + getEndpoint());
+            }
+            RemoteFileOperations rfo = (RemoteFileOperations) getOperations();
+            RemoteFileConfiguration conf = (RemoteFileConfiguration) getGenericFileEndpoint().getConfiguration();
+            loggedIn = rfo.connect(conf);
             if (!loggedIn) {
                 return;
             }
-            LOG.info("Connected and logged in to " + remoteServer());
+            log.info("Connected and logged in to " + getEndpoint());
         }
     }
 
-    public void disconnect() throws IOException {
-        loggedIn = false;
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Disconnecting from " + remoteServer());
-        }
-        operations.disconnect();
-    }
-
-    protected String remoteServer() {
-        return endpoint.remoteServerInformation();
-    }
 }

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java (original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java Mon Jan 26 11:52:06 2009
@@ -20,18 +20,19 @@
 
 import com.jcraft.jsch.ChannelSftp;
 import org.apache.camel.Processor;
+import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.util.ObjectHelper;
 
 /**
  * SFTP consumer
  */
-public class SftpConsumer extends RemoteFileConsumer {
+public class SftpConsumer extends RemoteFileConsumer<ChannelSftp.LsEntry> {
 
     public SftpConsumer(RemoteFileEndpoint endpoint, Processor processor, RemoteFileOperations operations) {
         super(endpoint, processor, operations);
     }
 
-    protected void pollDirectory(String fileName, List<RemoteFile> fileList) {
+    protected void pollDirectory(String fileName, List<GenericFile<ChannelSftp.LsEntry>> fileList) {
         if (fileName == null) {
             return;
         }
@@ -53,8 +54,8 @@
                     String directory = fileName + "/" + file.getFilename();
                     pollDirectory(directory, fileList);
                 }
-            // we cannot use file.getAttrs().isLink on Windows, so we dont invoke the method
-            // just assuming its a file we should poll
+                // we cannot use file.getAttrs().isLink on Windows, so we dont invoke the method
+                // just assuming its a file we should poll
             } else {
                 if (isValidFile(remote, false)) {
                     // matched file so add
@@ -67,10 +68,10 @@
     /**
      * Polls the given file
      *
-     * @param fileName  the file name
-     * @param fileList  current list of files gathered
+     * @param fileName the file name
+     * @param fileList current list of files gathered
      */
-    protected void pollFile(String fileName, List<RemoteFile> fileList) {
+    protected void pollFile(String fileName, List<GenericFile<ChannelSftp.LsEntry>> fileList) {
         String directory = ".";
         int index = fileName.lastIndexOf("/");
         if (index > -1) {
@@ -94,9 +95,9 @@
         remote.setFileName(file.getFilename());
         remote.setFileLength(file.getAttrs().getSize());
         remote.setLastModified(file.getAttrs().getMTime() * 1000L);
-        remote.setHostname(endpoint.getConfiguration().getHost());
+        remote.setHostname(((RemoteFileConfiguration) endpoint.getConfiguration()).getHost());
         String absoluteFileName = (ObjectHelper.isNotEmpty(directory) ? directory + "/" : "") + file.getFilename();
-        remote.setAbsolutelFileName(absoluteFileName);
+        remote.setAbsoluteFileName(absoluteFileName);
 
         // the relative filename
         String ftpBasePath = endpoint.getConfiguration().getFile();

Added: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileComponent.java?rev=737677&view=auto
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileComponent.java (added)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileComponent.java Mon Jan 26 11:52:06 2009
@@ -0,0 +1,56 @@
+/**
+ * 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 java.net.URI;
+import java.util.Map;
+
+import com.jcraft.jsch.ChannelSftp;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.file.GenericFileEndpoint;
+
+/**
+ * SFTP Remote File Component
+ */
+public class SftpRemoteFileComponent extends RemoteFileComponent<ChannelSftp.LsEntry> {
+
+    public SftpRemoteFileComponent() {
+        super();
+    }
+
+    public SftpRemoteFileComponent(CamelContext context) {
+        super(context);
+    }
+
+    @Override
+    protected GenericFileEndpoint<ChannelSftp.LsEntry> 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
+        if (uri.indexOf("?") != -1) {
+            uri = uri.substring(0, uri.indexOf("?"));
+        }
+
+        // lets make sure we create a new configuration as each endpoint can
+        // customize its own version
+        SftpRemoteFileConfiguration config = new SftpRemoteFileConfiguration(new URI(uri));
+
+        SftpRemoteFileOperations operations = new SftpRemoteFileOperations();
+        return new SftpRemoteFileEndpoint(uri, this, operations, config);
+    }
+}
+

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

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

Added: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileConfiguration.java?rev=737677&view=auto
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileConfiguration.java (added)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileConfiguration.java Mon Jan 26 11:52:06 2009
@@ -0,0 +1,37 @@
+/**
+ * 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 java.net.URI;
+
+public class SftpRemoteFileConfiguration extends RemoteFileConfiguration {
+
+    public static final int DEFAULT_SFTP_PORT = 22;
+
+    public SftpRemoteFileConfiguration() {
+    }
+
+    public SftpRemoteFileConfiguration(URI uri) {
+        super(uri);
+    }
+
+    @Override
+    protected void setDefaultPort() {
+        setPort(DEFAULT_SFTP_PORT);
+    }
+
+}

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

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

Added: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileEndpoint.java?rev=737677&view=auto
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileEndpoint.java (added)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileEndpoint.java Mon Jan 26 11:52:06 2009
@@ -0,0 +1,39 @@
+/**
+ * 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 com.jcraft.jsch.ChannelSftp;
+import org.apache.camel.Processor;
+
+
+public class SftpRemoteFileEndpoint extends RemoteFileEndpoint<ChannelSftp.LsEntry> {
+
+    public SftpRemoteFileEndpoint(String uri, SftpRemoteFileComponent component, RemoteFileOperations<ChannelSftp.LsEntry> operations,
+                                  RemoteFileConfiguration configuration) {
+        super(uri, component, operations, configuration);
+    }
+
+    @Override
+    protected RemoteFileConsumer buildConsumer(Processor processor, RemoteFileOperations operations) {
+        return new SftpConsumer(this, processor, operations);
+    }
+
+    @Override
+    public String getScheme() {
+        return "sftp";
+    }
+}

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

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

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileOperations.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileOperations.java (original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileOperations.java Mon Jan 26 11:52:06 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.file.remote;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -29,6 +30,9 @@
 import com.jcraft.jsch.Session;
 import com.jcraft.jsch.SftpException;
 import com.jcraft.jsch.UserInfo;
+import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.component.file.GenericFileExchange;
+import org.apache.camel.component.file.GenericFileOperationFailedException;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -37,12 +41,12 @@
 /**
  * SFTP remote file operations
  */
-public class SftpRemoteFileOperations implements RemoteFileOperations<ChannelSftp> {
+public class SftpRemoteFileOperations implements RemoteFileOperations<ChannelSftp.LsEntry> {
     private static final Log LOG = LogFactory.getLog(SftpRemoteFileOperations.class);
     private ChannelSftp channel;
     private Session session;
 
-    public boolean connect(RemoteFileConfiguration configuration) throws RemoteFileOperationFailedException {
+    public boolean connect(RemoteFileConfiguration configuration) throws GenericFileOperationFailedException {
         try {
             if (isConnected()) {
                 // already connected
@@ -114,11 +118,11 @@
         return session;
     }
 
-    public boolean isConnected() throws RemoteFileOperationFailedException {
+    public boolean isConnected() throws GenericFileOperationFailedException {
         return session != null && session.isConnected() && channel != null && channel.isConnected();
     }
 
-    public void disconnect() throws RemoteFileOperationFailedException {
+    public void disconnect() throws GenericFileOperationFailedException {
         if (session != null && session.isConnected()) {
             session.disconnect();
         }
@@ -127,7 +131,7 @@
         }
     }
 
-    public boolean deleteFile(String name) throws RemoteFileOperationFailedException {
+    public boolean deleteFile(String name) throws GenericFileOperationFailedException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("Deleteing file: " + name);
         }
@@ -139,7 +143,7 @@
         }
     }
 
-    public boolean renameFile(String from, String to) throws RemoteFileOperationFailedException {
+    public boolean renameFile(String from, String to) throws GenericFileOperationFailedException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("Renaming file: " + from + " to: " + to);
         }
@@ -151,7 +155,7 @@
         }
     }
 
-    public boolean buildDirectory(String dirName) throws RemoteFileOperationFailedException {
+    public boolean buildDirectory(String dirName) throws GenericFileOperationFailedException {
         boolean success = false;
 
         String originalDirectory = getCurrentDirectory();
@@ -215,25 +219,7 @@
         return success;
     }
 
-    public boolean retrieveFile(String name, OutputStream out) throws RemoteFileOperationFailedException {
-        try {
-            channel.get(name, out);
-        } catch (SftpException e) {
-            throw new RemoteFileOperationFailedException("Cannot get file: " + name, e);
-        }
-        return true;
-    }
-
-    public boolean storeFile(String name, InputStream body) throws RemoteFileOperationFailedException {
-        try {
-            channel.put(body, name);
-        } catch (SftpException e) {
-            throw new RemoteFileOperationFailedException("Cannot put file: " + name, e);
-        }
-        return true;
-    }
-
-    public String getCurrentDirectory() throws RemoteFileOperationFailedException {
+    public String getCurrentDirectory() throws GenericFileOperationFailedException {
         try {
             return channel.pwd();
         } catch (SftpException e) {
@@ -241,7 +227,7 @@
         }
     }
 
-    public void changeCurrentDirectory(String path) throws RemoteFileOperationFailedException {
+    public void changeCurrentDirectory(String path) throws GenericFileOperationFailedException {
         try {
             channel.cd(path);
         } catch (SftpException e) {
@@ -249,16 +235,16 @@
         }
     }
 
-    public List listFiles() throws RemoteFileOperationFailedException {
+    public List listFiles() throws GenericFileOperationFailedException {
         return listFiles(".");
     }
 
-    public List listFiles(String path) throws RemoteFileOperationFailedException {
+    public List listFiles(String path) throws GenericFileOperationFailedException {
         if (ObjectHelper.isEmpty(path)) {
             // list current dirctory if file path is not given
             path = ".";
         }
-        
+
         try {
             final List list = new ArrayList();
             Vector files = channel.ls(path);
@@ -271,4 +257,25 @@
         }
     }
 
+    public boolean retrieveFile(String name, GenericFileExchange<ChannelSftp.LsEntry> exchange) throws GenericFileOperationFailedException {
+        try {
+            GenericFile<ChannelSftp.LsEntry> target = exchange.getGenericFile();
+            OutputStream os = new ByteArrayOutputStream();
+            target.setBody(os);
+            channel.get(name, os);
+            return true;
+        } catch (SftpException e) {
+            throw new RemoteFileOperationFailedException("Could not retrieve the file [" + name + "]", e);
+        }
+    }
+
+    public boolean storeFile(String name, GenericFileExchange<ChannelSftp.LsEntry> exchange) throws GenericFileOperationFailedException {
+        try {
+            channel.put((InputStream) exchange.getIn().getBody(InputStream.class), name);
+            return true;
+        } catch (SftpException e) {
+            throw new RemoteFileOperationFailedException("Could not write the file [" + name + "]", e);
+        }
+    }
+
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftp
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftp?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftp (original)
+++ camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftp Mon Jan 26 11:52:06 2009
@@ -15,5 +15,5 @@
 # limitations under the License.
 #
 
-class=org.apache.camel.component.file.remote.RemoteFileComponent
-strategy.factory.class=org.apache.camel.component.file.remote.strategy.RemoteFileProcessStrategyFactory
+class=org.apache.camel.component.file.remote.FtpRemoteFileComponent
+strategy.factory.class=org.apache.camel.component.file.strategy.GenericFileProcessStrategyFactory

Modified: camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/sftp
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/sftp?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/sftp (original)
+++ camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/sftp Mon Jan 26 11:52:06 2009
@@ -15,5 +15,5 @@
 # limitations under the License.
 #
 
-class=org.apache.camel.component.file.remote.RemoteFileComponent
+class=org.apache.camel.component.file.remote.SftpRemoteFileComponent
 strategy.factory.class=org.apache.camel.component.file.remote.strategy.RemoteFileProcessStrategyFactory

Added: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDefaultRootRenameStrategyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDefaultRootRenameStrategyTest.java?rev=737677&view=auto
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDefaultRootRenameStrategyTest.java (added)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDefaultRootRenameStrategyTest.java Mon Jan 26 11:52:06 2009
@@ -0,0 +1,94 @@
+/**
+ * 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 java.io.File;
+
+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.file.FileComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.IOConverter;
+
+/**
+ * @version $Revision$
+ */
+public class FromFileToFtpDefaultRootRenameStrategyTest extends FtpServerTestSupport {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    /*
+     * This is our poll we want to test (no folder specified). Uses the rename strategy
+     */
+    private String getFtpPollingUrl() {
+        return "ftp://admin@localhost:" + getPort() + "?password=admin&delete=true&binary=true&delay=1000&initialDelay=1500&readLock=rename";
+    }
+
+    /*
+     * we use this URL to write out our binary test file to begin with
+     */
+    private String getFtpUrl() {
+        return "ftp://admin@localhost:" + getPort() + "?password=admin&binary=true";
+    }
+
+    public void testFromFileToFtp() throws Exception {
+        File expectedOnFtpServer = new File(FTP_ROOT_DIR + "logo.jpeg");
+        // the poller won't start for 1.5 seconds, so we check to make sure the file
+        // is there first check 1 - is the file there (default root location)
+        assertTrue(expectedOnFtpServer.exists());
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+
+        // give our poller chance to collect the file
+        Thread.sleep(500);
+
+        assertMockEndpointsSatisfied();
+
+        // give our mock a chance to delete chance to del the file
+        Thread.sleep(500);
+
+        // assert the file is NOT there now
+        assertTrue(!expectedOnFtpServer.exists());
+    }
+
+    private void prepareFtpServer() throws Exception {
+        // create a binary file .. uploaded to the default root location
+        Endpoint endpoint = context.getEndpoint(getFtpUrl());
+        Exchange exchange = endpoint.createExchange();
+        exchange.getIn().setBody(IOConverter.toFile("src/test/data/ftpbinarytest/logo.jpeg"));
+        exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "logo.jpeg");
+        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(getFtpPollingUrl()).to("mock:result");
+            }
+        };
+    }
+
+}

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

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

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java Mon Jan 26 11:52:06 2009
@@ -53,7 +53,7 @@
         producer.stop();
 
         // assert file is created
-        File file = new File("./res/home/deletefile/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "deletefile/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should exists", file.exists());
     }
@@ -68,7 +68,7 @@
         Thread.sleep(500);
 
         // assert the file is deleted
-        File file = new File("./res/home/deletefile/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "deletefile/hello.txt");
         file = file.getAbsoluteFile();
         assertFalse("The file should have been deleted", file.exists());
     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java Mon Jan 26 11:52:06 2009
@@ -55,8 +55,8 @@
         });
         context.start();
 
-        deleteDirectory("./res/home");
-        createDirectory("./res/home/slowfile");
+        deleteDirectory(FTP_ROOT_DIR);
+        createDirectory(FTP_ROOT_DIR + "slowfile");
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
 
@@ -76,7 +76,7 @@
 
         public void process(Exchange exchange) throws Exception {
             LOG.info("Creating a slow file ...");
-            File file = new File("./res/home/slowfile/hello.txt");
+            File file = new File(FTP_ROOT_DIR + "slowfile/hello.txt");
             FileOutputStream fos = new FileOutputStream(file);
             FileLock lock = fos.getChannel().lock();
             fos.write("Hello World".getBytes());

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadRenameStrategyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadRenameStrategyTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadRenameStrategyTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadRenameStrategyTest.java Mon Jan 26 11:52:06 2009
@@ -58,8 +58,8 @@
         });
         context.start();
 
-        deleteDirectory("./res/home");
-        createDirectory("./res/home/slowfile");
+        deleteDirectory(FTP_ROOT_DIR);
+        createDirectory(FTP_ROOT_DIR + "slowfile");
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
         mock.expectedBodiesReceived("Hello WorldLine #0Line #1Line #2Bye World");
@@ -86,8 +86,8 @@
         });
         context.start();
 
-        deleteDirectory("./res/home");
-        createDirectory("./res/home/slowfile");
+        deleteDirectory(FTP_ROOT_DIR);
+        createDirectory(FTP_ROOT_DIR + "slowfile");
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(0);
         mock.setMinimumResultWaitTime(2000);
@@ -104,7 +104,7 @@
 
         public void process(Exchange exchange) throws Exception {
             LOG.info("Creating a slow file ...");
-            File file = new File("./res/home/slowfile/hello.txt");
+            File file = new File(FTP_ROOT_DIR + "slowfile/hello.txt");
             FileOutputStream fos = new FileOutputStream(file);
             FileLock lock = fos.getChannel().lock();
             fos.write("Hello World".getBytes());

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java Mon Jan 26 11:52:06 2009
@@ -18,6 +18,8 @@
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.component.file.GenericFileFilter;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
 
@@ -71,8 +73,8 @@
     }
 
     // START SNIPPET: e1
-    public class MyFileFilter implements RemoteFileFilter {
-        public boolean accept(RemoteFile file) {
+    public class MyFileFilter implements GenericFileFilter {
+        public boolean accept(GenericFile file) {
             // we dont accept any files starting with skip in the name
             return !file.getFileName().startsWith("skip");
         }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java Mon Jan 26 11:52:06 2009
@@ -32,13 +32,13 @@
 
     private String getFtpUrl() {
         return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false"
-            + "&moveNamePostfix=.old&consumer.delay=5000";
+                + "&moveNamePostfix=.old&consumer.delay=5000";
     }
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/movefile");
+        deleteDirectory(FTP_ROOT_DIR + "movefile");
         prepareFtpServer();
     }
 
@@ -55,7 +55,7 @@
         producer.stop();
 
         // assert file is created
-        File file = new File("./res/home/movefile/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "movefile/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should exists", file.exists());
     }
@@ -71,7 +71,7 @@
         Thread.sleep(1000);
 
         // assert the file is moved
-        File file = new File("./res/home/movefile/hello.txt.old");
+        File file = new File(FTP_ROOT_DIR + "movefile/hello.txt.old");
         file = file.getAbsoluteFile();
         assertTrue("The file should have been moved", file.exists());
     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java Mon Jan 26 11:52:06 2009
@@ -38,7 +38,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/movefile");
+        deleteDirectory(FTP_ROOT_DIR + "movefile");
         prepareFtpServer();
     }
 
@@ -55,7 +55,7 @@
         producer.stop();
 
         // assert file is created
-        File file = new File("./res/home/movefile/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "movefile/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should exists", file.exists());
     }
@@ -71,7 +71,7 @@
         Thread.sleep(1000);
 
         // assert the file is deleted
-        File file = new File("./res/home/movefile/done/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "movefile/done/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should have been moved", file.exists());
     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java Mon Jan 26 11:52:06 2009
@@ -38,7 +38,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/movefile");
+        deleteDirectory(FTP_ROOT_DIR + "movefile");
         prepareFtpServer();
     }
 
@@ -55,7 +55,7 @@
         producer.stop();
 
         // assert file is created
-        File file = new File("./res/home/movefile/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "movefile/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should exists", file.exists());
     }
@@ -71,7 +71,7 @@
         Thread.sleep(1000);
 
         // assert the file is deleted
-        File file = new File("./res/home/movefile/done/sub2/hello.txt.old");
+        File file = new File(FTP_ROOT_DIR + "movefile/done/sub2/hello.txt.old");
         file = file.getAbsoluteFile();
         assertTrue("The file should have been moved", file.exists());
     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java Mon Jan 26 11:52:06 2009
@@ -29,8 +29,8 @@
     }
 
     public void testPoolIn3SecondsButNoFiles() throws Exception {
-        deleteDirectory("./res/home");
-        createDirectory("./res/home/slowfile");
+        deleteDirectory(FTP_ROOT_DIR);
+        createDirectory(FTP_ROOT_DIR + "slowfile");
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(0);
 

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java Mon Jan 26 11:52:06 2009
@@ -61,7 +61,7 @@
         mock.assertIsSatisfied();
 
         // assert the file is still there
-        File file = new File("./res/home/noop/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "noop/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should exists", file.exists());
     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPassiveModeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPassiveModeTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPassiveModeTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPassiveModeTest.java Mon Jan 26 11:52:06 2009
@@ -35,7 +35,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/passive");
+        deleteDirectory(FTP_ROOT_DIR + "passive");
         prepareFtpServer();
     }
 

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java Mon Jan 26 11:52:06 2009
@@ -39,7 +39,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/movefile");
+        deleteDirectory(FTP_ROOT_DIR + "movefile");
         prepareFtpServer();
     }
 
@@ -56,7 +56,7 @@
         producer.stop();
 
         // assert file is created
-        File file = new File("./res/home/movefile/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "movefile/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should exists", file.exists());
     }
@@ -75,7 +75,7 @@
                 from(getFtpUrl()).process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         // assert the file is pre moved
-                        File file = new File("./res/home/inprogress/hello.bak");
+                        File file = new File(FTP_ROOT_DIR + "inprogress/hello.bak");
                         file = file.getAbsoluteFile();
                         assertTrue("The file should have been moved", file.exists());
                     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java Mon Jan 26 11:52:06 2009
@@ -38,7 +38,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/movefile");
+        deleteDirectory(FTP_ROOT_DIR + "movefile");
         prepareFtpServer();
     }
 
@@ -55,7 +55,7 @@
         producer.stop();
 
         // assert file is created
-        File file = new File("./res/home/movefile/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "movefile/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should exists", file.exists());
     }
@@ -68,7 +68,7 @@
         mock.assertIsSatisfied();
 
         // assert the file is moved
-        File file = new File("./res/home/movefile/hello.txt.old");
+        File file = new File(FTP_ROOT_DIR + "movefile/hello.txt.old");
         file = file.getAbsoluteFile();
         assertTrue("The file should have been moved", file.exists());
     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java Mon Jan 26 11:52:06 2009
@@ -38,7 +38,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/movefile");
+        deleteDirectory(FTP_ROOT_DIR + "movefile");
         prepareFtpServer();
     }
 
@@ -55,7 +55,7 @@
         producer.stop();
 
         // assert file is created
-        File file = new File("./res/home/movefile/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "movefile/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should exists", file.exists());
     }
@@ -68,7 +68,7 @@
         mock.assertIsSatisfied();
 
         // assert the file is moved
-        File file = new File("./res/home/movefile/done/hello.txt");
+        File file = new File(FTP_ROOT_DIR + "movefile/done/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should have been moved", file.exists());
     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java Mon Jan 26 11:52:06 2009
@@ -18,6 +18,8 @@
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.component.file.GenericFileFilter;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
 
@@ -69,9 +71,9 @@
     }
 
     // START SNIPPET: e1
-    public class MyFileFilter implements RemoteFileFilter {
+    public class MyFileFilter implements GenericFileFilter {
 
-        public boolean accept(RemoteFile file) {
+        public boolean accept(GenericFile file) {
             // we only want report files 
             return file.getFileName().startsWith("report");
         }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFileTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFileTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFileTest.java Mon Jan 26 11:52:06 2009
@@ -40,7 +40,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home");
+        deleteDirectory(FTP_ROOT_DIR);
         prepareFtpServer();
     }
 

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinarySampleTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinarySampleTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinarySampleTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinarySampleTest.java Mon Jan 26 11:52:06 2009
@@ -43,7 +43,7 @@
                 // the delay parameter is from the FileConsumer component so we should use consumer.delay as
                 // the URI parameter name. The FTP Component is an extension of the File Component.
                 from("ftp://scott@localhost/public/reports?password=tiger&binary=true&consumer.delay=" + delay).
-                    to("file://target/test-reports");
+                        to("file://target/test-reports");
             }
         };
     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromQueueThenConsumeFtpToMockTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromQueueThenConsumeFtpToMockTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromQueueThenConsumeFtpToMockTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromQueueThenConsumeFtpToMockTest.java Mon Jan 26 11:52:06 2009
@@ -47,7 +47,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/getme");
+        deleteDirectory(FTP_ROOT_DIR + "getme");
         prepareFtpServer();
     }
 

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExpressionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExpressionTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExpressionTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExpressionTest.java Mon Jan 26 11:52:06 2009
@@ -61,7 +61,7 @@
         Thread.sleep(1000);
 
         String now = new SimpleDateFormat("yyyyMMdd").format(new Date());
-        File file = new File("res/home/filelanguage/backup/" + now + "/123-report2.bak");
+        File file = new File(FTP_ROOT_DIR + "filelanguage/backup/" + now + "/123-report2.bak");
         file = file.getAbsoluteFile();
         assertTrue("File should have been renamed", file.exists());
     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java Mon Jan 26 11:52:06 2009
@@ -88,7 +88,7 @@
         }
 
         public boolean contains(String key) {
-            return false;
+            return invoked;
         }
     }
 

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=737677&r1=737676&r2=737677&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 Mon Jan 26 11:52:06 2009
@@ -32,7 +32,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/multidir");
+        deleteDirectory(FTP_ROOT_DIR + "multidir");
         prepareFtpServer();
     }
 
@@ -49,20 +49,20 @@
         assertMockEndpointsSatisfied();
 
         RemoteFileExchange exchange = (RemoteFileExchange) mock.getExchanges().get(0);
-        RemoteFile file = exchange.getRemoteFile();
-        assertEquals("multidir/bye.txt", file.getAbsolutelFileName());
+        RemoteFile file = (RemoteFile) exchange.getGenericFile();
+        assertEquals("multidir/bye.txt", file.getAbsoluteFileName());
         assertEquals("bye.txt", file.getRelativeFileName());
         assertEquals("bye.txt", file.getFileName());
 
         exchange = (RemoteFileExchange) mock.getExchanges().get(1);
-        file = exchange.getRemoteFile();
-        assertEquals("multidir/sub/hello.txt", file.getAbsolutelFileName());
+        file = (RemoteFile) exchange.getGenericFile();
+        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 = exchange.getRemoteFile();
-        assertEquals("multidir/sub/sub2/godday.txt", file.getAbsolutelFileName());
+        file = (RemoteFile) exchange.getGenericFile();
+        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/FtpConsumerWithNoFileOptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithNoFileOptionTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithNoFileOptionTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithNoFileOptionTest.java Mon Jan 26 11:52:06 2009
@@ -34,8 +34,8 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/");
-        createDirectory("./res/home/");
+        deleteDirectory(FTP_ROOT_DIR);
+        createDirectory(FTP_ROOT_DIR);
         prepareFtpServer();
     }
 
@@ -50,8 +50,8 @@
         assertMockEndpointsSatisfied();
 
         RemoteFileExchange exchange = (RemoteFileExchange) mock.getExchanges().get(0);
-        RemoteFile file = exchange.getRemoteFile();
-        assertEquals("hello.txt", file.getAbsolutelFileName());
+        RemoteFile file = (RemoteFile) exchange.getGenericFile();
+        assertEquals("hello.txt", file.getAbsoluteFileName());
         assertEquals("hello.txt", file.getRelativeFileName());
         assertEquals("hello.txt", file.getFileName());
     }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginTest.java Mon Jan 26 11:52:06 2009
@@ -18,6 +18,7 @@
 
 import java.io.File;
 
+import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Producer;
 import org.apache.camel.component.file.FileComponent;
@@ -27,14 +28,10 @@
  */
 public class FtpLoginTest extends FtpServerTestSupport {
 
-    private String getFtpUrl() {
-        return "ftp://dummy@localhost:" + getPort();
-    }
-
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("./res/home/login");
+        deleteDirectory(FTP_ROOT_DIR + "login");
     }
 
     public void testBadLogin() throws Exception {
@@ -47,7 +44,7 @@
         }
 
         // assert file NOT created
-        File file = new File("./res/home/login/report.txt");
+        File file = new File(FTP_ROOT_DIR + "login/report.txt");
         file = file.getAbsoluteFile();
         assertFalse("The file should NOT exists", file.exists());
     }
@@ -59,26 +56,13 @@
         Thread.sleep(2000);
 
         // assert file created
-        File file = new File("./res/home/login/report.txt");
+        File file = new File(FTP_ROOT_DIR + "login/report.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should exists", file.exists());
     }
 
     private void uploadFile(String username, String password) throws Exception {
-        RemoteFileComponent component = new RemoteFileComponent(context);
-
-        RemoteFileConfiguration config = new RemoteFileConfiguration();
-        config.setBinary(false);
-        config.setUsername(username);
-        config.setPassword(password);
-        config.setDirectory(true);
-        config.setHost("localhost");
-        config.setPort(getPort());
-        config.setProtocol("ftp");
-        config.setFile("login");
-
-        FtpRemoteFileOperations remoteFileOperations = new FtpRemoteFileOperations();
-        RemoteFileEndpoint endpoint = new RemoteFileEndpoint(getFtpUrl(), component, remoteFileOperations, config);
+        Endpoint endpoint = context.getEndpoint("ftp://" + username + "@localhost:" + getPort() + "/login?password=" + password);
 
         Exchange exchange = endpoint.createExchange();
         exchange.getIn().setBody("Hello World from FTPServer");

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildDirectoryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildDirectoryTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildDirectoryTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildDirectoryTest.java Mon Jan 26 11:52:06 2009
@@ -31,11 +31,11 @@
     }
 
     public void testProduceAndBuildFullRemotFolderTest() throws Exception {
-        deleteDirectory("./res/home/");
+        deleteDirectory(FTP_ROOT_DIR + "");
 
         template.sendBodyAndHeader(getFtpUrl(), "Hello World", FileComponent.HEADER_FILE_NAME, "claus.txt");
 
-        File file = new File("./res/home/upload/user/claus/claus.txt");
+        File file = new File(FTP_ROOT_DIR + "upload/user/claus/claus.txt");
         file = file.getAbsoluteFile();
         assertTrue("The uploaded file should exists", file.exists());
         assertEquals("Hello World", IOConverter.toString(file));

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildPartOfDirectoryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildPartOfDirectoryTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildPartOfDirectoryTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildPartOfDirectoryTest.java Mon Jan 26 11:52:06 2009
@@ -31,12 +31,12 @@
     }
 
     public void testProduceAndBuildPartOfRemotFolderTest() throws Exception {
-        deleteDirectory("./res/home/");
-        createDirectory("./res/home/upload/user/superman");
+        deleteDirectory(FTP_ROOT_DIR + "");
+        createDirectory(FTP_ROOT_DIR + "upload/user/superman");
 
         template.sendBodyAndHeader(getFtpUrl(), "Bye World", FileComponent.HEADER_FILE_NAME, "claus.txt");
 
-        File file = new File("./res/home/upload/user/claus/claus.txt");
+        File file = new File(FTP_ROOT_DIR + "upload/user/claus/claus.txt");
         file = file.getAbsoluteFile();
         assertTrue("The uploaded file should exists", file.exists());
         assertEquals("Bye World", IOConverter.toString(file));

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerExpressionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerExpressionTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerExpressionTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerExpressionTest.java Mon Jan 26 11:52:06 2009
@@ -37,7 +37,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("res/home/filelanguage");
+        deleteDirectory(FTP_ROOT_DIR + "filelanguage");
         deleteDirectory("target/filelanguage");
     }
 
@@ -52,14 +52,14 @@
         template.sendBody(getFtpUrl() + "&expression=${bean:myguidgenerator}.bak", "Hello World");
 
         Thread.sleep(500);
-        assertFileExists("res/home/filelanguage/123.bak");
+        assertFileExists(FTP_ROOT_DIR + "filelanguage/123.bak");
     }
 
     public void testProduceBeanByHeader() throws Exception {
         template.sendBodyAndHeader(getFtpUrl(), "Hello World", FileComponent.HEADER_FILE_NAME, "${bean:myguidgenerator}.bak");
 
         Thread.sleep(500);
-        assertFileExists("res/home/filelanguage/123.bak");
+        assertFileExists(FTP_ROOT_DIR + "filelanguage/123.bak");
     }
 
     public void testProducerDateByHeader() throws Exception {
@@ -67,7 +67,7 @@
 
         Thread.sleep(500);
         String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
-        assertFileExists("res/home/filelanguage/myfile-" + date + ".txt");
+        assertFileExists(FTP_ROOT_DIR + "filelanguage/myfile-" + date + ".txt");
     }
 
     public void testProducerDateByExpression() throws Exception {
@@ -75,7 +75,7 @@
 
         Thread.sleep(500);
         String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
-        assertFileExists("res/home/filelanguage/myfile-" + date + ".txt");
+        assertFileExists(FTP_ROOT_DIR + "filelanguage/myfile-" + date + ".txt");
     }
 
     public void testProducerComplexByExpression() throws Exception {
@@ -84,7 +84,7 @@
 
         Thread.sleep(500);
         String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
-        assertFileExists("res/home/filelanguageinbox/myfile-123-" + date + ".txt");
+        assertFileExists(FTP_ROOT_DIR + "filelanguageinbox/myfile-123-" + date + ".txt");
     }
 
     public void testProducerSimpleWithHeaderByExpression() throws Exception {
@@ -92,7 +92,7 @@
                 "Hello World", "foo", "abc");
 
         Thread.sleep(500);
-        assertFileExists("res/home/filelanguage/myfile-abc.txt");
+        assertFileExists(FTP_ROOT_DIR + "filelanguage/myfile-abc.txt");
     }
 
     public void testProducerWithDateHeader() throws Exception {
@@ -104,7 +104,7 @@
                 "Hello World", "birthday", date);
 
         Thread.sleep(500);
-        assertFileExists("res/home/filelanguage/mybirthday-19740420.txt");
+        assertFileExists(FTP_ROOT_DIR + "filelanguage/mybirthday-19740420.txt");
     }
 
     private static void assertFileExists(String filename) {

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempPrefixTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempPrefixTest.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempPrefixTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempPrefixTest.java Mon Jan 26 11:52:06 2009
@@ -18,7 +18,6 @@
 
 import java.io.File;
 
-import org.apache.camel.Endpoint;
 import org.apache.camel.component.file.FileComponent;
 import org.apache.camel.converter.IOConverter;
 
@@ -31,30 +30,12 @@
         return "ftp://admin@localhost:" + getPort() + "/upload/user/claus?binary=false&password=admin&tempPrefix=.uploading";
     }
 
-    public void testCreateTempFileName() throws Exception {
-        Endpoint endpoint = context.getEndpoint(getFtpUrl());
-        RemoteFileProducer producer = (RemoteFileProducer) endpoint.createProducer();
-
-        String fileName = "somepath/someuser/claus.txt";
-        String tempFileName = producer.createTempFileName(fileName);
-        assertEquals("somepath/someuser/.uploadingclaus.txt", tempFileName);
-    }
-
-    public void testNoPathCreateTempFileName() throws Exception {
-        Endpoint endpoint = context.getEndpoint(getFtpUrl());
-        RemoteFileProducer producer = (RemoteFileProducer) endpoint.createProducer();
-
-        String fileName = "claus.txt";
-        String tempFileName = producer.createTempFileName(fileName);
-        assertEquals(".uploadingclaus.txt", tempFileName);
-    }
-
     public void testProduceTempPrefixTest() throws Exception {
-        deleteDirectory("./res/home/");
+        deleteDirectory(FTP_ROOT_DIR + "");
 
         template.sendBodyAndHeader(getFtpUrl(), "Hello World", FileComponent.HEADER_FILE_NAME, "claus.txt");
 
-        File file = new File("./res/home/upload/user/claus/claus.txt");
+        File file = new File(FTP_ROOT_DIR + "upload/user/claus/claus.txt");
         file = file.getAbsoluteFile();
         assertTrue("The uploaded file should exists", file.exists());
         assertEquals("Hello World", IOConverter.toString(file));

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java?rev=737677&r1=737676&r2=737677&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java Mon Jan 26 11:52:06 2009
@@ -30,7 +30,12 @@
  * Base class for unit testing using a FTPServer
  */
 public abstract class FtpServerTestSupport extends ContextTestSupport {
+
+    // TODO: Figure out to set the home dir of the ftpServer from java
+    public static final String FTP_ROOT_DIR = "./res/home/";
+
     protected FtpServer ftpServer;
+
     private int port;
 
     public int getPort() {

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=737677&r1=737676&r2=737677&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 Mon Jan 26 11:52:06 2009
@@ -30,9 +30,9 @@
 
     public void testFtpConfigurationDefaults() {
         Endpoint endpoint = context.getEndpoint("ftp://hostname");
-        assertIsInstanceOf(RemoteFileEndpoint.class, endpoint);
-        RemoteFileEndpoint ftpEndpoint = (RemoteFileEndpoint) endpoint;
-        RemoteFileConfiguration config = ftpEndpoint.getConfiguration();
+        assertIsInstanceOf(FtpRemoteFileEndpoint.class, endpoint);
+        FtpRemoteFileEndpoint ftpEndpoint = (FtpRemoteFileEndpoint) endpoint;
+        RemoteFileConfiguration config = (RemoteFileConfiguration) ftpEndpoint.getConfiguration();
 
         assertEquals("ftp", config.getProtocol());
         assertEquals("hostname", config.getHost());
@@ -42,12 +42,12 @@
         assertEquals(false, config.isBinary());
         assertEquals(true, config.isDirectory());
     }
-    
+
     public void testSftpConfigurationDefaults() {
         Endpoint endpoint = context.getEndpoint("sftp://hostname");
-        assertIsInstanceOf(RemoteFileEndpoint.class, endpoint);
-        RemoteFileEndpoint sftpEndpoint = (RemoteFileEndpoint) endpoint;
-        RemoteFileConfiguration config = sftpEndpoint.getConfiguration();
+        assertIsInstanceOf(SftpRemoteFileEndpoint.class, endpoint);
+        SftpRemoteFileEndpoint sftpEndpoint = (SftpRemoteFileEndpoint) endpoint;
+        RemoteFileConfiguration config = (RemoteFileConfiguration) sftpEndpoint.getConfiguration();
 
         assertEquals("sftp", config.getProtocol());
         assertEquals("hostname", config.getHost());
@@ -57,12 +57,12 @@
         assertEquals(false, config.isBinary());
         assertEquals(true, config.isDirectory());
     }
-    
+
     public void testFtpExplicitConfiguration() {
         Endpoint endpoint = context.getEndpoint("ftp://user@hostname:1021/some/file?password=secret&binary=true&directory=false");
-        assertIsInstanceOf(RemoteFileEndpoint.class, endpoint);
-        RemoteFileEndpoint ftpEndpoint = (RemoteFileEndpoint) endpoint;
-        RemoteFileConfiguration config = ftpEndpoint.getConfiguration();
+        assertIsInstanceOf(FtpRemoteFileEndpoint.class, endpoint);
+        FtpRemoteFileEndpoint ftpEndpoint = (FtpRemoteFileEndpoint) endpoint;
+        RemoteFileConfiguration config = (RemoteFileConfiguration) ftpEndpoint.getConfiguration();
 
         assertEquals("ftp", config.getProtocol());
         assertEquals("hostname", config.getHost());
@@ -72,12 +72,12 @@
         assertEquals(true, config.isBinary());
         assertEquals(false, config.isDirectory());
     }
-    
+
     public void testSftpExplicitConfiguration() {
         Endpoint endpoint = context.getEndpoint("sftp://user@hostname:1021/some/file?password=secret&binary=true&directory=false");
-        assertIsInstanceOf(RemoteFileEndpoint.class, endpoint);
-        RemoteFileEndpoint sftpEndpoint = (RemoteFileEndpoint) endpoint;
-        RemoteFileConfiguration config = sftpEndpoint.getConfiguration();
+        assertIsInstanceOf(SftpRemoteFileEndpoint.class, endpoint);
+        SftpRemoteFileEndpoint sftpEndpoint = (SftpRemoteFileEndpoint) endpoint;
+        RemoteFileConfiguration config = (RemoteFileConfiguration) sftpEndpoint.getConfiguration();
 
         assertEquals("sftp", config.getProtocol());
         assertEquals("hostname", config.getHost());
@@ -87,7 +87,7 @@
         assertEquals(true, config.isBinary());
         assertEquals(false, config.isDirectory());
     }
-    
+
     public void testRemoteFileEndpointFiles() {
         assertRemoteFileEndpointFile("ftp://hostname/foo/bar", "foo/bar");
         assertRemoteFileEndpointFile("ftp://hostname/foo/", "foo/");
@@ -98,7 +98,7 @@
         assertRemoteFileEndpointFile("ftp://hostname//foo/bar", "/foo/bar");
         assertRemoteFileEndpointFile("sftp://user@hostname:123//foo/bar?password=secret", "/foo/bar");
     }
-    
+
     private void assertRemoteFileEndpointFile(String endpointUri, String expectedFile) {
         RemoteFileEndpoint endpoint = resolveMandatoryEndpoint(context, endpointUri, RemoteFileEndpoint.class);
         assertNotNull("Could not find endpoint: " + endpointUri, endpoint);
@@ -106,12 +106,12 @@
         String file = endpoint.getConfiguration().getFile();
         assertEquals("For uri: " + endpointUri + " the file is not equal", expectedFile, file);
     }
-    
+
     public void testSftpKnownHostsFileConfiguration() {
         Endpoint endpoint = context.getEndpoint("sftp://user@hostname:1021/some/file?password=secret&binary=true&directory=false&knownHostsFile=/home/janstey/.ssh/known_hosts");
-        assertIsInstanceOf(RemoteFileEndpoint.class, endpoint);
-        RemoteFileEndpoint sftpEndpoint = (RemoteFileEndpoint) endpoint;
-        RemoteFileConfiguration config = sftpEndpoint.getConfiguration();
+        assertIsInstanceOf(SftpRemoteFileEndpoint.class, endpoint);
+        SftpRemoteFileEndpoint sftpEndpoint = (SftpRemoteFileEndpoint) endpoint;
+        RemoteFileConfiguration config = (RemoteFileConfiguration) sftpEndpoint.getConfiguration();
 
         assertEquals("sftp", config.getProtocol());
         assertEquals("hostname", config.getHost());



Mime
View raw message