Author: davsclaus
Date: Thu Jun 30 10:43:02 2011
New Revision: 1141471

URL: http://svn.apache.org/viewvc?rev=1141471&view=rev
Log:
CAMEL-2934: Ported the changed read lock strategy to ftp component. Thanks to 
Laurentiu Trics for patch.

Added:
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpChangedExclusiveReadLockStrategy.java
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpProcessStrategyFactory.java
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpChangedExclusiveReadLockStrategy.java
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpProcessStrategyFactory.java
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/package.html
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTest.java
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTimeoutTest.java
    
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.java
      - copied, changed from r1141420, 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpTest.java
    
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.xml
      - copied, changed from r1141420, 
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/ftp/CamelContext.xml
Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
    
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java
    
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTimeoutTest.java
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
    
camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftp
    
camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftps
    
camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/sftp
    camel/trunk/components/camel-ftp/src/test/resources/log4j.properties

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java?rev=1141471&r1=1141470&r2=1141471&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
 Thu Jun 30 10:43:02 2011
@@ -173,7 +173,9 @@ public abstract class GenericFileEndpoin
 
         try {
             Method factoryMethod = 
factory.getMethod("createGenericFileProcessStrategy", CamelContext.class, 
Map.class);
-            return (GenericFileProcessStrategy<T>) 
ObjectHelper.invokeMethod(factoryMethod, null, getCamelContext(), 
getParamsAsMap());
+            Map<String, Object> params = getParamsAsMap();
+            log.debug("Parameters for Generic file process strategy {}", 
params);
+            return (GenericFileProcessStrategy<T>) 
ObjectHelper.invokeMethod(factoryMethod, null, getCamelContext(), params);
         } catch (NoSuchMethodException e) {
             throw new TypeNotPresentException(factory.getSimpleName() + 
".createGenericFileProcessStrategy method not found", e);
         }

Modified: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java?rev=1141471&r1=1141470&r2=1141471&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java
 (original)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java
 Thu Jun 30 10:43:02 2011
@@ -46,6 +46,7 @@ public class FileChangedReadLockTest ext
 
         String content = context.getTypeConverter().convertTo(String.class, 
new File("target/changed/out/slowfile.dat").getAbsoluteFile());
         String[] lines = content.split("\n");
+        assertEquals("There should be 20 lines in the file", 20, lines.length);
         for (int i = 0; i < 20; i++) {
             assertEquals("Line " + i, lines[i]);
         }

Modified: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTimeoutTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTimeoutTest.java?rev=1141471&r1=1141470&r2=1141471&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTimeoutTest.java
 (original)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTimeoutTest.java
 Thu Jun 30 10:43:02 2011
@@ -28,7 +28,7 @@ public class FileChangedReadLockTimeoutT
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                
from("file:target/changed/in?readLock=changed&readLockTimeout=2000").to("file:target/changed/out",
 "mock:result");
+                
from("file:target/changed/in?readLock=changed&readLockTimeout=2500").to("file:target/changed/out",
 "mock:result");
             }
         };
     }

Modified: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java?rev=1141471&r1=1141470&r2=1141471&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
 Thu Jun 30 10:43:02 2011
@@ -36,11 +36,17 @@ public abstract class RemoteFileEndpoint
 
     public RemoteFileEndpoint() {
         // no args constructor for spring bean endpoint configuration
+        // for ftp we need to use higher interval/checkout that for files
+        setReadLockTimeout(20000);
+        setReadLockCheckInterval(5000);
     }
 
     public RemoteFileEndpoint(String uri, RemoteFileComponent<T> component, 
RemoteFileConfiguration configuration) {
         super(uri, component);
         this.configuration = configuration;
+        // for ftp we need to use higher interval/checkout that for files
+        setReadLockTimeout(20000);
+        setReadLockCheckInterval(5000);
     }
 
     @Override

Added: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpChangedExclusiveReadLockStrategy.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpChangedExclusiveReadLockStrategy.java?rev=1141471&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpChangedExclusiveReadLockStrategy.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpChangedExclusiveReadLockStrategy.java
 Thu Jun 30 10:43:02 2011
@@ -0,0 +1,141 @@
+/**
+ * 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.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.component.file.GenericFileEndpoint;
+import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy;
+import org.apache.camel.component.file.GenericFileOperations;
+import org.apache.camel.util.StopWatch;
+import org.apache.commons.net.ftp.FTPFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FtpChangedExclusiveReadLockStrategy implements 
GenericFileExclusiveReadLockStrategy<FTPFile> {
+    private static final transient Logger LOG = 
LoggerFactory.getLogger(FtpChangedExclusiveReadLockStrategy.class);
+    private long timeout;
+    private long checkInterval = 5000;
+
+    @Override
+    public void prepareOnStartup(GenericFileOperations<FTPFile> 
tGenericFileOperations, GenericFileEndpoint<FTPFile> tGenericFileEndpoint) 
throws Exception {
+        // noop
+    }
+
+    public boolean acquireExclusiveReadLock(GenericFileOperations<FTPFile> 
operations, GenericFile<FTPFile> file, Exchange exchange) throws Exception {
+        boolean exclusive = false;
+
+        LOG.trace("Waiting for exclusive read lock to file: " + file);
+
+        try {
+            long lastModified = Long.MIN_VALUE;
+            long length = Long.MIN_VALUE;
+            StopWatch watch = new StopWatch();
+
+            while (!exclusive) {
+                // timeout check
+                if (timeout > 0) {
+                    long delta = watch.taken();
+                    if (delta > timeout) {
+                        LOG.warn("Cannot acquire read lock within " + timeout 
+ " millis. Will skip the file: " + file);
+                        // we could not get the lock within the timeout 
period, so return false
+                        return false;
+                    }
+                }
+
+                long newLastModified = 0;
+                long newLength = 0;
+                List<FTPFile> files = operations.listFiles(file.getParent());
+                for (FTPFile f : files) {
+                    if (f.getName().equals(file.getFileName())) {
+                        newLastModified = f.getTimestamp().getTimeInMillis();
+                        newLength = f.getSize();
+                    }
+                }
+
+                LOG.trace("Previous last modified: " + lastModified + ", new 
last modified: " + newLastModified);
+                LOG.trace("Previous length: " + length + ", new length: " + 
newLength);
+
+                if (newLastModified == lastModified && newLength == length && 
length != 0) {
+                    // We consider that zero-length files are files in 
progress on some FTP servers
+                    LOG.trace("Read lock acquired.");
+                    exclusive = true;
+                } else {
+                    // set new base file change information
+                    lastModified = newLastModified;
+                    length = newLength;
+
+                    boolean interrupted = sleep();
+                    if (interrupted) {
+                        // we were interrupted while sleeping, we are likely 
being shutdown so return false
+                        return false;
+                    }
+                }
+            }
+        } catch (Exception e) {
+            // must handle IOException as some apps on Windows etc. will still 
somehow hold a lock to a file
+            // such as AntiVirus or MS Office that has special locks for it's 
supported files
+            if (timeout == 0) {
+                // if not using timeout, then we cant retry, so rethrow
+                throw e;
+            }
+            LOG.debug("Cannot acquire read lock. Will try again.", e);
+            boolean interrupted = sleep();
+            if (interrupted) {
+                // we were interrupted while sleeping, we are likely being 
shutdown so return false
+                return false;
+            }
+        }
+
+        return exclusive;
+    }
+
+    private boolean sleep() {
+        LOG.trace("Exclusive read lock not granted. Sleeping for " + 
checkInterval + " millis.");
+        try {
+            Thread.sleep(checkInterval);
+            return false;
+        } catch (InterruptedException e) {
+            LOG.debug("Sleep interrupted while waiting for exclusive read 
lock, so breaking out");
+            return true;
+        }
+    }
+
+    @Override
+    public void releaseExclusiveReadLock(GenericFileOperations<FTPFile> 
tGenericFileOperations, GenericFile<FTPFile> tGenericFile, Exchange exchange) 
throws Exception {
+        // noop
+    }
+
+    public long getTimeout() {
+        return timeout;
+    }
+
+    public void setTimeout(long timeout) {
+        this.timeout = timeout;
+    }
+
+    public long getCheckInterval() {
+        return checkInterval;
+    }
+
+    public void setCheckInterval(long checkInterval) {
+        this.checkInterval = checkInterval;
+    }
+
+}
\ No newline at end of file

Added: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpProcessStrategyFactory.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpProcessStrategyFactory.java?rev=1141471&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpProcessStrategyFactory.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpProcessStrategyFactory.java
 Thu Jun 30 10:43:02 2011
@@ -0,0 +1,127 @@
+/**
+ * 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.CamelContext;
+import org.apache.camel.Expression;
+import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy;
+import org.apache.camel.component.file.GenericFileProcessStrategy;
+import 
org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy;
+import org.apache.camel.component.file.strategy.GenericFileExpressionRenamer;
+import org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy;
+import 
org.apache.camel.component.file.strategy.GenericFileRenameExclusiveReadLockStrategy;
+import 
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy;
+import org.apache.camel.util.ObjectHelper;
+
+public final class FtpProcessStrategyFactory {
+
+    private FtpProcessStrategyFactory() {
+    }
+
+    @SuppressWarnings("unchecked")
+    public static <FTPFile> GenericFileProcessStrategy<FTPFile> 
createGenericFileProcessStrategy(CamelContext context, Map<String, Object> 
params) {
+
+        // We assume a value is present only if its value not null for String 
and 'true' for boolean
+        Expression moveExpression = (Expression) params.get("move");
+        Expression moveFailedExpression = (Expression) 
params.get("moveFailed");
+        Expression preMoveExpression = (Expression) params.get("preMove");
+        boolean isNoop = params.get("noop") != null;
+        boolean isDelete = params.get("delete") != null;
+        boolean isMove = moveExpression != null || preMoveExpression != null 
|| moveFailedExpression != null;
+
+        if (isDelete) {
+            GenericFileDeleteProcessStrategy<FTPFile> strategy = new 
GenericFileDeleteProcessStrategy<FTPFile>();
+            
strategy.setExclusiveReadLockStrategy((GenericFileExclusiveReadLockStrategy<FTPFile>)
 getExclusiveReadLockStrategy(params));
+            if (preMoveExpression != null) {
+                GenericFileExpressionRenamer<FTPFile> renamer = new 
GenericFileExpressionRenamer<FTPFile>();
+                renamer.setExpression(preMoveExpression);
+                strategy.setBeginRenamer(renamer);
+            }
+            if (moveFailedExpression != null) {
+                GenericFileExpressionRenamer<FTPFile> renamer = new 
GenericFileExpressionRenamer<FTPFile>();
+                renamer.setExpression(moveFailedExpression);
+                strategy.setFailureRenamer(renamer);
+            }
+            return strategy;
+        } else if (isMove || isNoop) {
+            GenericFileRenameProcessStrategy<FTPFile> strategy = new 
GenericFileRenameProcessStrategy<FTPFile>();
+            
strategy.setExclusiveReadLockStrategy((GenericFileExclusiveReadLockStrategy<FTPFile>)
 getExclusiveReadLockStrategy(params));
+            if (!isNoop && moveExpression != null) {
+                // move on commit is only possible if not noop
+                GenericFileExpressionRenamer<FTPFile> renamer = new 
GenericFileExpressionRenamer<FTPFile>();
+                renamer.setExpression(moveExpression);
+                strategy.setCommitRenamer(renamer);
+            }
+            // both move and noop supports pre move
+            if (moveFailedExpression != null) {
+                GenericFileExpressionRenamer<FTPFile> renamer = new 
GenericFileExpressionRenamer<FTPFile>();
+                renamer.setExpression(moveFailedExpression);
+                strategy.setFailureRenamer(renamer);
+            }
+            // both move and noop supports pre move
+            if (preMoveExpression != null) {
+                GenericFileExpressionRenamer<FTPFile> renamer = new 
GenericFileExpressionRenamer<FTPFile>();
+                renamer.setExpression(preMoveExpression);
+                strategy.setBeginRenamer(renamer);
+            }
+            return strategy;
+        } else {
+            // default strategy will do nothing
+            GenericFileNoOpProcessStrategy<FTPFile> strategy = new 
GenericFileNoOpProcessStrategy<FTPFile>();
+            
strategy.setExclusiveReadLockStrategy((GenericFileExclusiveReadLockStrategy<FTPFile>)
 getExclusiveReadLockStrategy(params));
+            return strategy;
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private static <FTPFile> GenericFileExclusiveReadLockStrategy<FTPFile> 
getExclusiveReadLockStrategy(Map<String, Object> params) {
+        GenericFileExclusiveReadLockStrategy<FTPFile> strategy = 
(GenericFileExclusiveReadLockStrategy<FTPFile>) 
params.get("exclusiveReadLockStrategy");
+        if (strategy != null) {
+            return strategy;
+        }
+
+        // no explicit strategy 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)) {
+                GenericFileRenameExclusiveReadLockStrategy<FTPFile> 
readLockStrategy = new GenericFileRenameExclusiveReadLockStrategy<FTPFile>();
+                Long timeout = (Long) params.get("readLockTimeout");
+                if (timeout != null) {
+                    readLockStrategy.setTimeout(timeout);
+                }
+                return readLockStrategy;
+            } else if ("changed".equals(readLock)) {
+                GenericFileExclusiveReadLockStrategy readLockStrategy = new 
FtpChangedExclusiveReadLockStrategy();
+                Long timeout = (Long) params.get("readLockTimeout");
+                if (timeout != null) {
+                    readLockStrategy.setTimeout(timeout);
+                }
+                Long checkInterval = (Long) 
params.get("readLockCheckInterval");
+                if (checkInterval != null) {
+                    readLockStrategy.setCheckInterval(checkInterval);
+                }
+                return readLockStrategy;
+            }
+        }
+
+        return null;
+    }
+}

Added: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpChangedExclusiveReadLockStrategy.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpChangedExclusiveReadLockStrategy.java?rev=1141471&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpChangedExclusiveReadLockStrategy.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpChangedExclusiveReadLockStrategy.java
 Thu Jun 30 10:43:02 2011
@@ -0,0 +1,141 @@
+/**
+ * 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.List;
+
+import com.jcraft.jsch.ChannelSftp;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.component.file.GenericFileEndpoint;
+import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy;
+import org.apache.camel.component.file.GenericFileOperations;
+import org.apache.camel.util.StopWatch;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SftpChangedExclusiveReadLockStrategy implements 
GenericFileExclusiveReadLockStrategy<ChannelSftp.LsEntry> {
+    private static final transient Logger LOG = 
LoggerFactory.getLogger(SftpChangedExclusiveReadLockStrategy.class);
+    private long timeout;
+    private long checkInterval = 5000;
+
+    @Override
+    public void prepareOnStartup(GenericFileOperations<ChannelSftp.LsEntry> 
tGenericFileOperations, GenericFileEndpoint<ChannelSftp.LsEntry> 
tGenericFileEndpoint) throws Exception {
+        // noop
+    }
+
+    public boolean 
acquireExclusiveReadLock(GenericFileOperations<ChannelSftp.LsEntry> operations, 
GenericFile<ChannelSftp.LsEntry> file, Exchange exchange) throws Exception {
+        boolean exclusive = false;
+
+        LOG.trace("Waiting for exclusive read lock to file: " + file);
+
+        try {
+            long lastModified = Long.MIN_VALUE;
+            long length = Long.MIN_VALUE;
+            StopWatch watch = new StopWatch();
+
+            while (!exclusive) {
+                // timeout check
+                if (timeout > 0) {
+                    long delta = watch.taken();
+                    if (delta > timeout) {
+                        LOG.warn("Cannot acquire read lock within " + timeout 
+ " millis. Will skip the file: " + file);
+                        // we could not get the lock within the timeout 
period, so return false
+                        return false;
+                    }
+                }
+
+                long newLastModified = 0;
+                long newLength = 0;
+                List<ChannelSftp.LsEntry> files = 
operations.listFiles(file.getParent());
+                for (ChannelSftp.LsEntry f : files) {
+                    if (f.getFilename().equals(file.getFileName())) {
+                        newLastModified = f.getAttrs().getATime();
+                        newLength = f.getAttrs().getSize();
+                    }
+                }
+
+                LOG.trace("Previous last modified: " + lastModified + ", new 
last modified: " + newLastModified);
+                LOG.trace("Previous length: " + length + ", new length: " + 
newLength);
+
+                if (newLastModified == lastModified && newLength == length && 
length != 0) {
+                    // We consider that zero-length files are files in 
progress on some FTP servers
+                    LOG.trace("Read lock acquired.");
+                    exclusive = true;
+                } else {
+                    // set new base file change information
+                    lastModified = newLastModified;
+                    length = newLength;
+
+                    boolean interrupted = sleep();
+                    if (interrupted) {
+                        // we were interrupted while sleeping, we are likely 
being shutdown so return false
+                        return false;
+                    }
+                }
+            }
+        } catch (Exception e) {
+            // must handle IOException as some apps on Windows etc. will still 
somehow hold a lock to a file
+            // such as AntiVirus or MS Office that has special locks for it's 
supported files
+            if (timeout == 0) {
+                // if not using timeout, then we cant retry, so rethrow
+                throw e;
+            }
+            LOG.debug("Cannot acquire read lock. Will try again.", e);
+            boolean interrupted = sleep();
+            if (interrupted) {
+                // we were interrupted while sleeping, we are likely being 
shutdown so return false
+                return false;
+            }
+        }
+
+        return exclusive;
+    }
+
+    private boolean sleep() {
+        LOG.trace("Exclusive read lock not granted. Sleeping for " + 
checkInterval + " millis.");
+        try {
+            Thread.sleep(checkInterval);
+            return false;
+        } catch (InterruptedException e) {
+            LOG.debug("Sleep interrupted while waiting for exclusive read 
lock, so breaking out");
+            return true;
+        }
+    }
+
+    @Override
+    public void 
releaseExclusiveReadLock(GenericFileOperations<ChannelSftp.LsEntry> 
tGenericFileOperations, GenericFile<ChannelSftp.LsEntry> tGenericFile, Exchange 
exchange) throws Exception {
+        // noop
+    }
+
+    public long getTimeout() {
+        return timeout;
+    }
+
+    public void setTimeout(long timeout) {
+        this.timeout = timeout;
+    }
+
+    public long getCheckInterval() {
+        return checkInterval;
+    }
+
+    public void setCheckInterval(long checkInterval) {
+        this.checkInterval = checkInterval;
+    }
+
+}
\ No newline at end of file

Added: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpProcessStrategyFactory.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpProcessStrategyFactory.java?rev=1141471&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpProcessStrategyFactory.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpProcessStrategyFactory.java
 Thu Jun 30 10:43:02 2011
@@ -0,0 +1,128 @@
+/**
+ * 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.CamelContext;
+import org.apache.camel.Expression;
+import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy;
+import org.apache.camel.component.file.GenericFileProcessStrategy;
+import 
org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy;
+import org.apache.camel.component.file.strategy.GenericFileExpressionRenamer;
+import org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy;
+import 
org.apache.camel.component.file.strategy.GenericFileRenameExclusiveReadLockStrategy;
+import 
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy;
+import org.apache.camel.util.ObjectHelper;
+
+public final class SftpProcessStrategyFactory {
+
+    private SftpProcessStrategyFactory() {
+    }
+
+    @SuppressWarnings("unchecked")
+    public static <LsEntry> GenericFileProcessStrategy<LsEntry> 
createGenericFileProcessStrategy(CamelContext context, Map<String, Object> 
params) {
+
+        // We assume a value is present only if its value not null for String 
and 'true' for boolean
+        Expression moveExpression = (Expression) params.get("move");
+        Expression moveFailedExpression = (Expression) 
params.get("moveFailed");
+        Expression preMoveExpression = (Expression) params.get("preMove");
+        boolean isNoop = params.get("noop") != null;
+        boolean isDelete = params.get("delete") != null;
+        boolean isMove = moveExpression != null || preMoveExpression != null 
|| moveFailedExpression != null;
+
+        if (isDelete) {
+            GenericFileDeleteProcessStrategy<LsEntry> strategy = new 
GenericFileDeleteProcessStrategy<LsEntry>();
+            
strategy.setExclusiveReadLockStrategy((GenericFileExclusiveReadLockStrategy<LsEntry>)
 getExclusiveReadLockStrategy(params));
+            if (preMoveExpression != null) {
+                GenericFileExpressionRenamer<LsEntry> renamer = new 
GenericFileExpressionRenamer<LsEntry>();
+                renamer.setExpression(preMoveExpression);
+                strategy.setBeginRenamer(renamer);
+            }
+            if (moveFailedExpression != null) {
+                GenericFileExpressionRenamer<LsEntry> renamer = new 
GenericFileExpressionRenamer<LsEntry>();
+                renamer.setExpression(moveFailedExpression);
+                strategy.setFailureRenamer(renamer);
+            }
+            return strategy;
+        } else if (isMove || isNoop) {
+            GenericFileRenameProcessStrategy<LsEntry> strategy = new 
GenericFileRenameProcessStrategy<LsEntry>();
+            
strategy.setExclusiveReadLockStrategy((GenericFileExclusiveReadLockStrategy<LsEntry>)
 getExclusiveReadLockStrategy(params));
+            if (!isNoop && moveExpression != null) {
+                // move on commit is only possible if not noop
+                GenericFileExpressionRenamer<LsEntry> renamer = new 
GenericFileExpressionRenamer<LsEntry>();
+                renamer.setExpression(moveExpression);
+                strategy.setCommitRenamer(renamer);
+            }
+            // both move and noop supports pre move
+            if (moveFailedExpression != null) {
+                GenericFileExpressionRenamer<LsEntry> renamer = new 
GenericFileExpressionRenamer<LsEntry>();
+                renamer.setExpression(moveFailedExpression);
+                strategy.setFailureRenamer(renamer);
+            }
+            // both move and noop supports pre move
+            if (preMoveExpression != null) {
+                GenericFileExpressionRenamer<LsEntry> renamer = new 
GenericFileExpressionRenamer<LsEntry>();
+                renamer.setExpression(preMoveExpression);
+                strategy.setBeginRenamer(renamer);
+            }
+            return strategy;
+        } else {
+            // default strategy will do nothing
+            GenericFileNoOpProcessStrategy<LsEntry> strategy = new 
GenericFileNoOpProcessStrategy<LsEntry>();
+            
strategy.setExclusiveReadLockStrategy((GenericFileExclusiveReadLockStrategy<LsEntry>)
 getExclusiveReadLockStrategy(params));
+            return strategy;
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private static <LsEntry> GenericFileExclusiveReadLockStrategy<LsEntry> 
getExclusiveReadLockStrategy(Map<String, Object> params) {
+        GenericFileExclusiveReadLockStrategy<LsEntry> strategy = 
(GenericFileExclusiveReadLockStrategy<LsEntry>) 
params.get("exclusiveReadLockStrategy");
+        if (strategy != null) {
+            return strategy;
+        }
+
+        // no explicit strategy 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)) {
+                GenericFileRenameExclusiveReadLockStrategy<LsEntry> 
readLockStrategy = new GenericFileRenameExclusiveReadLockStrategy<LsEntry>();
+                Long timeout = (Long) params.get("readLockTimeout");
+                if (timeout != null) {
+                    readLockStrategy.setTimeout(timeout);
+                }
+                return readLockStrategy;
+            } else if ("changed".equals(readLock)) {
+                GenericFileExclusiveReadLockStrategy readLockStrategy = new 
SftpChangedExclusiveReadLockStrategy();
+                Long timeout = (Long) params.get("readLockTimeout");
+                if (timeout != null) {
+                    readLockStrategy.setTimeout(timeout);
+                }
+                Long checkInterval = (Long) 
params.get("readLockCheckInterval");
+                if (checkInterval != null) {
+                    readLockStrategy.setCheckInterval(checkInterval);
+                }
+                return readLockStrategy;
+            }
+        }
+
+        return null;
+    }
+
+}

Added: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/package.html
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/package.html?rev=1141471&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/package.html
 (added)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/package.html
 Thu Jun 30 10:43:02 2011
@@ -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 FTP Component.
+
+</body>
+</html>

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=1141471&r1=1141470&r2=1141471&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
 Thu Jun 30 10:43:02 2011
@@ -16,4 +16,4 @@
 #
 
 class=org.apache.camel.component.file.remote.FtpComponent
-strategy.factory.class=org.apache.camel.component.file.strategy.GenericFileProcessStrategyFactory
+strategy.factory.class=org.apache.camel.component.file.remote.strategy.FtpProcessStrategyFactory

Modified: 
camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftps
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftps?rev=1141471&r1=1141470&r2=1141471&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftps
 (original)
+++ 
camel/trunk/components/camel-ftp/src/main/resources/META-INF/services/org/apache/camel/component/ftps
 Thu Jun 30 10:43:02 2011
@@ -16,4 +16,4 @@
 #
 
 class=org.apache.camel.component.file.remote.FtpsComponent
-strategy.factory.class=org.apache.camel.component.file.strategy.GenericFileProcessStrategyFactory
+strategy.factory.class=org.apache.camel.component.file.remote.strategy.FtpProcessStrategyFactory

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=1141471&r1=1141470&r2=1141471&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
 Thu Jun 30 10:43:02 2011
@@ -16,4 +16,4 @@
 #
 
 class=org.apache.camel.component.file.remote.SftpComponent
-strategy.factory.class=org.apache.camel.component.file.strategy.GenericFileProcessStrategyFactory
+strategy.factory.class=org.apache.camel.component.file.remote.strategy.SftpProcessStrategyFactory

Added: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTest.java?rev=1141471&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTest.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTest.java
 Thu Jun 30 10:43:02 2011
@@ -0,0 +1,83 @@
+/**
+ * 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 java.io.FileOutputStream;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class FtpChangedReadLockTest extends FtpServerTestSupport {
+
+    private static final transient Logger LOG = 
LoggerFactory.getLogger(FtpChangedReadLockTest.class);
+
+    protected String getFtpUrl() {
+        return "ftp://admin@localhost:"; + getPort() + 
"/changed?password=admin&readLock=changed&readLockCheckInterval=1000&delete=true";
+    }
+
+    @Test
+    public void testChangedReadLock() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedFileExists("target/changed/out/slowfile.dat");
+
+        writeSlowFile();
+
+        assertMockEndpointsSatisfied();
+
+        String content = context.getTypeConverter().convertTo(String.class, 
new File("target/changed/out/slowfile.dat").getAbsoluteFile());
+        String[] lines = content.split("\n");
+        assertEquals("There should be 20 lines in the file", 20, lines.length);
+        for (int i = 0; i < 20; i++) {
+            assertEquals("Line " + i, lines[i]);
+        }
+    }
+
+    private void writeSlowFile() throws Exception {
+        LOG.debug("Writing slow file...");
+
+        createDirectory(FTP_ROOT_DIR + "/changed");
+        FileOutputStream fos = new FileOutputStream(FTP_ROOT_DIR + 
"changed/slowfile.dat", true);
+        for (int i = 0; i < 20; i++) {
+            fos.write(("Line " + i + "\n").getBytes());
+            LOG.debug("Writing line " + i);
+            Thread.sleep(200);
+        }
+
+        fos.flush();
+        fos.close();
+        LOG.debug("Writing slow file DONE...");
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(getFtpUrl()).to("file:target/changed/out", "mock:result");
+            }
+        };
+    }
+
+}

Added: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTimeoutTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTimeoutTest.java?rev=1141471&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTimeoutTest.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTimeoutTest.java
 Thu Jun 30 10:43:02 2011
@@ -0,0 +1,29 @@
+/**
+ * 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;
+
+/**
+ *
+ */
+public class FtpChangedReadLockTimeoutTest extends FtpChangedReadLockTest {
+
+    protected String getFtpUrl() {
+        // will timeout, but the scheduler will pickup the file later
+        return super.getFtpUrl() + "&readLockTimeout=2500";
+    }
+
+}

Modified: camel/trunk/components/camel-ftp/src/test/resources/log4j.properties
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/resources/log4j.properties?rev=1141471&r1=1141470&r2=1141471&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/resources/log4j.properties 
(original)
+++ camel/trunk/components/camel-ftp/src/test/resources/log4j.properties Thu 
Jun 30 10:43:02 2011
@@ -23,6 +23,7 @@ log4j.rootLogger=INFO, file
 # uncomment the following to enable camel debugging
 #log4j.logger.org.apache.camel.component.file=TRACE
 #log4j.logger.org.apache.camel.component.file=DEBUG
+#log4j.logger.org.apache.camel.component.file.remote.strategy=TRACE
 #log4j.logger.org.apache.camel.processor.DefaultErrorHandler=TRACE
 #log4j.logger.org.apache.camel=DEBUG
 log4j.logger.org.apache.mina=WARN

Copied: 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.java
 (from r1141420, 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpTest.java)
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.java?p2=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.java&p1=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpTest.java&r1=1141420&r2=1141471&rev=1141471&view=diff
==============================================================================
--- 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpTest.java
 (original)
+++ 
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.java
 Thu Jun 30 10:43:02 2011
@@ -16,10 +16,8 @@
  */
 package org.apache.camel.itest.osgi.ftp;
 
-import org.apache.camel.Exchange;
 import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport;
 import org.apache.karaf.testing.Helper;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -28,27 +26,24 @@ import org.ops4j.pax.exam.junit.JUnit4Te
 import 
org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
 
 import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.felix;
 import static org.ops4j.pax.exam.OptionUtils.combine;
 import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
 import static 
org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
 
 @RunWith(JUnit4TestRunner.class)
-@Ignore("Not fully implemented, see TODO")
-public class FtpTest extends OSGiIntegrationSpringTestSupport {
+public class FtpConsumeTest extends OSGiIntegrationSpringTestSupport {
 
     @Override
     protected OsgiBundleXmlApplicationContext createApplicationContext() {
-        return new OsgiBundleXmlApplicationContext(new 
String[]{"org/apache/camel/itest/osgi/ftp/CamelContext.xml"});
+        return new OsgiBundleXmlApplicationContext(new 
String[]{"org/apache/camel/itest/osgi/ftp/FtpConsumeTest.xml"});
     }
 
     @Test
     public void testFtp() throws Exception {
-        getMockEndpoint("mock:result").expectedMessageCount(1);
-
-        
template.sendBodyAndHeader("ftp://localhost:21002?username=admin&password=admin";,
 "Hello World", Exchange.FILE_NAME, "hello.txt");
-
-        assertMockEndpointsSatisfied();
+        // just sleep a bit, the ftp consumer cannot connect to the server, but
+        // we just wanna test that the camel-ftp component can create a 
endpoint/consumer in osgi
+        Thread.sleep(3000);
     }
     @Configuration
     public static Option[] configure() throws Exception {
@@ -58,10 +53,6 @@ public class FtpTest extends OSGiIntegra
             // this is how you set the default log level when using pax 
logging (logProfile)
                 Helper.setLogLevel("WARN")),
                 
-            
mavenBundle().groupId("org.apache.mina").artifactId("mina-core").version("2.0.0"),
-            
mavenBundle().groupId("org.apache.ftpserver").artifactId("ftpserver-core").version("1.0.5"),
-            
mavenBundle().groupId("org.apache.ftpserver").artifactId("ftplet-api").version("1.0.5"),
-
             // install the spring, http features first
             scanFeatures(getKarafFeatureUrl(), "spring", "spring-dm", "jetty"),
             
@@ -69,11 +60,9 @@ public class FtpTest extends OSGiIntegra
             scanFeatures(getCamelKarafFeatureUrl(),                         
                           "camel-core", "camel-spring", "camel-test", 
"camel-ftp"),
 
-            // TODO: our app need to import the FTP server stuff
-
             workingDirectory("target/paxrunner/"),
 
-            /*felix(),*/ equinox());
+            felix(), equinox());
         
         return options;
     }

Copied: 
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.xml
 (from r1141420, 
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/ftp/CamelContext.xml)
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.xml?p2=camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.xml&p1=camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/ftp/CamelContext.xml&r1=1141420&r2=1141471&rev=1141471&view=diff
==============================================================================
--- 
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/ftp/CamelContext.xml
 (original)
+++ 
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.xml
 Thu Jun 30 10:43:02 2011
@@ -23,14 +23,11 @@
        http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd";>
 
-    <camelContext xmlns="http://camel.apache.org/schema/spring"; 
depends-on="ftpServer">
+    <camelContext xmlns="http://camel.apache.org/schema/spring";>
         <route>
-            <from uri="ftp://localhost:21002?user=admin&amp;password=admin"/>
+            <from 
uri="ftp://localhost:21003?username=admin&amp;password=admin&amp;readLock=changed"/>
             <to uri="mock:result"/>
         </route>
     </camelContext>
 
-    <bean id="ftpServer" class="org.apache.camel.itest.osgi.ftp.FtpServerBean"
-          init-method="startServer" destroy-method="shutdownServer"/>
-
 </beans>


Reply via email to