You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/01/12 09:30:08 UTC
svn commit: r733650 [3/4] - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/
camel-core/src/main/java/org/apache/camel/component/file/
camel-core/src/main/java/org/apache/camel/model/
camel-core/src/main/java/org/apache/camel/model/...
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/NoOpRemoteFileProcessStrategy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/NoOpRemoteFileProcessStrategy.java?rev=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/NoOpRemoteFileProcessStrategy.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/NoOpRemoteFileProcessStrategy.java Mon Jan 12 00:30:05 2009
@@ -1,21 +1,21 @@
-/**
- * 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;
-
-public class NoOpRemoteFileProcessStrategy extends RemoteFileProcessStrategySupport {
-
-}
+/**
+ * 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;
+
+public class NoOpRemoteFileProcessStrategy extends RemoteFileProcessStrategySupport {
+
+}
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/NoOpRemoteFileProcessStrategy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/NoOpRemoteFileProcessStrategy.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileExpressionRenamer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileExpressionRenamer.java?rev=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileExpressionRenamer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileExpressionRenamer.java Mon Jan 12 00:30:05 2009
@@ -1,46 +1,46 @@
-/**
- * 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.Expression;
-import org.apache.camel.component.file.remote.RemoteFile;
-import org.apache.camel.component.file.remote.RemoteFileExchange;
-import org.apache.camel.util.ObjectHelper;
-
-public class RemoteFileExpressionRenamer implements RemoteFileRenamer {
- private Expression expression;
-
- public RemoteFile renameFile(RemoteFileExchange exchange, RemoteFile file) {
- ObjectHelper.notNull(expression, "expression");
-
- Object eval = expression.evaluate(exchange);
- String newName = exchange.getContext().getTypeConverter().convertTo(String.class, eval);
-
- // clone and change the name
- RemoteFile result = file.clone();
- result.changeFileName(newName);
- return result;
- }
-
- public Expression getExpression() {
- return expression;
- }
-
- public void setExpression(Expression expression) {
- this.expression = expression;
- }
-}
+/**
+ * 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.Expression;
+import org.apache.camel.component.file.remote.RemoteFile;
+import org.apache.camel.component.file.remote.RemoteFileExchange;
+import org.apache.camel.util.ObjectHelper;
+
+public class RemoteFileExpressionRenamer implements RemoteFileRenamer {
+ private Expression expression;
+
+ public RemoteFile renameFile(RemoteFileExchange exchange, RemoteFile file) {
+ ObjectHelper.notNull(expression, "expression");
+
+ Object eval = expression.evaluate(exchange);
+ String newName = exchange.getContext().getTypeConverter().convertTo(String.class, eval);
+
+ // clone and change the name
+ RemoteFile result = file.clone();
+ result.changeFileName(newName);
+ return result;
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+}
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileExpressionRenamer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileExpressionRenamer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: 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=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategyFactory.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategyFactory.java Mon Jan 12 00:30:05 2009
@@ -1,108 +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;
- }
-}
+/**
+ * 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;
+ }
+}
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategyFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategyFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: 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=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategySupport.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategySupport.java Mon Jan 12 00:30:05 2009
@@ -1,58 +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;
- }
-}
-
+/**
+ * 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;
+ }
+}
+
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategySupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileProcessStrategySupport.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: 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=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenameExclusiveReadLockStrategy.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenameExclusiveReadLockStrategy.java Mon Jan 12 00:30:05 2009
@@ -1,101 +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;
- }
-}
+/**
+ * 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;
+ }
+}
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenameExclusiveReadLockStrategy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenameExclusiveReadLockStrategy.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: 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=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenamer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenamer.java Mon Jan 12 00:30:05 2009
@@ -1,36 +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);
-
-}
+/**
+ * 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);
+
+}
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenamer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RemoteFileRenamer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: 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=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RenameRemoteFileProcessStrategy.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RenameRemoteFileProcessStrategy.java Mon Jan 12 00:30:05 2009
@@ -1,112 +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;
- }
-
-}
+/**
+ * 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;
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RenameRemoteFileProcessStrategy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/RenameRemoteFileProcessStrategy.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: 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=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java Mon Jan 12 00:30:05 2009
@@ -1,84 +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
+/**
+ * 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
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: 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=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java Mon Jan 12 00:30:05 2009
@@ -1,90 +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");
- }
- };
- }
-
+/**
+ * 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
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: 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=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java Mon Jan 12 00:30:05 2009
@@ -1,86 +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");
- }
-
+/**
+ * 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
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: 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=733650&r1=733649&r2=733650&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java Mon Jan 12 00:30:05 2009
@@ -1,101 +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");
- }
-
+/**
+ * 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
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date