CAMEL-8639: Ensure FTP uses the FTP poll strategy by default. Thanks to Rob Sessink for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e8b81a9b Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e8b81a9b Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e8b81a9b Branch: refs/heads/camel-2.15.x Commit: e8b81a9bfc8255fe949f5aebe69d727b1a49daa2 Parents: 42d16b7 Author: Claus Ibsen <davscl...@apache.org> Authored: Sat Jul 18 09:41:02 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sat Jul 18 09:41:38 2015 +0200 ---------------------------------------------------------------------- .../file/remote/RemoteFileEndpoint.java | 6 ++++ ...moteFilePollingConsumerPollStrategyTest.java | 30 ++++++++++++++++++++ 2 files changed, 36 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/e8b81a9b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java index 97a310d..e327292 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java @@ -50,6 +50,9 @@ public abstract class RemoteFileEndpoint<T> extends GenericFileEndpoint<T> { // for ftp we need to use higher interval/checkout that for files setReadLockTimeout(20000); setReadLockCheckInterval(5000); + // explicitly set RemoteFilePollingConsumerPollStrategy otherwise + // DefaultPollingConsumerPollStrategy is be used + setPollStrategy(new RemoteFilePollingConsumerPollStrategy()); } public RemoteFileEndpoint(String uri, RemoteFileComponent<T> component, RemoteFileConfiguration configuration) { @@ -58,6 +61,9 @@ public abstract class RemoteFileEndpoint<T> extends GenericFileEndpoint<T> { // for ftp we need to use higher interval/checkout that for files setReadLockTimeout(20000); setReadLockCheckInterval(5000); + // explicitly set RemoteFilePollingConsumerPollStrategy otherwise + // DefaultPollingConsumerPollStrategy is be used + setPollStrategy(new RemoteFilePollingConsumerPollStrategy()); } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/e8b81a9b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteEndPointRemoteFilePollingConsumerPollStrategyTest.java ---------------------------------------------------------------------- diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteEndPointRemoteFilePollingConsumerPollStrategyTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteEndPointRemoteFilePollingConsumerPollStrategyTest.java new file mode 100644 index 0000000..1d05b97 --- /dev/null +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteEndPointRemoteFilePollingConsumerPollStrategyTest.java @@ -0,0 +1,30 @@ +/** + * 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.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class RemoteEndPointRemoteFilePollingConsumerPollStrategyTest extends CamelTestSupport { + + @Test + public void testPollStrategy() throws Exception { + RemoteFileEndpoint<?> endpoint = context.getEndpoint("ftp://hostname", RemoteFileEndpoint.class); + assertTrue(endpoint.getPollStrategy() instanceof RemoteFilePollingConsumerPollStrategy); + } + +}