Author: davsclaus
Date: Fri Dec  5 12:46:02 2008
New Revision: 723860

URL: http://svn.apache.org/viewvc?rev=723860&view=rev
Log:
Merged revisions 723835 via svnmerge from 
https://svn.apache.org/repos/asf/activemq/camel/trunk

........
  r723835 | davsclaus | 2008-12-05 20:44:08 +0100 (fr, 05 dec 2008) | 1 line
  
  CAMEL-1148: Added options pre move options to move file before processing
........

Added:
    
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java
   (contents, props changed)
      - copied, changed from r723835, 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java
    
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java
   (contents, props changed)
      - copied, changed from r723835, 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java
    
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java
   (contents, props changed)
      - copied, changed from r723835, 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java
    
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
   (contents, props changed)
      - copied, changed from r723835, 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
    
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCommitRenameStrategyTest.java
      - copied unchanged from r723835, 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCommitRenameStrategyTest.java
Removed:
    
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameStrategyTest.java
Modified:
    activemq/camel/branches/camel-1.x/   (props changed)
    
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
    
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
    
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileExchange.java
    
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java
    
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/strategy/RenameFileProcessStrategy.java

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec  5 12:46:02 2008
@@ -1 +1 @@
-/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409
+/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java?rev=723860&r1=723859&r2=723860&view=diff
==============================================================================
--- 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
 (original)
+++ 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
 Fri Dec  5 12:46:02 2008
@@ -112,47 +112,49 @@
     /**
      * Polls the given file
      *
-     * @param file  the file
+     * @param target  the file
      * @return returns 1 if the file was processed, 0 otherwise.
      */
-    protected int pollFile(final File file) {
+    protected int pollFile(final File target) {
         if (LOG.isTraceEnabled()) {
-            LOG.trace("Polling file: " + file);
+            LOG.trace("Polling file: " + target);
         }
 
-        if (!file.exists()) {
+        if (!target.exists()) {
             return 0;
         }
-        if (!isValidFile(file)) {
+        if (!isValidFile(target)) {
             return 0;
         }
         // we only care about file modified times if we are not 
deleting/moving files
         if (!endpoint.isNoop()) {
-            if (filesBeingProcessed.contains(file)) {
+            if (filesBeingProcessed.contains(target)) {
                 return 1;
             }
-            filesBeingProcessed.put(file, file);
+            filesBeingProcessed.put(target, target);
         }
 
         final FileProcessStrategy processStrategy = endpoint.getFileStrategy();
-        final FileExchange exchange = endpoint.createExchange(file);
+        final FileExchange exchange = endpoint.createExchange(target);
 
-        endpoint.configureMessage(file, exchange.getIn());
+        endpoint.configureMessage(target, exchange.getIn());
         try {
             // is we use excluse read then acquire the exclusive read (waiting 
until we got it)
             if (exclusiveReadLock) {
-                acquireExclusiveReadLock(file);
+                acquireExclusiveReadLock(target);
             }
 
             if (LOG.isDebugEnabled()) {
-                LOG.debug("About to process file: " + file + " using exchange: 
" + exchange);
+                LOG.debug("About to process file: " + target + " using 
exchange: " + exchange);
             }
-            if (processStrategy.begin(endpoint, exchange, file)) {
+            if (processStrategy.begin(endpoint, exchange, target)) {
 
                 // Use the async processor interface so that processing of
                 // the exchange can happen asynchronously
                 getAsyncProcessor().process(exchange, new AsyncCallback() {
                     public void done(boolean sync) {
+                        // must use file from exchange as it can be updated 
due the preMoveNamePrefix/preMoveNamePostfix options
+                        final File file = exchange.getFile();
                         boolean failed = exchange.isFailed();
                         boolean handled = 
DeadLetterChannel.isFailureHandled(exchange);
 
@@ -180,9 +182,7 @@
                 });
 
             } else {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug(endpoint + " can not process file: " + file);
-                }
+                LOG.warn(endpoint + " can not process file: " + target);
             }
         } catch (Throwable e) {
             handleException(e);

Modified: 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=723860&r1=723859&r2=723860&view=diff
==============================================================================
--- 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
 (original)
+++ 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
 Fri Dec  5 12:46:02 2008
@@ -60,11 +60,14 @@
     private String moveNamePostfix;
     private String[] excludedNamePrefixes;
     private String[] excludedNamePostfixes;
+    private String preMoveNamePrefix;
+    private String preMoveNamePostfix;
     private String excludedNamePrefix;
     private String excludedNamePostfix;
     private int bufferSize = 128 * 1024;
     private boolean ignoreFileNameHeader;
     private Expression expression;
+    private Expression preMoveExpression;
 
     protected FileEndpoint(File file, String endpointUri, FileComponent 
component) {
         super(endpointUri, component);
@@ -90,6 +93,11 @@
 
     public Consumer<FileExchange> createConsumer(Processor processor) throws 
Exception {
         Consumer<FileExchange> result = new FileConsumer(this, processor);
+
+        if (isDelete() && (getMoveNamePrefix() != null || getMoveNamePostfix() 
!= null || getExpression() != null)) {
+            throw new IllegalArgumentException("You cannot set delet and a 
moveNamePrefix, moveNamePostfix or expression option");
+        }
+        
         configureConsumer(result);
         return result;
     }
@@ -245,6 +253,31 @@
         this.excludedNamePostfixes = excludedNamePostfixes;
     }
 
+    public String getPreMoveNamePrefix() {
+        return preMoveNamePrefix;
+    }
+
+    public void setPreMoveNamePrefix(String preMoveNamePrefix) {
+        this.preMoveNamePrefix = preMoveNamePrefix;
+    }
+
+    /**
+     * Sets the name prefix appended to pre moved files. For example to move
+     * files before processing into a inprogress directory called 
<tt>.inprogress</tt> set this value to
+     * <tt>.inprogress/</tt>
+     */
+    public String getPreMoveNamePostfix() {
+        return preMoveNamePostfix;
+    }
+
+    /**
+     * Sets the name postfix appended to pre moved files. For example to rename
+     * files before processing from <tt>*</tt> to <tt>*.inprogress</tt> set 
this value to <tt>.inprogress</tt>
+     */
+    public void setPreMoveNamePostfix(String preMoveNamePostfix) {
+        this.preMoveNamePostfix = preMoveNamePostfix;
+    }
+
     public boolean isNoop() {
         return noop;
     }
@@ -324,6 +357,21 @@
         this.expression = FileLanguage.file(fileLanguageExpression);
     }
 
+    public Expression getPreMoveExpression() {
+        return preMoveExpression;
+    }
+
+    public void setPreMoveExpression(Expression expression) {
+        this.preMoveExpression = expression;
+    }
+
+    /**
+     * Sets the pre move expression based on [EMAIL PROTECTED] FileLanguage}
+     */
+    public void setPreMoveExpression(String fileLanguageExpression) {
+        this.preMoveExpression = FileLanguage.file(fileLanguageExpression);
+    }
+
     /**
      * A strategy method to lazily create the file strategy
      */
@@ -376,9 +424,18 @@
         if (moveNamePostfix != null) {
             params.put("moveNamePostfix", moveNamePostfix);
         }
+        if (preMoveNamePrefix != null) {
+            params.put("preMoveNamePrefix", preMoveNamePrefix);
+        }
+        if (preMoveNamePostfix != null) {
+            params.put("preMoveNamePostfix", preMoveNamePostfix);
+        }
         if (expression != null) {
             params.put("expression", expression);
         }
+        if (preMoveExpression != null) {
+            params.put("preMoveExpression", preMoveExpression);
+        }
 
         return params;
     }

Modified: 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileExchange.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileExchange.java?rev=723860&r1=723859&r2=723860&view=diff
==============================================================================
--- 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileExchange.java
 (original)
+++ 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/FileExchange.java
 Fri Dec  5 12:46:02 2008
@@ -35,9 +35,29 @@
 
     public FileExchange(CamelContext camelContext, ExchangePattern pattern, 
File file) {
         super(camelContext, pattern);
+        setFile(file);
+    }
+
+    public FileExchange(DefaultExchange parent, File file) {
+        super(parent);
+        setFile(file);
+    }
+
+    public File getFile() {
+        return this.file;
+    }
+
+    public void setFile(File file) {
         setIn(new FileMessage(file));
         this.file = file;
+        populateHeaders(file);
+    }
+
+    public Exchange newInstance() {
+        return new FileExchange(this, getFile());
+    }
 
+    private void populateHeaders(File file) {
         // set additional headers with file information
         if (file != null) {
             getIn().setHeader("CamelFileName", file.getName());
@@ -58,21 +78,4 @@
         }
     }
 
-    public FileExchange(DefaultExchange parent, File file) {
-        super(parent);
-        this.file = file;
-    }
-
-    public File getFile() {
-        return this.file;
-    }
-
-    public void setFile(File file) {
-        this.file = file;
-    }
-
-    public Exchange newInstance() {
-        return new FileExchange(this, getFile());
-    }
-
 }

Modified: 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java?rev=723860&r1=723859&r2=723860&view=diff
==============================================================================
--- 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java
 (original)
+++ 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java
 Fri Dec  5 12:46:02 2008
@@ -40,26 +40,41 @@
         boolean isLock = params.get("lock") != 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 (params.containsKey("noop")) {
             return new NoOpFileProcessStrategy(isLock);
-        } else if (moveNamePostfix != null || moveNamePrefix != null) {
-            if (isDelete) {
-                throw new IllegalArgumentException("You cannot set the 
deleteFiles property "
-                    + "and a moveFilenamePostfix or moveFilenamePrefix");
+        } else if (move || preMove) {
+            RenameFileProcessStrategy strategy = new 
RenameFileProcessStrategy(isLock);
+            if (move) {
+                strategy.setCommitRenamer(new 
DefaultFileRenamer(moveNamePrefix, moveNamePostfix));
             }
-            return new RenameFileProcessStrategy(isLock, moveNamePrefix, 
moveNamePostfix);
-        } else if (expression != null) {
-            FileExpressionRenamer renamer = new FileExpressionRenamer();
-            renamer.setExpression(expression);
-
+            if (preMove) {
+                strategy.setBeginRenamer(new 
DefaultFileRenamer(preMoveNamePrefix, preMoveNamePostfix));
+            }
+            return strategy;
+        } else if (expression != null || preMoveExpression != null) {
             RenameFileProcessStrategy strategy = new 
RenameFileProcessStrategy(isLock);
-            strategy.setRenamer(renamer);
+            if (expression != null) {
+                FileExpressionRenamer renamer = new FileExpressionRenamer();
+                renamer.setExpression(expression);
+                strategy.setCommitRenamer(renamer);
+            }
+            if (preMoveExpression != null) {
+                FileExpressionRenamer renamer = new FileExpressionRenamer();
+                renamer.setExpression(preMoveExpression);
+                strategy.setBeginRenamer(renamer);
+            }
             return strategy;
         } else if (isDelete) {
             return new DeleteFileProcessStrategy(isLock);
         } else {
+            // default strategy will move to .camel subfolder
             return new RenameFileProcessStrategy(isLock);
         }
     }

Modified: 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/strategy/RenameFileProcessStrategy.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/strategy/RenameFileProcessStrategy.java?rev=723860&r1=723859&r2=723860&view=diff
==============================================================================
--- 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/strategy/RenameFileProcessStrategy.java
 (original)
+++ 
activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/file/strategy/RenameFileProcessStrategy.java
 Fri Dec  5 12:46:02 2008
@@ -31,7 +31,8 @@
  */
 public class RenameFileProcessStrategy extends FileProcessStrategySupport {
     private static final transient Log LOG = 
LogFactory.getLog(RenameFileProcessStrategy.class);
-    private FileRenamer renamer;
+    private FileRenamer beginRenamer;
+    private FileRenamer commitRenamer;
 
     public RenameFileProcessStrategy() {
         this(true);
@@ -42,42 +43,85 @@
     }
 
     public RenameFileProcessStrategy(boolean lock, String namePrefix, String 
namePostfix) {
-        this(lock, new DefaultFileRenamer(namePrefix, namePostfix));
+        this(lock, new DefaultFileRenamer(namePrefix, namePostfix), null);
     }
 
-    public RenameFileProcessStrategy(boolean lock, FileRenamer renamer) {
+    public RenameFileProcessStrategy(boolean lock, String namePrefix, String 
namePostfix, String preNamePrefix, String preNamePostfix) {
+        this(lock, new DefaultFileRenamer(namePrefix, namePostfix), new 
DefaultFileRenamer(preNamePrefix, preNamePostfix));
+    }
+
+    public RenameFileProcessStrategy(boolean lock, FileRenamer commitRenamer, 
FileRenamer beginRenamer) {
         super(lock);
-        this.renamer = renamer;
+        this.commitRenamer = commitRenamer;
+        this.beginRenamer = beginRenamer;
+    }
+
+    @Override
+    public boolean begin(FileEndpoint endpoint, FileExchange exchange, File 
file) throws Exception {
+        boolean answer = super.begin(endpoint, exchange, file);
+
+        if (beginRenamer != null) {
+            File newName = beginRenamer.renameFile(exchange, file);
+            // deleting any existing files before renaming
+            File to = renameFile(file, newName);
+            exchange.setFile(to);
+        }
+
+        return answer;
     }
 
     @Override
     public void commit(FileEndpoint endpoint, FileExchange exchange, File 
file) throws Exception {
-        File newName = renamer.renameFile(exchange, file);
+        File newName = commitRenamer.renameFile(exchange, file);
+        renameFile(file, newName);
+
+        // must commit to release the lock
+        super.commit(endpoint, exchange, file);
+    }
+
+    private static File renameFile(File from, File to) throws IOException {
         // deleting any existing files before renaming
-        if (newName.exists()) {
-            newName.delete();
+        if (to.exists()) {
+            to.delete();
         }
 
         // make parent folder if missing
-        newName.getParentFile().mkdirs();
+        File parent = to.getParentFile();
+        if (!parent.exists()) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Creating directory: " + parent);
+            }
+            boolean mkdir = parent.mkdirs();
+            if (!mkdir) {
+                throw new IOException("Can not create directory: " + parent);
+            }
+        }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Renaming file: " + file + " to: " + newName);
+            LOG.debug("Renaming file: " + from + " to: " + to);
         }
-        boolean renamed = file.renameTo(newName);
+        boolean renamed = from.renameTo(to);
         if (!renamed) {
-            throw new IOException("Can not rename file from: " + file + " to: 
" + newName);
+            throw new IOException("Can not rename file from: " + from + " to: 
" + to);
         }
 
-        // must commit to release the lock
-        super.commit(endpoint, exchange, file);
+        return to;
     }
 
-    public FileRenamer getRenamer() {
-        return renamer;
+    public FileRenamer getBeginRenamer() {
+        return beginRenamer;
     }
 
-    public void setRenamer(FileRenamer renamer) {
-        this.renamer = renamer;
+    public void setBeginRenamer(FileRenamer beginRenamer) {
+        this.beginRenamer = beginRenamer;
     }
+
+    public FileRenamer getCommitRenamer() {
+        return commitRenamer;
+    }
+
+    public void setCommitRenamer(FileRenamer commitRenamer) {
+        this.commitRenamer = commitRenamer;
+    }
+
 }
\ No newline at end of file

Copied: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java
 (from r723835, 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java)
URL: 
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java?p2=activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java&r1=723835&r2=723860&rev=723860&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java
 (original)
+++ 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java
 Fri Dec  5 12:46:02 2008
@@ -1,82 +1,82 @@
-/**
- * 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.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.converter.IOConverter;
-
-/**
- * Unit test for the FileRenameStrategy using preMoveExpression and expression 
options
- */
-public class FileConsumerBeginAndCommitExpressionRenameStrategyTest extends 
ContextTestSupport {
-
-    public void testRenameSuccess() throws Exception {
-        deleteDirectory("target/inprogress");
-        deleteDirectory("target/done");
-        deleteDirectory("target/reports");
-
-        MockEndpoint mock = getMockEndpoint("mock:report");
-        mock.expectedMessageCount(1);
-        mock.expectedBodiesReceived("Hello Paris");
-
-        template.sendBodyAndHeader("file:target/reports", "Hello Paris", 
FileComponent.HEADER_FILE_NAME, "paris.txt");
-
-        mock.assertIsSatisfied();
-
-        // sleep to let the file consumer do its renaming
-        Thread.sleep(100);
-
-        // content of file should be Hello Paris
-        String content = IOConverter.toString(new 
File("./target/done/paris.bak"));
-        assertEquals("The file should have been renamed", "Hello Paris", 
content);
-    }
-
-    public void testIllegalOptions() throws Exception {
-        try {
-            
context.getEndpoint("file://target?expression=../done/${file:name}&delete=true").createConsumer(new
 Processor() {
-                public void process(Exchange exchange) throws Exception {
-                }
-            });
-            fail("Should have thrown an exception");
-        } catch (IllegalArgumentException e) {
-            // ok
-        }
-    }
-
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            public void configure() throws Exception {
-                
from("file://target/reports?preMoveExpression=../inprogress/${file:name.noext}.bak&expression=../done/${file:name}&consumer.delay=5000")
-                        .process(new Processor() {
-                            public void process(Exchange exchange) throws 
Exception {
-                                FileExchange fe = (FileExchange) exchange;
-                                assertEquals("The file should have been move 
to inprogress",
-                                        "inprogress", 
fe.getFile().getParentFile().getName());
-                            }
-                        })
-                        .to("mock:report");
-            }
-        };
-    }
-
+/**
+ * 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.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.IOConverter;
+
+/**
+ * Unit test for the FileRenameStrategy using preMoveExpression and expression 
options
+ */
+public class FileConsumerBeginAndCommitExpressionRenameStrategyTest extends 
ContextTestSupport {
+
+    public void testRenameSuccess() throws Exception {
+        deleteDirectory("target/inprogress");
+        deleteDirectory("target/done");
+        deleteDirectory("target/reports");
+
+        MockEndpoint mock = getMockEndpoint("mock:report");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hello Paris");
+
+        template.sendBodyAndHeader("file:target/reports", "Hello Paris", 
FileComponent.HEADER_FILE_NAME, "paris.txt");
+
+        mock.assertIsSatisfied();
+
+        // sleep to let the file consumer do its renaming
+        Thread.sleep(100);
+
+        // content of file should be Hello Paris
+        String content = IOConverter.toString(new 
File("./target/done/paris.bak"));
+        assertEquals("The file should have been renamed", "Hello Paris", 
content);
+    }
+
+    public void testIllegalOptions() throws Exception {
+        try {
+            
context.getEndpoint("file://target?expression=../done/${file:name}&delete=true").createConsumer(new
 Processor() {
+                public void process(Exchange exchange) throws Exception {
+                }
+            });
+            fail("Should have thrown an exception");
+        } catch (IllegalArgumentException e) {
+            // ok
+        }
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                
from("file://target/reports?preMoveExpression=../inprogress/${file:name.noext}.bak&expression=../done/${file:name}&consumer.delay=5000")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws 
Exception {
+                                FileExchange fe = (FileExchange) exchange;
+                                assertEquals("The file should have been move 
to inprogress",
+                                        "inprogress", 
fe.getFile().getParentFile().getName());
+                            }
+                        })
+                        .to("mock:report");
+            }
+        };
+    }
+
 }
\ No newline at end of file

Propchange: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitExpressionRenameStrategyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java
 (from r723835, 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java)
URL: 
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java?p2=activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java&r1=723835&r2=723860&rev=723860&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java
 (original)
+++ 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java
 Fri Dec  5 12:46:02 2008
@@ -1,92 +1,92 @@
-/**
- * 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.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.converter.IOConverter;
-
-/**
- * Unit test for the FileRenameStrategy using preMove and move options
- */
-public class FileConsumerBeginAndCommitRenameStrategyTest extends 
ContextTestSupport {
-
-    public void testRenameSuccess() throws Exception {
-        deleteDirectory("target/inprogress");
-        deleteDirectory("target/done");
-        deleteDirectory("target/reports");
-
-        MockEndpoint mock = getMockEndpoint("mock:report");
-        mock.expectedMessageCount(1);
-        mock.expectedBodiesReceived("Hello Paris");
-
-        template.sendBodyAndHeader("file:target/reports", "Hello Paris", 
FileComponent.HEADER_FILE_NAME, "paris.txt");
-
-        mock.assertIsSatisfied();
-
-        // sleep to let the file consumer do its renaming
-        Thread.sleep(100);
-
-        // content of file should be Hello Paris
-        String content = IOConverter.toString(new 
File("./target/done/paris.txt"));
-        assertEquals("The file should have been renamed", "Hello Paris", 
content);
-    }
-
-    public void testIllegalOptions() throws Exception {
-        try {
-            
context.getEndpoint("file://target?moveNamePrefix=../done/&delete=true").createConsumer(new
 Processor() {
-                public void process(Exchange exchange) throws Exception {
-                }
-            });
-            fail("Should have thrown an exception");
-        } catch (IllegalArgumentException e) {
-            // ok
-        }
-
-        try {
-            
context.getEndpoint("file://target?expression=${file:name.noext}.bak&delete=true").createConsumer(new
 Processor() {
-                public void process(Exchange exchange) throws Exception {
-                }
-            });
-            fail("Should have thrown an exception");
-        } catch (IllegalArgumentException e) {
-            // ok
-        }
-    }
-
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            public void configure() throws Exception {
-                
from("file://target/reports?preMoveNamePrefix=../inprogress/&moveNamePrefix=../done/&consumer.delay=5000")
-                        .process(new Processor() {
-                            public void process(Exchange exchange) throws 
Exception {
-                                FileExchange fe = (FileExchange) exchange;
-                                assertEquals("The file should have been move 
to inprogress",
-                                        "inprogress", 
fe.getFile().getParentFile().getName());
-                            }
-                        })
-                        .to("mock:report");
-            }
-        };
-    }
-
+/**
+ * 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.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.IOConverter;
+
+/**
+ * Unit test for the FileRenameStrategy using preMove and move options
+ */
+public class FileConsumerBeginAndCommitRenameStrategyTest extends 
ContextTestSupport {
+
+    public void testRenameSuccess() throws Exception {
+        deleteDirectory("target/inprogress");
+        deleteDirectory("target/done");
+        deleteDirectory("target/reports");
+
+        MockEndpoint mock = getMockEndpoint("mock:report");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hello Paris");
+
+        template.sendBodyAndHeader("file:target/reports", "Hello Paris", 
FileComponent.HEADER_FILE_NAME, "paris.txt");
+
+        mock.assertIsSatisfied();
+
+        // sleep to let the file consumer do its renaming
+        Thread.sleep(100);
+
+        // content of file should be Hello Paris
+        String content = IOConverter.toString(new 
File("./target/done/paris.txt"));
+        assertEquals("The file should have been renamed", "Hello Paris", 
content);
+    }
+
+    public void testIllegalOptions() throws Exception {
+        try {
+            
context.getEndpoint("file://target?moveNamePrefix=../done/&delete=true").createConsumer(new
 Processor() {
+                public void process(Exchange exchange) throws Exception {
+                }
+            });
+            fail("Should have thrown an exception");
+        } catch (IllegalArgumentException e) {
+            // ok
+        }
+
+        try {
+            
context.getEndpoint("file://target?expression=${file:name.noext}.bak&delete=true").createConsumer(new
 Processor() {
+                public void process(Exchange exchange) throws Exception {
+                }
+            });
+            fail("Should have thrown an exception");
+        } catch (IllegalArgumentException e) {
+            // ok
+        }
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                
from("file://target/reports?preMoveNamePrefix=../inprogress/&moveNamePrefix=../done/&consumer.delay=5000")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws 
Exception {
+                                FileExchange fe = (FileExchange) exchange;
+                                assertEquals("The file should have been move 
to inprogress",
+                                        "inprogress", 
fe.getFile().getParentFile().getName());
+                            }
+                        })
+                        .to("mock:report");
+            }
+        };
+    }
+
 }
\ No newline at end of file

Propchange: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginAndCommitRenameStrategyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java
 (from r723835, 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java)
URL: 
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java?p2=activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java&r1=723835&r2=723860&rev=723860&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java
 (original)
+++ 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java
 Fri Dec  5 12:46:02 2008
@@ -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;
-
-import java.io.File;
-import java.io.FileWriter;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test for the FileRenameStrategy using preMoveExpression options
- */
-public class FileConsumerBeginExpressionRenameStrategyTest extends 
ContextTestSupport {
-
-    public void testRenameSuccess() throws Exception {
-        deleteDirectory("target/inprogress");
-        deleteDirectory("target/reports");
-
-        MockEndpoint mock = getMockEndpoint("mock:report");
-        mock.expectedMessageCount(1);
-        mock.expectedBodiesReceived("Hello Paris");
-
-        template.sendBodyAndHeader("file:target/reports", "Hello Paris", 
FileComponent.HEADER_FILE_NAME, "paris.txt");
-
-        Thread.sleep(100);
-
-        mock.assertIsSatisfied();
-    }
-
-    public void testRenameFileExists() throws Exception {
-        deleteDirectory("target/inprogress");
-        deleteDirectory("target/reports");
-
-        // create a file in inprogress to let there be a duplicate file
-        File file = new File("target/inprogress");
-        file.mkdirs();
-        FileWriter fw = new FileWriter("./target/inprogress/london.bak");
-        fw.write("I was there once in London");
-        fw.flush();
-        fw.close();
-
-        MockEndpoint mock = getMockEndpoint("mock:report");
-        mock.expectedBodiesReceived("Hello London");
-
-        template.sendBodyAndHeader("file:target/reports", "Hello London", 
FileComponent.HEADER_FILE_NAME, "london.txt");
-
-        Thread.sleep(100);
-
-        mock.assertIsSatisfied();
-    }
-
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            public void configure() throws Exception {
-                
from("file://target/reports?preMoveExpression=../inprogress/${file:name.noext}.bak&consumer.delay=5000")
-                        .process(new Processor() {
-                            public void process(Exchange exchange) throws 
Exception {
-                                FileExchange fe = (FileExchange) exchange;
-                                assertEquals("The file should have been move 
to inprogress",
-                                        "inprogress", 
fe.getFile().getParentFile().getName());
-                            }
-                        })
-                        .to("mock:report");
-            }
-        };
-    }
-
+/**
+ * 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 java.io.FileWriter;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test for the FileRenameStrategy using preMoveExpression options
+ */
+public class FileConsumerBeginExpressionRenameStrategyTest extends 
ContextTestSupport {
+
+    public void testRenameSuccess() throws Exception {
+        deleteDirectory("target/inprogress");
+        deleteDirectory("target/reports");
+
+        MockEndpoint mock = getMockEndpoint("mock:report");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hello Paris");
+
+        template.sendBodyAndHeader("file:target/reports", "Hello Paris", 
FileComponent.HEADER_FILE_NAME, "paris.txt");
+
+        Thread.sleep(100);
+
+        mock.assertIsSatisfied();
+    }
+
+    public void testRenameFileExists() throws Exception {
+        deleteDirectory("target/inprogress");
+        deleteDirectory("target/reports");
+
+        // create a file in inprogress to let there be a duplicate file
+        File file = new File("target/inprogress");
+        file.mkdirs();
+        FileWriter fw = new FileWriter("./target/inprogress/london.bak");
+        fw.write("I was there once in London");
+        fw.flush();
+        fw.close();
+
+        MockEndpoint mock = getMockEndpoint("mock:report");
+        mock.expectedBodiesReceived("Hello London");
+
+        template.sendBodyAndHeader("file:target/reports", "Hello London", 
FileComponent.HEADER_FILE_NAME, "london.txt");
+
+        Thread.sleep(100);
+
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                
from("file://target/reports?preMoveExpression=../inprogress/${file:name.noext}.bak&consumer.delay=5000")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws 
Exception {
+                                FileExchange fe = (FileExchange) exchange;
+                                assertEquals("The file should have been move 
to inprogress",
+                                        "inprogress", 
fe.getFile().getParentFile().getName());
+                            }
+                        })
+                        .to("mock:report");
+            }
+        };
+    }
+
 }
\ No newline at end of file

Propchange: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginExpressionRenameStrategyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
 (from r723835, 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java)
URL: 
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java?p2=activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java&r1=723835&r2=723860&rev=723860&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
 (original)
+++ 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
 Fri Dec  5 12:46:02 2008
@@ -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;
-
-import java.io.File;
-import java.io.FileWriter;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test for the FileRenameStrategy using preMove options
- */
-public class FileConsumerBeginRenameStrategyTest extends ContextTestSupport {
-
-    public void testRenameSuccess() throws Exception {
-        deleteDirectory("target/inprogress");
-        deleteDirectory("target/reports");
-
-        MockEndpoint mock = getMockEndpoint("mock:report");
-        mock.expectedMessageCount(1);
-        mock.expectedBodiesReceived("Hello Paris");
-
-        template.sendBodyAndHeader("file:target/reports", "Hello Paris", 
FileComponent.HEADER_FILE_NAME, "paris.txt");
-
-        Thread.sleep(100);
-
-        mock.assertIsSatisfied();
-    }
-
-    public void testRenameFileExists() throws Exception {
-        deleteDirectory("target/inprogress");
-        deleteDirectory("target/reports");
-
-        // create a file in inprogress to let there be a duplicate file
-        File file = new File("target/inprogress");
-        file.mkdirs();
-        FileWriter fw = new FileWriter("./target/inprogress/london.txt");
-        fw.write("I was there once in London");
-        fw.flush();
-        fw.close();
-
-        MockEndpoint mock = getMockEndpoint("mock:report");
-        mock.expectedBodiesReceived("Hello London");
-
-        template.sendBodyAndHeader("file:target/reports", "Hello London", 
FileComponent.HEADER_FILE_NAME, "london.txt");
-
-        Thread.sleep(100);
-
-        mock.assertIsSatisfied();
-    }
-
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            public void configure() throws Exception {
-                
from("file://target/reports?preMoveNamePrefix=../inprogress/&consumer.delay=5000")
-                        .process(new Processor() {
-                            public void process(Exchange exchange) throws 
Exception {
-                                FileExchange fe = (FileExchange) exchange;
-                                assertEquals("The file should have been move 
to inprogress", 
-                                        "inprogress", 
fe.getFile().getParentFile().getName());
-                            }
-                        })
-                        .to("mock:report");
-            }
-        };
-    }
-
+/**
+ * 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 java.io.FileWriter;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test for the FileRenameStrategy using preMove options
+ */
+public class FileConsumerBeginRenameStrategyTest extends ContextTestSupport {
+
+    public void testRenameSuccess() throws Exception {
+        deleteDirectory("target/inprogress");
+        deleteDirectory("target/reports");
+
+        MockEndpoint mock = getMockEndpoint("mock:report");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hello Paris");
+
+        template.sendBodyAndHeader("file:target/reports", "Hello Paris", 
FileComponent.HEADER_FILE_NAME, "paris.txt");
+
+        Thread.sleep(100);
+
+        mock.assertIsSatisfied();
+    }
+
+    public void testRenameFileExists() throws Exception {
+        deleteDirectory("target/inprogress");
+        deleteDirectory("target/reports");
+
+        // create a file in inprogress to let there be a duplicate file
+        File file = new File("target/inprogress");
+        file.mkdirs();
+        FileWriter fw = new FileWriter("./target/inprogress/london.txt");
+        fw.write("I was there once in London");
+        fw.flush();
+        fw.close();
+
+        MockEndpoint mock = getMockEndpoint("mock:report");
+        mock.expectedBodiesReceived("Hello London");
+
+        template.sendBodyAndHeader("file:target/reports", "Hello London", 
FileComponent.HEADER_FILE_NAME, "london.txt");
+
+        Thread.sleep(100);
+
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                
from("file://target/reports?preMoveNamePrefix=../inprogress/&consumer.delay=5000")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws 
Exception {
+                                FileExchange fe = (FileExchange) exchange;
+                                assertEquals("The file should have been move 
to inprogress", 
+                                        "inprogress", 
fe.getFile().getParentFile().getName());
+                            }
+                        })
+                        .to("mock:report");
+            }
+        };
+    }
+
 }
\ No newline at end of file

Propchange: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date


Reply via email to