camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r752398 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/component/file/ camel-core/src/test/java/org/apache/camel/component/file/ components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/ components/camel-sprin...
Date Wed, 11 Mar 2009 07:31:07 GMT
Author: davsclaus
Date: Wed Mar 11 07:31:06 2009
New Revision: 752398

URL: http://svn.apache.org/viewvc?rev=752398&view=rev
Log:
CAMEL-1440: Simplyfied setting move and preMove options on Camel VFS. So you dont have to
use file language syntax just to move it into a .done folder.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToAbsoluteTest.java
  (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToRelativeTest.java
  (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToAbsoluteTest.java
  (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToRelativeTest.java
  (with props)
    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteTest.java
  (with props)
    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest.java
  (with props)
    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest.java
  (with props)
    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteTest.java
  (with props)
    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeTest.java
      - copied, changed from r752366, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveTest.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
    camel/trunk/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/SingleRouteCamelConfiguration.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java?rev=752398&r1=752397&r2=752398&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
Wed Mar 11 07:31:06 2009
@@ -98,9 +98,10 @@
             answer.setRelativeFilePath(file.getAbsolutePath());
         } else {
             File path;
-            if (file.getPath().startsWith(FileUtil.normalizePath(endpointPath))) {
+            String endpointNormalized = FileUtil.normalizePath(endpointPath);
+            if (file.getPath().startsWith(endpointNormalized)) {
                 // skip duplicate endpoint path
-                path = new File(ObjectHelper.after(file.getPath(), FileUtil.normalizePath(endpointPath)
+ File.separator));
+                path = new File(ObjectHelper.after(file.getPath(), endpointNormalized + File.separator));
             } else {
                 path = new File(file.getPath());
             }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java?rev=752398&r1=752397&r2=752398&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
Wed Mar 11 07:31:06 2009
@@ -94,6 +94,17 @@
         File file = new File(newName);
         boolean absolute = file.isAbsolute();
 
+        if (!absolute) {
+            // for relative then we should avoid having the endpoint path duplicated so clip
it
+            if (ObjectHelper.isNotEmpty(endpointPath) && newName.startsWith(endpointPath))
{
+                // clip starting endpoint in case it was added
+                newName = ObjectHelper.after(newName, endpointPath + getFileSeparator());
+
+                // reconstruct file with clipped name
+                file = new File(newName);
+            }
+        }
+
         // store the file name only
         setFileNameOnly(file.getName());
         setFileName(file.getName());
@@ -112,7 +123,8 @@
         } else {
             setAbsolute(false);
             // construct a pseudo absolute filename that the file operations uses even for
relative only
-            setAbsoluteFilePath(endpointPath + getFileSeparator() + getRelativeFilePath());
+            String path = ObjectHelper.isEmpty(endpointPath) ? "" : endpointPath + getFileSeparator();
+            setAbsoluteFilePath(path + getRelativeFilePath());
         }
 
         if (LOG.isTraceEnabled()) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java?rev=752398&r1=752397&r2=752398&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
Wed Mar 11 07:31:06 2009
@@ -285,7 +285,7 @@
      * @return <tt>true</tt> if the remote file is matched, <tt>false</tt>
if not
      */
     protected boolean isMatched(GenericFile<T> file, boolean isDirectory) {
-        String name = file.getFileName();
+        String name = file.getFileNameOnly();
 
         // folders/names starting with dot is always skipped (eg. ".", ".camel", ".camelLock")
         if (name.startsWith(".")) {
@@ -337,7 +337,7 @@
         if (fileExpressionResult == null) {
             // create a dummy exchange as Exchange is needed for expression evaluation
             Exchange dummy = new DefaultExchange(endpoint.getCamelContext());
-            fileExpressionResult = (String) endpoint.getFileName().evaluate(dummy);
+            fileExpressionResult = endpoint.getFileName().evaluate(dummy, String.class);
         }
     }
 

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=752398&r1=752397&r2=752398&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
Wed Mar 11 07:31:06 2009
@@ -32,6 +32,7 @@
 import org.apache.camel.language.simple.FileLanguage;
 import org.apache.camel.spi.IdempotentRepository;
 import org.apache.camel.util.FactoryFinder;
+import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.UuidGenerator;
 import org.apache.commons.logging.Log;
@@ -198,7 +199,8 @@
      * {@link org.apache.camel.language.simple.FileLanguage}
      */
     public void setMove(String fileLanguageExpression) {
-        this.move = FileLanguage.file(fileLanguageExpression);
+        String expression = configureMoveOrPreMoveExpression(fileLanguageExpression);
+        this.move = FileLanguage.file(expression);
     }
 
     public Expression getPreMove() {
@@ -214,7 +216,8 @@
      * {@link org.apache.camel.language.simple.FileLanguage}
      */
     public void setPreMove(String fileLanguageExpression) {
-        this.preMove = FileLanguage.file(fileLanguageExpression);
+        String expression = configureMoveOrPreMoveExpression(fileLanguageExpression);
+        this.preMove = FileLanguage.file(expression);
     }
 
     public Expression getFileName() {
@@ -387,7 +390,8 @@
         String name = file.isAbsolute() ? file.getAbsoluteFilePath() : file.getRelativeFilePath();
 
         // skip leading endpoint configured directory
-        if (name.startsWith(getConfiguration().getDirectory())) {
+        String endpointPath = getConfiguration().getDirectory();
+        if (ObjectHelper.isNotEmpty(endpointPath) && name.startsWith(endpointPath))
{
             name = ObjectHelper.after(name, getConfiguration().getDirectory() + File.separator);
         }
 
@@ -395,6 +399,40 @@
         message.setHeader(Exchange.FILE_NAME, name);
     }
 
+    /**
+     * Strategy to configure the move or premove option based on a String input.
+     * <p/>
+     * @param expression the original string input
+     * @return configured string or the original if no modifications is needed
+     */
+    protected String configureMoveOrPreMoveExpression(String expression) {
+        // if the expression already have ${ } placeholders then pass it unmodified
+        if (expression.indexOf("${") != -1) {
+            return expression;
+        }
+
+        // remove trailing slash
+        expression = FileUtil.stripTrailingSeparator(expression);
+
+        StringBuilder sb = new StringBuilder();
+
+        // relative or absolute path?
+        File file = new File(expression);
+
+        // if relative then insert start with the parent folder
+        if (!file.isAbsolute()) {
+            sb.append("${file:parent}");
+            sb.append(File.separator);
+        }
+        // insert the directory the end user provided
+        sb.append(expression);
+        // append only the filename (file:name can contain a relative path, so we must use
onlyname)
+        sb.append(File.separator);
+        sb.append("${file:onlyname}");
+
+        return sb.toString();
+    }
+
     protected Map<String, Object> getParamsAsMap() {
         Map<String, Object> params = new HashMap<String, Object>();
 

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToAbsoluteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToAbsoluteTest.java?rev=752398&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToAbsoluteTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToAbsoluteTest.java
Wed Mar 11 07:31:06 2009
@@ -0,0 +1,65 @@
+/**
+ * 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;
+
+import java.io.File;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class FileConsumeSimpleAbsoluteMoveToAbsoluteTest extends ContextTestSupport {
+
+    private String fileUrl = "file://target/move";
+    private String base;
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory("./target/move");
+        // use current dir as base as aboslute path
+        base = new File("").getAbsolutePath() + "/target/move";
+        super.setUp();
+        template.sendBodyAndHeader(fileUrl, "Bye World", Exchange.FILE_NAME, "bye.txt");
+        template.sendBodyAndHeader(fileUrl, "Hello World", Exchange.FILE_NAME, "sub/hello.txt");
+        template.sendBodyAndHeader(fileUrl, "Goodday World", Exchange.FILE_NAME, "sub/sub2/goodday.txt");
+    }
+
+    public void testMoveToSubDir() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(3);
+        // will flattern when using absolute path in move
+        mock.expectedFileExists(base + "/.done/bye.txt");
+        mock.expectedFileExists(base + "/.done/hello.txt");
+        mock.expectedFileExists(base + "/.done/goodday.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file://" + base + "?recursive=true&move=" + base + "/.done").to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToAbsoluteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToAbsoluteTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToRelativeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToRelativeTest.java?rev=752398&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToRelativeTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToRelativeTest.java
Wed Mar 11 07:31:06 2009
@@ -0,0 +1,64 @@
+/**
+ * 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;
+
+import java.io.File;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class FileConsumeSimpleAbsoluteMoveToRelativeTest extends ContextTestSupport {
+
+    private String fileUrl = "file://target/move";
+    private String base;
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory("./target/move");
+        // use current dir as base as aboslute path
+        base = new File("").getAbsolutePath() + "/target/move";
+        super.setUp();
+        template.sendBodyAndHeader(fileUrl, "Bye World", Exchange.FILE_NAME, "bye.txt");
+        template.sendBodyAndHeader(fileUrl, "Hello World", Exchange.FILE_NAME, "sub/hello.txt");
+        template.sendBodyAndHeader(fileUrl, "Goodday World", Exchange.FILE_NAME, "sub/sub2/goodday.txt");
+    }
+
+    public void testMoveToSubDir() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(3);
+        mock.expectedFileExists(base + "/.done/bye.txt");
+        mock.expectedFileExists(base + "/sub/.done/hello.txt");
+        mock.expectedFileExists(base + "/sub/sub2/.done/goodday.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file://" + base + "?recursive=true&move=.done").to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToRelativeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleAbsoluteMoveToRelativeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToAbsoluteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToAbsoluteTest.java?rev=752398&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToAbsoluteTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToAbsoluteTest.java
Wed Mar 11 07:31:06 2009
@@ -0,0 +1,65 @@
+/**
+ * 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;
+
+import java.io.File;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class FileConsumeSimpleRelativeMoveToAbsoluteTest extends ContextTestSupport {
+
+    private String fileUrl = "file://target/move";
+    private String base;
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory("./target/move");
+        // use current dir as base as aboslute path
+        base = new File("").getAbsolutePath() + "/target/move";
+        super.setUp();
+        template.sendBodyAndHeader(fileUrl, "Bye World", Exchange.FILE_NAME, "bye.txt");
+        template.sendBodyAndHeader(fileUrl, "Hello World", Exchange.FILE_NAME, "sub/hello.txt");
+        template.sendBodyAndHeader(fileUrl, "Goodday World", Exchange.FILE_NAME, "sub/sub2/goodday.txt");
+    }
+
+    public void testMoveToSubDir() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(3);
+        // will flattern when using absolute path in move
+        mock.expectedFileExists(base + "/.done/bye.txt");
+        mock.expectedFileExists(base + "/.done/hello.txt");
+        mock.expectedFileExists(base + "/.done/goodday.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file://target/move?recursive=true&move=" + base + "/.done").to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToAbsoluteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToAbsoluteTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToRelativeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToRelativeTest.java?rev=752398&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToRelativeTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToRelativeTest.java
Wed Mar 11 07:31:06 2009
@@ -0,0 +1,59 @@
+/**
+ * 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;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class FileConsumeSimpleRelativeMoveToRelativeTest extends ContextTestSupport {
+
+    private String fileUrl = "file://target/move";
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory("./target/move");
+        super.setUp();
+        template.sendBodyAndHeader(fileUrl, "Bye World", Exchange.FILE_NAME, "bye.txt");
+        template.sendBodyAndHeader(fileUrl, "Hello World", Exchange.FILE_NAME, "sub/hello.txt");
+        template.sendBodyAndHeader(fileUrl, "Goodday World", Exchange.FILE_NAME, "sub/sub2/goodday.txt");
+    }
+
+    public void testMoveToSubDir() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(3);
+        mock.expectedFileExists("./target/move/.done/bye.txt");
+        mock.expectedFileExists("./target/move/sub/.done/hello.txt");
+        mock.expectedFileExists("./target/move/sub/sub2/.done/goodday.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file://target/move?recursive=true&move=.done").to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToRelativeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSimpleRelativeMoveToRelativeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteTest.java?rev=752398&view=auto
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteTest.java
(added)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteTest.java
Wed Mar 11 07:31:06 2009
@@ -0,0 +1,65 @@
+/**
+ * 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.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class FromFtpNoEndpointPathRelativeMoveToAbsoluteTest extends FtpServerTestSupport
{
+
+    private String getFtpUrl() {
+        return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+                + "&move=/.done/${file:name}&initialDelay=2500&delay=5000";
+    }
+
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory(FTP_ROOT_DIR);
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        template.sendBodyAndHeader(getFtpUrl(), "Hello", Exchange.FILE_NAME, "hello.txt");
+        template.sendBodyAndHeader(getFtpUrl(), "Bye", Exchange.FILE_NAME, "sub/bye.txt");
+        template.sendBodyAndHeader(getFtpUrl(), "Goodday", Exchange.FILE_NAME, "sub/sub2/goodday.txt");
+    }
+
+    public void testPollFileAndShouldBeMoved() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
+        mock.expectedFileExists(FTP_ROOT_DIR + ".done/hello.txt");
+        mock.expectedFileExists(FTP_ROOT_DIR + ".done/sub/bye.txt");
+        mock.expectedFileExists(FTP_ROOT_DIR + ".done/sub/sub2/goodday.txt");
+
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from(getFtpUrl()).to("mock:result");
+            }
+        };
+    }
+
+}
\ No newline at end of file

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

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

Added: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest.java?rev=752398&view=auto
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest.java
(added)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest.java
Wed Mar 11 07:31:06 2009
@@ -0,0 +1,65 @@
+/**
+ * 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.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest extends FtpServerTestSupport
{
+
+    private String getFtpUrl() {
+        return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+                + "&move=/.done&initialDelay=2500&delay=5000";
+    }
+
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory(FTP_ROOT_DIR);
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        template.sendBodyAndHeader(getFtpUrl(), "Hello", Exchange.FILE_NAME, "hello.txt");
+        template.sendBodyAndHeader(getFtpUrl(), "Bye", Exchange.FILE_NAME, "sub/bye.txt");
+        template.sendBodyAndHeader(getFtpUrl(), "Goodday", Exchange.FILE_NAME, "sub/sub2/goodday.txt");
+    }
+
+    public void testPollFileAndShouldBeMoved() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
+        mock.expectedFileExists(FTP_ROOT_DIR + ".done/hello.txt");
+        mock.expectedFileExists(FTP_ROOT_DIR + ".done/bye.txt");
+        mock.expectedFileExists(FTP_ROOT_DIR + ".done/goodday.txt");
+
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from(getFtpUrl()).to("mock:result");
+            }
+        };
+    }
+
+}
\ No newline at end of file

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

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

Added: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest.java?rev=752398&view=auto
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest.java
(added)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest.java
Wed Mar 11 07:31:06 2009
@@ -0,0 +1,64 @@
+/**
+ * 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.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest extends FtpServerTestSupport
{
+
+    private String getFtpUrl() {
+        return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+                + "&move=.done&initialDelay=2500&delay=5000";
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory(FTP_ROOT_DIR);
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        template.sendBodyAndHeader(getFtpUrl(), "Hello", Exchange.FILE_NAME, "hello.txt");
+        template.sendBodyAndHeader(getFtpUrl(), "Bye", Exchange.FILE_NAME, "sub/bye.txt");
+        template.sendBodyAndHeader(getFtpUrl(), "Goodday", Exchange.FILE_NAME, "sub/sub2/goodday.txt");
+    }
+
+    public void testPollFileAndShouldBeMoved() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
+        mock.expectedFileExists(FTP_ROOT_DIR + ".done/hello.txt");
+        mock.expectedFileExists(FTP_ROOT_DIR + "sub/.done/bye.txt");
+        mock.expectedFileExists(FTP_ROOT_DIR + "sub/sub2/.done/goodday.txt");
+
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from(getFtpUrl()).to("mock:result");
+            }
+        };
+    }
+
+}
\ No newline at end of file

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

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

Added: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteTest.java?rev=752398&view=auto
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteTest.java
(added)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteTest.java
Wed Mar 11 07:31:06 2009
@@ -0,0 +1,65 @@
+/**
+ * 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.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class FromFtpSimpleRelativeMoveToAbsoluteTest extends FtpServerTestSupport {
+
+    private String getFtpUrl() {
+        return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&recursive=true&binary=false"
+                + "&move=/movefile/.done&initialDelay=2500&delay=5000";
+    }
+
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory(FTP_ROOT_DIR + "movefile");
+        super.setUp();
+        prepareFtpServer();
+    }
+
+    private void prepareFtpServer() throws Exception {
+        template.sendBodyAndHeader(getFtpUrl(), "Hello", Exchange.FILE_NAME, "hello.txt");
+        template.sendBodyAndHeader(getFtpUrl(), "Bye", Exchange.FILE_NAME, "sub/bye.txt");
+        template.sendBodyAndHeader(getFtpUrl(), "Goodday", Exchange.FILE_NAME, "sub/sub2/goodday.txt");
+    }
+
+    public void testPollFileAndShouldBeMoved() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
+        mock.expectedFileExists(FTP_ROOT_DIR + "movefile/.done/hello.txt");
+        mock.expectedFileExists(FTP_ROOT_DIR + "movefile/.done/bye.txt");
+        mock.expectedFileExists(FTP_ROOT_DIR + "movefile/.done/goodday.txt");
+
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from(getFtpUrl()).to("mock:result");
+            }
+        };
+    }
+
+}
\ No newline at end of file

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

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

Copied: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeTest.java
(from r752366, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeTest.java?p2=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeTest.java&p1=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveTest.java&r1=752366&r2=752398&rev=752398&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveTest.java
(original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeTest.java
Wed Mar 11 07:31:06 2009
@@ -21,13 +21,13 @@
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
- * Unit test based on end user problem with SFTP on Windows
+ * @version $Revision$
  */
-public class FromFtpMoveFileAbsoluteFolderRecursiveTest extends FtpServerTestSupport {
+public class FromFtpSimpleRelativeMoveToRelativeTest extends FtpServerTestSupport {
 
     private String getFtpUrl() {
         return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&recursive=true&binary=false"
-                + "&move=/.done/${file:name}.old&initialDelay=2500&delay=5000";
+                + "&move=.done&initialDelay=2500&delay=5000";
     }
 
     @Override
@@ -39,16 +39,16 @@
 
     private void prepareFtpServer() throws Exception {
         template.sendBodyAndHeader(getFtpUrl(), "Hello", Exchange.FILE_NAME, "hello.txt");
-        template.sendBodyAndHeader(getFtpUrl(), "Bye", Exchange.FILE_NAME, "bye/bye.txt");
-        template.sendBodyAndHeader(getFtpUrl(), "Goodday", Exchange.FILE_NAME, "goodday/goodday.txt");
+        template.sendBodyAndHeader(getFtpUrl(), "Bye", Exchange.FILE_NAME, "sub/bye.txt");
+        template.sendBodyAndHeader(getFtpUrl(), "Goodday", Exchange.FILE_NAME, "sub/sub2/goodday.txt");
     }
 
     public void testPollFileAndShouldBeMoved() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
-        mock.expectedFileExists(FTP_ROOT_DIR + ".done/hello.txt.old");
-        mock.expectedFileExists(FTP_ROOT_DIR + ".done/bye/bye.txt.old");
-        mock.expectedFileExists(FTP_ROOT_DIR + ".done/goodday/goodday.txt.old");
+        mock.expectedFileExists(FTP_ROOT_DIR + "movefile/.done/hello.txt");
+        mock.expectedFileExists(FTP_ROOT_DIR + "movefile/sub/.done/bye.txt");
+        mock.expectedFileExists(FTP_ROOT_DIR + "movefile/sub/sub2/.done/goodday.txt");
 
         mock.assertIsSatisfied();
     }

Modified: camel/trunk/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/SingleRouteCamelConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/SingleRouteCamelConfiguration.java?rev=752398&r1=752397&r2=752398&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/SingleRouteCamelConfiguration.java
(original)
+++ camel/trunk/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/SingleRouteCamelConfiguration.java
Wed Mar 11 07:31:06 2009
@@ -30,6 +30,7 @@
  * @version $Revision$
  */
 public abstract class SingleRouteCamelConfiguration extends CamelConfiguration {
+
     @Bean
     public List<RouteBuilder> routes() {
         return Collections.singletonList(route());
@@ -37,7 +38,6 @@
 
     /**
      * Creates the single {@link RouteBuilder} to use in this confguration
-     * @return
      */
     public abstract RouteBuilder route();
 }



Mime
View raw message