You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2008/12/26 11:53:12 UTC

svn commit: r729480 [3/4] - in /activemq/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/ tes...

Added: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategyFactory.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategyFactory.java?rev=729480&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategyFactory.java (added)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategyFactory.java Fri Dec 26 02:53:10 2008
@@ -0,0 +1,108 @@
+/**
+ * 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.strategy;
+
+import java.util.Map;
+
+import org.apache.camel.Expression;
+import org.apache.camel.component.file.remote.RemoteFileExclusiveReadLockStrategy;
+import org.apache.camel.component.file.remote.RemoteFileProcessStrategy;
+import org.apache.camel.util.ObjectHelper;
+
+public final class RemoteFileProcessStrategyFactory {
+
+    private RemoteFileProcessStrategyFactory() {
+    }
+
+    public static RemoteFileProcessStrategy createRemoteFileProcessStrategy(Map<String, Object> params) {
+
+        // We assume a value is present only if its value not null for String and 'true' for boolean
+        boolean isNoop = params.get("noop") != null;
+        boolean isDelete = params.get("delete") != null;
+        String moveNamePrefix = (String) params.get("moveNamePrefix");
+        String moveNamePostfix = (String) params.get("moveNamePostfix");
+        String preMoveNamePrefix = (String) params.get("preMoveNamePrefix");
+        String preMoveNamePostfix = (String) params.get("preMoveNamePostfix");
+        Expression expression = (Expression) params.get("expression");
+        Expression preMoveExpression = (Expression) params.get("preMoveExpression");
+        boolean move = moveNamePrefix != null || moveNamePostfix != null;
+        boolean preMove = preMoveNamePrefix != null || preMoveNamePostfix != null;
+
+        if (isNoop) {
+            NoOpRemoteFileProcessStrategy strategy = new NoOpRemoteFileProcessStrategy();
+            strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
+            return strategy;
+        } else if (isDelete) {
+            DeleteRemoteFileProcessStrategy strategy = new DeleteRemoteFileProcessStrategy();
+            strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
+            return strategy;
+        } else if (move || preMove) {
+            RenameRemoteFileProcessStrategy strategy = new RenameRemoteFileProcessStrategy();
+            strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
+            if (move) {
+                strategy.setCommitRenamer(new DefaultRemoteFileRenamer(moveNamePrefix, moveNamePostfix));
+            }
+            if (preMove) {
+                strategy.setBeginRenamer(new DefaultRemoteFileRenamer(preMoveNamePrefix, preMoveNamePostfix));
+            }
+            return strategy;
+        } else if (expression != null || preMoveExpression != null) {
+            RenameRemoteFileProcessStrategy strategy = new RenameRemoteFileProcessStrategy();
+            strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
+            if (expression != null) {
+                RemoteFileExpressionRenamer renamer = new RemoteFileExpressionRenamer();
+                renamer.setExpression(expression);
+                strategy.setCommitRenamer(renamer);
+            }
+            if (preMoveExpression != null) {
+                RemoteFileExpressionRenamer renamer = new RemoteFileExpressionRenamer();
+                renamer.setExpression(preMoveExpression);
+                strategy.setBeginRenamer(renamer);
+            }
+            return strategy;
+        } else {
+            // default strategy will do nothing
+            NoOpRemoteFileProcessStrategy strategy = new NoOpRemoteFileProcessStrategy();
+            strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
+            return strategy;
+        }
+    }
+
+    private static RemoteFileExclusiveReadLockStrategy getExclusiveReadLockStrategy(Map<String, Object> params) {
+        RemoteFileExclusiveReadLockStrategy strategy = (RemoteFileExclusiveReadLockStrategy) params.get("exclusiveReadLockStrategy");
+        if (strategy != null) {
+            return strategy;
+        }
+
+        // no explicit stategy set then fallback to readLock option
+        String readLock = (String) params.get("readLock");
+        if (ObjectHelper.isNotEmpty(readLock)) {
+            if ("none".equals(readLock) || "false".equals(readLock)) {
+                return null;
+            } else if ("rename".equals(readLock)) {
+                RemoteFileRenameExclusiveReadLockStrategy readLockStrategy = new RemoteFileRenameExclusiveReadLockStrategy();
+                Long timeout = (Long) params.get("readLockTimeout");
+                if (timeout != null) {
+                    readLockStrategy.setTimeout(timeout);
+                }
+                return readLockStrategy;
+            }
+        }
+
+        return null;
+    }
+}

Added: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategySupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategySupport.java?rev=729480&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategySupport.java (added)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategySupport.java Fri Dec 26 02:53:10 2008
@@ -0,0 +1,58 @@
+/**
+ * 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.strategy;
+
+import org.apache.camel.component.file.remote.RemoteFile;
+import org.apache.camel.component.file.remote.RemoteFileEndpoint;
+import org.apache.camel.component.file.remote.RemoteFileExchange;
+import org.apache.camel.component.file.remote.RemoteFileExclusiveReadLockStrategy;
+import org.apache.camel.component.file.remote.RemoteFileOperations;
+import org.apache.camel.component.file.remote.RemoteFileProcessStrategy;
+
+public abstract class RemoteFileProcessStrategySupport implements RemoteFileProcessStrategy {
+    private RemoteFileExclusiveReadLockStrategy exclusiveReadLockStrategy;
+
+    public boolean begin(RemoteFileOperations operations, RemoteFileEndpoint endpoint, RemoteFileExchange exchange, RemoteFile file) throws Exception {
+        // is we use excluse read then acquire the exclusive read (waiting until we got it)
+        if (exclusiveReadLockStrategy != null) {
+            boolean lock = exclusiveReadLockStrategy.acquireExclusiveReadLock(operations, file);
+            if (!lock) {
+                // do not begin sice we could not get the exclusive read lcok
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public void commit(RemoteFileOperations operations, RemoteFileEndpoint endpoint, RemoteFileExchange exchange, RemoteFile file) throws Exception {
+        // nothing
+    }
+
+    public void rollback(RemoteFileOperations operations, RemoteFileEndpoint endpoint, RemoteFileExchange exchange, RemoteFile file) {
+        // nothing
+    }
+
+    public RemoteFileExclusiveReadLockStrategy getExclusiveReadLockStrategy() {
+        return exclusiveReadLockStrategy;
+    }
+
+    public void setExclusiveReadLockStrategy(RemoteFileExclusiveReadLockStrategy exclusiveReadLockStrategy) {
+        this.exclusiveReadLockStrategy = exclusiveReadLockStrategy;
+    }
+}
+

Added: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenameExclusiveReadLockStrategy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenameExclusiveReadLockStrategy.java?rev=729480&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenameExclusiveReadLockStrategy.java (added)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenameExclusiveReadLockStrategy.java Fri Dec 26 02:53:10 2008
@@ -0,0 +1,101 @@
+/**
+ * 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.strategy;
+
+import org.apache.camel.component.file.remote.RemoteFile;
+import org.apache.camel.component.file.remote.RemoteFileExclusiveReadLockStrategy;
+import org.apache.camel.component.file.remote.RemoteFileOperations;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Acquires exclusive read lock to the given file. Will wait until the lock is granted.
+ * After granting the read lock it is realeased, we just want to make sure that when we start
+ * consuming the file its not currently in progress of being written by third party.
+ */
+public class RemoteFileRenameExclusiveReadLockStrategy implements RemoteFileExclusiveReadLockStrategy {
+    private static final transient Log LOG = LogFactory.getLog(RemoteFileRenameExclusiveReadLockStrategy.class);
+    private long timeout;
+
+    public boolean acquireExclusiveReadLock(RemoteFileOperations operations, RemoteFile file) {
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Waiting for exclusive read lock to remote file: " + file);
+        }
+
+        // the trick is to try to rename the file, if we can rename then we have exclusive read
+        // since its a remote file we cannot use java.nio to get a RW lock
+        String newName = file.getFileName() + ".camelExclusiveReadLock";
+
+        // clone and change the name
+        RemoteFile newFile = file.clone();
+        newFile.changeFileName(newName);
+
+        long start = System.currentTimeMillis();
+
+        boolean exclusive = false;
+        while (!exclusive) {
+             // timeout check
+            if (timeout > 0) {
+                long delta = System.currentTimeMillis() - start;
+                if (delta > timeout) {
+                    LOG.debug("Could not acquire read lock within " + timeout + " millis. Will skip the remote file: " + file);
+                    // we could not get the lock within the timeout period, so return false
+                    return false;
+                }
+            }
+            
+            exclusive = operations.renameFile(file.getAbsolutelFileName(), newFile.getAbsolutelFileName());
+            if (exclusive) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Acquired exclusive read lock to file: " + file);
+                }
+                // rename it back so we can read it
+                operations.renameFile(newFile.getAbsolutelFileName(), file.getAbsolutelFileName());
+            } else {
+                sleep();
+            }
+        }
+
+        return true;
+    }
+
+    private void sleep() {
+        LOG.trace("Exclusive read lock not granted. Sleeping for 1000 millis.");
+        try {
+            Thread.sleep(1000);
+        } catch (InterruptedException e) {
+            // ignore
+        }
+    }
+
+    public long getTimeout() {
+        return timeout;
+    }
+
+    /**
+     * Sets an optional timeout period.
+     * <p/>
+     * If the readlock could not be granted within the timeperiod then the wait is stopped and the
+     * {@link #acquireExclusiveReadLock(org.apache.camel.component.file.remote.RemoteFileOperations,
+     * org.apache.camel.component.file.remote.RemoteFile) acquireExclusiveReadLock} returns <tt>false</tt>.
+     *
+     * @param timeout period in millis
+     */
+    public void setTimeout(long timeout) {
+        this.timeout = timeout;
+    }
+}

Added: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenamer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenamer.java?rev=729480&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenamer.java (added)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenamer.java Fri Dec 26 02:53:10 2008
@@ -0,0 +1,36 @@
+/**
+ * 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.strategy;
+
+import org.apache.camel.component.file.remote.RemoteFile;
+import org.apache.camel.component.file.remote.RemoteFileExchange;
+
+/**
+ * Used for renaming files.
+ */
+public interface RemoteFileRenamer {
+
+    /**
+     * Renames the given file
+     *
+     * @param exchange  the exchange
+     * @param file      the original file.
+     * @return the renamed file name.
+     */
+    RemoteFile renameFile(RemoteFileExchange exchange, RemoteFile file);
+
+}

Added: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RenameRemoteFileProcessStrategy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RenameRemoteFileProcessStrategy.java?rev=729480&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RenameRemoteFileProcessStrategy.java (added)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RenameRemoteFileProcessStrategy.java Fri Dec 26 02:53:10 2008
@@ -0,0 +1,112 @@
+/**
+ * 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.strategy;
+
+import java.io.IOException;
+
+import org.apache.camel.component.file.remote.RemoteFile;
+import org.apache.camel.component.file.remote.RemoteFileEndpoint;
+import org.apache.camel.component.file.remote.RemoteFileExchange;
+import org.apache.camel.component.file.remote.RemoteFileOperationFailedException;
+import org.apache.camel.component.file.remote.RemoteFileOperations;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class RenameRemoteFileProcessStrategy extends RemoteFileProcessStrategySupport {
+    private static final transient Log LOG = LogFactory.getLog(RenameRemoteFileProcessStrategy.class);
+    private RemoteFileRenamer beginRenamer;
+    private RemoteFileRenamer commitRenamer;
+
+    public RenameRemoteFileProcessStrategy() {
+    }
+
+    public RenameRemoteFileProcessStrategy(String namePrefix, String namePostfix) {
+        this(new DefaultRemoteFileRenamer(namePrefix, namePostfix), null);
+    }
+
+    public RenameRemoteFileProcessStrategy(String namePrefix, String namePostfix, String preNamePrefix, String preNamePostfix) {
+        this(new DefaultRemoteFileRenamer(namePrefix, namePostfix), new DefaultRemoteFileRenamer(preNamePrefix, preNamePostfix));
+    }
+
+    public RenameRemoteFileProcessStrategy(RemoteFileRenamer commitRenamer, RemoteFileRenamer beginRenamer) {
+        this.commitRenamer = commitRenamer;
+        this.beginRenamer = beginRenamer;
+    }
+
+    @Override
+    public boolean begin(RemoteFileOperations operations, RemoteFileEndpoint endpoint, RemoteFileExchange exchange, RemoteFile file) throws Exception {
+        if (beginRenamer != null) {
+            RemoteFile newName = beginRenamer.renameFile(exchange, file);
+            RemoteFile to = renameFile(operations, file, newName);
+            exchange.setRemoteFile(to);
+        }
+
+        return true;
+    }
+
+    @Override
+    public void commit(RemoteFileOperations operations, RemoteFileEndpoint endpoint, RemoteFileExchange exchange, RemoteFile file) throws Exception {
+        if (commitRenamer != null) {
+            RemoteFile newName = commitRenamer.renameFile(exchange, file);
+            renameFile(operations, file, newName);
+        }
+    }
+
+    private static RemoteFile renameFile(RemoteFileOperations operations, RemoteFile from, RemoteFile to) throws IOException {
+        // deleting any existing files before renaming
+        boolean deleted = operations.deleteFile(to.getAbsolutelFileName());
+        if (!deleted) {
+            // if we could not delete any existing file then maybe the folder is missing
+            // build folder if needed
+            String name = to.getAbsolutelFileName();
+            int lastPathIndex = name.lastIndexOf('/');
+            if (lastPathIndex != -1) {
+                String directory = name.substring(0, lastPathIndex);
+                if (!operations.buildDirectory(directory)) {
+                    LOG.warn("Cannot build directory: " + directory + " (maybe because of denied permissions)");
+                }
+            }
+        }
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Renaming file: " + from + " to: " + to);
+        }
+        boolean renamed = operations.renameFile(from.getAbsolutelFileName(), to.getAbsolutelFileName());
+        if (!renamed) {
+            throw new RemoteFileOperationFailedException("Cannot rename file: " + from + " to: " + to);
+        }
+
+        return to;
+    }
+
+    public RemoteFileRenamer getBeginRenamer() {
+        return beginRenamer;
+    }
+
+    public void setBeginRenamer(RemoteFileRenamer beginRenamer) {
+        this.beginRenamer = beginRenamer;
+    }
+
+    public RemoteFileRenamer getCommitRenamer() {
+        return commitRenamer;
+    }
+
+    public void setCommitRenamer(RemoteFileRenamer commitRenamer) {
+        this.commitRenamer = commitRenamer;
+    }
+
+}

Added: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/package.html?rev=729480&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/package.html (added)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/package.html Fri Dec 26 02:53:10 2008
@@ -0,0 +1,25 @@
+<!--
+    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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Strategies for the Remote Files and <a href="http://activemq.apache.org/camel/ftp.html">FTP</a> Component.
+
+</body>
+</html>

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

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

Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/package.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Modified: activemq/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftp
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftp?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftp (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftp Fri Dec 26 02:53:10 2008
@@ -16,3 +16,4 @@
 #
 
 class=org.apache.camel.component.file.remote.RemoteFileComponent
+strategy.factory.class=org.apache.camel.component.file.remote.strategy.RemoteFileProcessStrategyFactory

Modified: activemq/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/sftp
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/sftp?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/sftp (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/sftp Fri Dec 26 02:53:10 2008
@@ -16,3 +16,4 @@
 #
 
 class=org.apache.camel.component.file.remote.RemoteFileComponent
+strategy.factory.class=org.apache.camel.component.file.remote.strategy.RemoteFileProcessStrategyFactory

Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpTest.java?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpTest.java Fri Dec 26 02:53:10 2008
@@ -25,15 +25,13 @@
 public class FromFileToFtpTest extends FtpServerTestSupport {
 
     private int port = 20011;
-    private String ftpUrl = "ftp://admin@localhost:" + port + "/tmp2/camel?password=admin";
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/tmp2/camel?password=admin&consumer.initialDelay=5000";
 
     public void testFromFileToFtp() throws Exception {
-        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
-        resultEndpoint.expectedMinimumMessageCount(1);
-        resultEndpoint.assertIsSatisfied();
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(2);
 
-        // let some time pass to let the consumer etc. properly do its business before closing
-        Thread.sleep(1000);
+        assertMockEndpointsSatisfied();
     }
 
     public int getPort() {
@@ -43,7 +41,7 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("file:src/main/data?noop=true").to(ftpUrl);
+                from("file:src/main/data?noop=true&consumer.delay=5000").to(ftpUrl);
 
                 from(ftpUrl).to("mock:result");
             }

Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java Fri Dec 26 02:53:10 2008
@@ -26,12 +26,12 @@
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
- * Unit test to test consumer.deleteFile option.
+ * Unit test to test delete option.
  */
 public class FromFtpDeleteFileTest extends FtpServerTestSupport {
 
     private int port = 20022;
-    private String ftpUrl = "ftp://admin@localhost:" + port + "/deletefile?password=admin&binary=false&consumer.deleteFile=true";
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/deletefile?password=admin&binary=false&delete=true";
 
     public int getPort() {
         return port;
@@ -65,9 +65,11 @@
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
         mock.expectedBodiesReceived("Hello World this file will be deleted");
-
+        
         mock.assertIsSatisfied();
 
+        Thread.sleep(500);
+
         // assert the file is deleted
         File file = new File("./res/home/deletefile/hello.txt");
         file = file.getAbsoluteFile();

Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesTest.java?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesTest.java Fri Dec 26 02:53:10 2008
@@ -35,8 +35,7 @@
     private int port = 20034;
 
     private String ftpUrl = "ftp://admin@localhost:" + port + "/incoming/?password=admin&directory=true"
-        + "&binary=true&consumer.useFixedDelay=false&consumer.setNames=true&consumer.recursive=false";
-    // must user "consumer." prefix on the parameters to the file component
+        + "&binary=true&consumer.useFixedDelay=false&setNames=true&recursive=false&consumer.delay=5000";
 
     public void testFtpRoute() throws Exception {
         MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
@@ -47,7 +46,7 @@
         assertTrue("Logo size wrong", bytes.length > 10000);
 
         // wait until the file producer has written the file
-        Thread.sleep(1000);
+        Thread.sleep(2000);
 
         // assert the file
         File file = new File("target/ftptest/logo1.jpeg");
@@ -58,9 +57,6 @@
         file = new File("target/ftptest/logo.jpeg");
         assertTrue(" The binary file should exists", file.exists());
         assertTrue("Logo size wrong", file.length() > 10000);
-
-        // let some time pass to let the consumer etc. properly do its business before closing
-        Thread.sleep(1000);
     }
 
     public int getPort() {
@@ -77,7 +73,7 @@
         // prepares the FTP Server by creating a file on the server that we want to unit
         // test that we can pool and store as a local file
         String ftpUrl = "ftp://admin@localhost:" + port + "/incoming/?password=admin&binary=true"
-            + "&consumer.delay=2000&consumer.recursive=false&consumer.append=false";
+            + "&consumer.delay=2000&recursive=false";
         Endpoint endpoint = context.getEndpoint(ftpUrl);
         Exchange exchange = endpoint.createExchange();
         exchange.getIn().setBody(IOConverter.toFile("src/test/data/ftpbinarytest/logo.jpeg"));

Copied: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java (from r727937, activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java?p2=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java&p1=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java&r1=727937&r2=729480&rev=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java Fri Dec 26 02:53:10 2008
@@ -18,7 +18,10 @@
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.nio.channels.FileLock;
 
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.commons.logging.Log;
@@ -27,55 +30,68 @@
 /**
  * Unit test to verify *NON* exclusive read.
  */
-public class FromFtpNonExclusiveReadTest extends FtpServerTestSupport {
+public class FromFtpExclusiveReadNoneStrategyTest extends FtpServerTestSupport {
 
-    private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadTest.class);
+    private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadRenameStrategyTest.class);
 
     private int port = 20027;
     private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin"
-            + "&consumer.exclusiveReadLock=false&consumer.delay=500&consumer.timestamp=true";
+            + "&readLock=none&consumer.delay=500";
 
     public int getPort() {
         return port;
     }
 
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+
     public void testPollFileWhileSlowFileIsBeingWrittenUsingNonExclusiveRead() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("seda:start").process(new MySlowFileProcessor());
+                from(ftpUrl).to("mock:result");
+            }
+        });
+        context.start();
+
         deleteDirectory("./res/home");
         createDirectory("./res/home/slowfile");
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
 
-        createSlowFile();
+        // send a message to seda:start to trigger the creating of the slowfile to poll
+        template.sendBody("seda:start", "Create the slow file");
 
         mock.assertIsSatisfied();
 
         // we read only part of the file as we dont have exclusive read and thus read part of the
         // file currently in progress of being written - so we get only the Hello World part
-        String body = mock.getExchanges().get(0).getIn().getBody(String.class);
-        assertFalse("Should not get the entire file", body.endsWith("Bye World"));
+        String body = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
+        LOG.debug("Body is: " + body);
+        assertFalse("Should not wait and read the entire file", body.endsWith("Bye World"));
     }
 
-    private void createSlowFile() throws Exception {
-        LOG.info("Creating a slow file ...");
-        File file = new File("./res/home/slowfile/hello.txt");
-        FileOutputStream fos = new FileOutputStream(file);
-        fos.write("Hello World".getBytes());
-        for (int i = 0; i < 3; i++) {
-            Thread.sleep(1000);
-            fos.write(("Line #" + i).getBytes());
-            LOG.info("Appending to slowfile");
-        }
-        fos.write("Bye World".getBytes());
-        fos.close();
-        LOG.info("... done creating slowfile");
-    }
+    private class MySlowFileProcessor implements Processor {
 
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            public void configure() throws Exception {
-                from(ftpUrl).to("mock:result");
+        public void process(Exchange exchange) throws Exception {
+            LOG.info("Creating a slow file ...");
+            File file = new File("./res/home/slowfile/hello.txt");
+            FileOutputStream fos = new FileOutputStream(file);
+            FileLock lock = fos.getChannel().lock();
+            fos.write("Hello World".getBytes());
+            for (int i = 0; i < 3; i++) {
+                Thread.sleep(1000);
+                fos.write(("Line #" + i).getBytes());
+                LOG.info("Appending to slowfile");
             }
-        };
+            fos.write("Bye World".getBytes());
+            lock.release();
+            fos.close();
+            LOG.info("... done creating slowfile");
+        }
     }
-
 }

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

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

Copied: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadRenameStrategyTest.java (from r727937, activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadRenameStrategyTest.java?p2=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadRenameStrategyTest.java&p1=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadTest.java&r1=727937&r2=729480&rev=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadRenameStrategyTest.java Fri Dec 26 02:53:10 2008
@@ -18,59 +18,109 @@
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.nio.channels.FileLock;
 
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 /**
  * Unit test to verify exclusive read - that we do not poll files that is in progress of being written.
  */
-public class FromFtpExclusiveReadTest extends FtpServerTestSupport {
-
-    private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadTest.class);
+public class FromFtpExclusiveReadRenameStrategyTest extends FtpServerTestSupport {
+    private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadRenameStrategyTest.class);
+    private static final boolean ON_WINDOWS = System.getProperty("os.name").startsWith("Windows");
 
     private int port = 20090;
-    private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&consumer.exclusiveReadLock=true&consumer.delay=500";
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&readLock=rename&consumer.delay=500";
 
     public int getPort() {
         return port;
     }
 
-    // TODO: Not possible to test in single JVM
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
     public void testPollFileWhileSlowFileIsBeingWritten() throws Exception {
-        /*deleteDirectory("./res/home");
+        // can only be tested on Windows
+        if (!ON_WINDOWS) {
+            return;
+        }
+
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("seda:start").process(new MySlowFileProcessor());
+                from(ftpUrl).to("mock:result");
+            }
+        });
+        context.start();
+
+        deleteDirectory("./res/home");
         createDirectory("./res/home/slowfile");
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
         mock.expectedBodiesReceived("Hello WorldLine #0Line #1Line #2Bye World");
+        mock.setMinimumResultWaitTime(3000);
 
-        createSlowFile();
+        // send a message to seda:start to trigger the creating of the slowfile to poll
+        template.sendBody("seda:start", "Create the slow file");
 
-        mock.assertIsSatisfied();*/
+        mock.assertIsSatisfied();
     }
 
-    private void createSlowFile() throws Exception {
-        LOG.info("Creating a slow file ...");
-        File file = new File("./res/home/slowfile/hello.txt");
-        FileOutputStream fos = new FileOutputStream(file);
-        fos.write("Hello World".getBytes());
-        for (int i = 0; i < 3; i++) {
-            Thread.sleep(1000);
-            fos.write(("Line #" + i).getBytes());
-            LOG.info("Appending to slowfile");
+    public void testPollFileWhileSlowFileIsBeingWrittenWithTimeout() throws Exception {
+        // can only be tested on Windows
+        if (!ON_WINDOWS) {
+            return;
         }
-        fos.write("Bye World".getBytes());
-        fos.close();
-        LOG.info("... done creating slowfile");
-    }
 
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
+        context.addRoutes(new RouteBuilder() {
+            @Override
             public void configure() throws Exception {
-                from(ftpUrl).to("mock:result");
+                from("seda:start").process(new MySlowFileProcessor());
+                from(ftpUrl + "&readLockTimeout=1000").to("mock:result");
             }
-        };
+        });
+        context.start();
+
+        deleteDirectory("./res/home");
+        createDirectory("./res/home/slowfile");
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(0);
+        mock.setMinimumResultWaitTime(2000);
+        mock.setResultWaitTime(5000);
+
+        // send a message to seda:start to trigger the creating of the slowfile to poll
+        template.sendBody("seda:start", "Create the slow file");
+
+        mock.assertIsSatisfied();
+    }
+
+
+    private class MySlowFileProcessor implements Processor {
+
+        public void process(Exchange exchange) throws Exception {
+            LOG.info("Creating a slow file ...");
+            File file = new File("./res/home/slowfile/hello.txt");
+            FileOutputStream fos = new FileOutputStream(file);
+            FileLock lock = fos.getChannel().lock();
+            fos.write("Hello World".getBytes());
+            for (int i = 0; i < 3; i++) {
+                Thread.sleep(1000);
+                fos.write(("Line #" + i).getBytes());
+                LOG.info("Appending to slowfile");
+            }
+            fos.write("Bye World".getBytes());
+            lock.release();
+            fos.close();
+            LOG.info("... done creating slowfile");
+        }
     }
 
 }

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

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

Added: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java?rev=729480&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java (added)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java Fri Dec 26 02:53:10 2008
@@ -0,0 +1,84 @@
+/**
+ * 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.builder.RouteBuilder;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+
+/**
+ * Unit test to test filter option.
+ */
+public class FromFtpFilterTest extends FtpServerTestSupport {
+
+    private int port = 20077;
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/filter?password=admin&binary=false&filter=#myFilter";
+
+    public int getPort() {
+        return port;
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("myFilter", new MyFileFilter());
+        return jndi;
+    }
+
+    public void testFilterFiles() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(0);
+
+        template.sendBodyAndHeader(ftpUrl, "This is a file to be filtered",
+                FileComponent.HEADER_FILE_NAME, "skipme.txt");
+
+        mock.setResultWaitTime(3000);
+        mock.assertIsSatisfied();
+    }
+
+    public void testFilterFilesWithARegularFile() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hello World");
+
+        template.sendBodyAndHeader(ftpUrl, "This is a file to be filtered",
+                FileComponent.HEADER_FILE_NAME, "skipme.txt");
+
+        template.sendBodyAndHeader(ftpUrl, "Hello World",
+                FileComponent.HEADER_FILE_NAME, "hello.txt");
+
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from(ftpUrl).to("mock:result");
+            }
+        };
+    }
+
+    // START SNIPPET: e1
+    public class MyFileFilter implements RemoteFileFilter {
+        public boolean accept(RemoteFile file) {
+            // we dont accept any files starting with skip in the name
+            return !file.getFileName().startsWith("skip");
+        }
+    }
+    // END SNIPPET: e1
+}
\ No newline at end of file

Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java Fri Dec 26 02:53:10 2008
@@ -32,7 +32,7 @@
 
     private int port = 20031;
     private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
-        + "&consumer.moveNamePostfix=.old";
+        + "&moveNamePostfix=.old&consumer.delay=5000";
 
     public int getPort() {
         return port;
@@ -70,7 +70,10 @@
 
         mock.assertIsSatisfied();
 
-        // assert the file is deleted
+        // give some time to move the file after we recieved it on mock
+        Thread.sleep(1000);
+
+        // assert the file is moved
         File file = new File("./res/home/movefile/hello.txt.old");
         file = file.getAbsoluteFile();
         assertTrue("The file should have been moved", file.exists());

Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java Fri Dec 26 02:53:10 2008
@@ -31,8 +31,8 @@
 public class FromFtpMoveFilePrefixTest extends FtpServerTestSupport {
 
     private int port = 20030;
-    private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
-        + "&consumer.moveNamePrefix=done/";
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false&consumer.delay=5000"
+        + "&moveNamePrefix=done/";
 
     public int getPort() {
         return port;
@@ -70,6 +70,9 @@
 
         mock.assertIsSatisfied();
 
+        // give ftp time to move the file
+        Thread.sleep(1000);
+
         // assert the file is deleted
         File file = new File("./res/home/movefile/done/hello.txt");
         file = file.getAbsoluteFile();

Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java Fri Dec 26 02:53:10 2008
@@ -32,7 +32,7 @@
 
     private int port = 20032;
     private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
-        + "&consumer.moveNamePrefix=done/sub2/&consumer.moveNamePostfix=.old";
+        + "&moveNamePrefix=done/sub2/&moveNamePostfix=.old&consumer.delay=5000";
 
     public int getPort() {
         return port;
@@ -70,6 +70,9 @@
 
         mock.assertIsSatisfied();
 
+        // give time to allow ftp consumer to move file after its processed
+        Thread.sleep(1000);
+
         // assert the file is deleted
         File file = new File("./res/home/movefile/done/sub2/hello.txt.old");
         file = file.getAbsoluteFile();

Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java Fri Dec 26 02:53:10 2008
@@ -16,22 +16,15 @@
  */
 package org.apache.camel.component.file.remote;
 
-import java.io.File;
-
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * Unit test to verify polling a server with no files to poll.
  */
 public class FromFtpNoFilesTest extends FtpServerTestSupport {
-
-    private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadTest.class);
-
     private int port = 20020;
-    private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&binary=false&consumer.exclusiveReadLock=true&consumer.delay=500";
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&binary=false&readLock=rename&consumer.delay=500";
 
     public int getPort() {
         return port;
@@ -48,7 +41,6 @@
         mock.assertIsSatisfied();
     }
 
-
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {

Copied: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java (from r729464, activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java?p2=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java&p1=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java&r1=729464&r2=729480&rev=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java Fri Dec 26 02:53:10 2008
@@ -26,12 +26,12 @@
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
- * Unit test to test consumer.deleteFile option.
+ * Unit test to test noop option.
  */
-public class FromFtpDeleteFileTest extends FtpServerTestSupport {
+public class FromFtpNoopTest extends FtpServerTestSupport {
 
-    private int port = 20022;
-    private String ftpUrl = "ftp://admin@localhost:" + port + "/deletefile?password=admin&binary=false&consumer.deleteFile=true";
+    private int port = 20066;
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/noop?password=admin&binary=false&noop=true";
 
     public int getPort() {
         return port;
@@ -48,30 +48,26 @@
         // test that we can pool and store as a local file
         Endpoint endpoint = context.getEndpoint(ftpUrl);
         Exchange exchange = endpoint.createExchange();
-        exchange.getIn().setBody("Hello World this file will be deleted");
+        exchange.getIn().setBody("Hello World");
         exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
         Producer producer = endpoint.createProducer();
         producer.start();
         producer.process(exchange);
         producer.stop();
-
-        // assert file is created
-        File file = new File("./res/home/deletefile/hello.txt");
-        file = file.getAbsoluteFile();
-        assertTrue("The file should exists", file.exists());
     }
 
-    public void testPollFileAndShouldBeDeleted() throws Exception {
+    public void testNoop() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMessageCount(1);
-        mock.expectedBodiesReceived("Hello World this file will be deleted");
-
+        // we should be able to poll the file more than once since its noop
+        mock.expectedMinimumMessageCount(2);
+        mock.setResultWaitTime(5000);
+        
         mock.assertIsSatisfied();
 
-        // assert the file is deleted
-        File file = new File("./res/home/deletefile/hello.txt");
+        // assert the file is still there
+        File file = new File("./res/home/noop/hello.txt");
         file = file.getAbsoluteFile();
-        assertFalse("The file should have been deleted", file.exists());
+        assertTrue("The file should exists", file.exists());
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -82,4 +78,4 @@
         };
     }
 
-}
+}
\ No newline at end of file

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

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

Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPollFileOnlyTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPollFileOnlyTest.java?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPollFileOnlyTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPollFileOnlyTest.java Fri Dec 26 02:53:10 2008
@@ -33,7 +33,6 @@
 
     public void testPollFileOnly() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMinimumMessageCount(1);
         mock.expectedBodiesReceived("Hello World from FTPServer");
 
         mock.assertIsSatisfied();

Added: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java?rev=729480&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java (added)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java Fri Dec 26 02:53:10 2008
@@ -0,0 +1,90 @@
+/**
+ * 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.Processor;
+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;
+
+/**
+ * Unit test to test preMoveExpression option.
+ */
+public class FromFtpPreMoveFileExpressionTest extends FtpServerTestSupport {
+
+    private int port = 20030;
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false&consumer.delay=5000"
+        + "&preMoveExpression=../inprogress/${file:name.noext}.bak";
+
+    public int getPort() {
+        return port;
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        deleteDirectory("./res/home/movefile");
+        prepareFtpServer();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        // prepares the FTP Server by creating a file on the server that we want to unit
+        // test that we can pool and store as a local file
+        Endpoint endpoint = context.getEndpoint(ftpUrl);
+        Exchange exchange = endpoint.createExchange();
+        exchange.getIn().setBody("Hello World this file will be moved");
+        exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
+        Producer producer = endpoint.createProducer();
+        producer.start();
+        producer.process(exchange);
+        producer.stop();
+
+        // assert file is created
+        File file = new File("./res/home/movefile/hello.txt");
+        file = file.getAbsoluteFile();
+        assertTrue("The file should exists", file.exists());
+    }
+
+    public void testPollFileAndShouldBeMoved() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hello World this file will be moved");
+
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from(ftpUrl).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.getAbsoluteFile();
+                        assertTrue("The file should have been moved", file.exists());
+                    }
+                }).to("mock:result");
+            }
+        };
+    }
+
+}
\ No newline at end of file

Copied: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java (from r725331, activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java?p2=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java&p1=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java&r1=725331&r2=729480&rev=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java Fri Dec 26 02:53:10 2008
@@ -26,13 +26,13 @@
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
- * Unit test to test consumer.moveNamePostfix option.
+ * Unit test to test preMoveNamePostfix option.
  */
-public class FromFtpMoveFilePostfixTest extends FtpServerTestSupport {
+public class FromFtpPreMoveFilePostfixTest extends FtpServerTestSupport {
 
     private int port = 20031;
     private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
-        + "&consumer.moveNamePostfix=.old";
+        + "&preMoveNamePostfix=.old";
 
     public int getPort() {
         return port;
@@ -66,11 +66,11 @@
     public void testPollFileAndShouldBeMoved() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
-        mock.expectedBodiesReceived("Hello World this file will be moved");
+        //mock.expectedBodiesReceived("Hello World this file will be moved");
 
         mock.assertIsSatisfied();
 
-        // assert the file is deleted
+        // assert the file is moved
         File file = new File("./res/home/movefile/hello.txt.old");
         file = file.getAbsoluteFile();
         assertTrue("The file should have been moved", file.exists());
@@ -84,4 +84,4 @@
         };
     }
 
-}
+}
\ No newline at end of file

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

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

Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java (from r725331, activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java?p2=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java&p1=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java&r1=725331&r2=729480&rev=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java Fri Dec 26 02:53:10 2008
@@ -26,13 +26,13 @@
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
- * Unit test to test consumer.moveNamePrefix option.
+ * Unit test to test preMoveNamePrefix option.
  */
-public class FromFtpMoveFilePrefixTest extends FtpServerTestSupport {
+public class FromFtpPreMoveFilePrefixTest extends FtpServerTestSupport {
 
     private int port = 20030;
-    private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
-        + "&consumer.moveNamePrefix=done/";
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false&consumer.delay=5000"
+        + "&preMoveNamePrefix=done/";
 
     public int getPort() {
         return port;
@@ -70,7 +70,7 @@
 
         mock.assertIsSatisfied();
 
-        // assert the file is deleted
+        // assert the file is moved
         File file = new File("./res/home/movefile/done/hello.txt");
         file = file.getAbsoluteFile();
         assertTrue("The file should have been moved", file.exists());
@@ -84,4 +84,4 @@
         };
     }
 
-}
+}
\ No newline at end of file

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

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

Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java?rev=729480&r1=729479&r2=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java Fri Dec 26 02:53:10 2008
@@ -27,7 +27,7 @@
 
     private int port = 20097;
 
-    private String ftpUrl = "ftp://admin@localhost:" + port + "/regexp?password=admin&consumer.regexPattern=report.*";
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/regexp?password=admin&regexPattern=report.*";
 
     public void testFtpRegexPattern() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");

Copied: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java (from r726956, activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java?p2=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java&p1=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java&r1=726956&r2=729480&rev=729480&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java Fri Dec 26 02:53:10 2008
@@ -19,20 +19,28 @@
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.file.FileComponent;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
 
 /**
- * Unit test to verify regexPattern option.
+ * Unit test to verify remotefile filter option.
  */
-public class FromFtpRegexPatternTest extends FtpServerTestSupport {
+public class FromFtpRemoteFileFilterTest extends FtpServerTestSupport {
 
-    private int port = 20097;
+    private int port = 20096;
 
-    private String ftpUrl = "ftp://admin@localhost:" + port + "/regexp?password=admin&consumer.regexPattern=report.*";
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/filefilter?password=admin&filter=#myFilter";
 
-    public void testFtpRegexPattern() throws Exception {
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("myFilter", new MyFileFilter());
+        return jndi;
+    }
+
+    public void testFtpFilter() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(2);
-        mock.expectedBodiesReceived("Reports", "Reports");
+        mock.expectedBodiesReceivedInAnyOrder("Report 1", "Report 2");
         mock.assertIsSatisfied();
     }
 
@@ -48,12 +56,12 @@
 
     private void prepareFtpServer() throws Exception {
         // prepares the FTP Server by creating files on the server that we want to unit
-        // test that we can pool and store as a local file
-        String ftpUrl = "ftp://admin@localhost:" + port + "/regexp/?password=admin";
+        // test that we can pool
+        String ftpUrl = "ftp://admin@localhost:" + port + "/filefilter/?password=admin";
         template.sendBodyAndHeader(ftpUrl, "Hello World", FileComponent.HEADER_FILE_NAME, "hello.txt");
-        template.sendBodyAndHeader(ftpUrl, "Reports", FileComponent.HEADER_FILE_NAME, "report1.txt");
+        template.sendBodyAndHeader(ftpUrl, "Report 1", FileComponent.HEADER_FILE_NAME, "report1.txt");
         template.sendBodyAndHeader(ftpUrl, "Bye World", FileComponent.HEADER_FILE_NAME, "bye.txt");
-        template.sendBodyAndHeader(ftpUrl, "Reports", FileComponent.HEADER_FILE_NAME, "report2.txt");
+        template.sendBodyAndHeader(ftpUrl, "Report 2", FileComponent.HEADER_FILE_NAME, "report2.txt");
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -64,4 +72,15 @@
         };
     }
 
-}
+    // START SNIPPET: e1
+    public class MyFileFilter implements RemoteFileFilter {
+
+        public boolean accept(RemoteFile file) {
+            // we only want report files 
+            return file.getFileName().startsWith("report");
+        }
+    }
+    // END SNIPPET: e1
+
+
+}
\ No newline at end of file

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

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

Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java?rev=729480&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java (added)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java Fri Dec 26 02:53:10 2008
@@ -0,0 +1,86 @@
+/**
+ * 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.builder.RouteBuilder;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test to verify remotefile sortby option.
+ */
+public class FromFtpRemoteFileSortByExpressionTest extends FtpServerTestSupport {
+
+    private int port = 20094;
+
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/sortby?password=admin&consumer.delay=5000";
+
+    public int getPort() {
+        return port;
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    public void testSortFiles() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(ftpUrl + "&sortBy=file:name.ext").to("mock:result");
+            }
+        });
+        context.start();
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello Paris", "Hello London", "Hello Copenhagen");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testSortFilesReverse() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(ftpUrl + "&sortBy=reverse:file:name.ext").to("mock:reverse");
+            }
+        });
+        context.start();
+
+        MockEndpoint mock = getMockEndpoint("mock:reverse");
+        mock.expectedBodiesReceived("Hello Copenhagen", "Hello London", "Hello Paris");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        // prepares the FTP Server by creating files on the server that we want to unit
+        // test that we can pool
+        String ftpUrl = "ftp://admin@localhost:" + port + "/sortby/?password=admin";
+        template.sendBodyAndHeader(ftpUrl, "Hello Paris", FileComponent.HEADER_FILE_NAME, "paris.dat");
+        template.sendBodyAndHeader(ftpUrl, "Hello London", FileComponent.HEADER_FILE_NAME, "london.txt");
+        template.sendBodyAndHeader(ftpUrl, "Hello Copenhagen", FileComponent.HEADER_FILE_NAME, "copenhagen.xml");
+    }
+
+}
\ No newline at end of file

Added: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java?rev=729480&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java (added)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java Fri Dec 26 02:53:10 2008
@@ -0,0 +1,101 @@
+/**
+ * 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.builder.RouteBuilder;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test to verify remotefile sortby option.
+ */
+public class FromFtpRemoteFileSortByIgnoreCaseExpressionTest extends FtpServerTestSupport {
+
+    private int port = 20093;
+
+    private String ftpUrl = "ftp://admin@localhost:" + port + "/sortbyignore?password=admin&consumer.delay=5000";
+
+    public int getPort() {
+        return port;
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    public void testSortFiles() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(ftpUrl + "&sortBy=file:name").to("mock:result");
+            }
+        });
+        context.start();
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello London", "Hello Copenhagen", "Hello Paris");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testSortFilesNoCase() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(ftpUrl + "&sortBy=ignoreCase:file:name").to("mock:nocase");
+            }
+        });
+        context.start();
+
+        MockEndpoint nocase = getMockEndpoint("mock:nocase");
+        nocase.expectedBodiesReceived("Hello Copenhagen", "Hello London", "Hello Paris");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testSortFilesNoCaseReverse() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(ftpUrl + "&sortBy=reverse:ignoreCase:file:name").to("mock:nocasereverse");
+            }
+        });
+        context.start();
+
+        MockEndpoint nocasereverse = getMockEndpoint("mock:nocasereverse");
+        nocasereverse.expectedBodiesReceived("Hello Paris", "Hello London", "Hello Copenhagen");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        // prepares the FTP Server by creating files on the server that we want to unit
+        // test that we can pool
+        String ftpUrl = "ftp://admin@localhost:" + port + "/sortbyignore/?password=admin";
+        template.sendBodyAndHeader(ftpUrl, "Hello Paris", FileComponent.HEADER_FILE_NAME, "report-3.dat");
+        template.sendBodyAndHeader(ftpUrl, "Hello London", FileComponent.HEADER_FILE_NAME, "REPORT-2.txt");
+        template.sendBodyAndHeader(ftpUrl, "Hello Copenhagen", FileComponent.HEADER_FILE_NAME, "Report-1.xml");
+    }
+
+}
\ No newline at end of file