You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/04/26 09:06:23 UTC

svn commit: r1330674 - in /camel/branches/camel-2.9.x: ./ camel-core/src/main/java/org/apache/camel/component/file/ camel-core/src/main/java/org/apache/camel/converter/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/test/java/org/a...

Author: davsclaus
Date: Thu Apr 26 07:06:22 2012
New Revision: 1330674

URL: http://svn.apache.org/viewvc?rev=1330674&view=rev
Log:
CAMEL-5222: The file consumer should use the charset encoding when writing the file if configured.

Added:
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFtoISOConfiguredTest.java
      - copied unchanged from r1330670, camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFtoISOConfiguredTest.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFtoISOConvertBodyToTest.java
      - copied unchanged from r1330670, camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFtoISOConvertBodyToTest.java
Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/ConvertBodyProcessor.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeCharsetTest.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1330670

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

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java Thu Apr 26 07:06:22 2012
@@ -78,7 +78,7 @@ public class FileConsumer extends Generi
             }
 
             // creates a generic file
-            GenericFile<File> gf = asGenericFile(endpointPath, file);
+            GenericFile<File> gf = asGenericFile(endpointPath, file, getEndpoint().getCharset());
 
             if (file.isDirectory()) {
                 if (endpoint.isRecursive() && isValidFile(gf, true) && depth < endpoint.getMaxDepth()) {
@@ -116,11 +116,12 @@ public class FileConsumer extends Generi
      * @param file the source file
      * @return wrapped as a GenericFile
      */
-    public static GenericFile<File> asGenericFile(String endpointPath, File file) {
+    public static GenericFile<File> asGenericFile(String endpointPath, File file, String charset) {
         GenericFile<File> answer = new GenericFile<File>();
         // use file specific binding
         answer.setBinding(new FileBinding());
 
+        answer.setCharset(charset);
         answer.setEndpointPath(endpointPath);
         answer.setFile(file);
         answer.setFileNameOnly(file.getName());

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java Thu Apr 26 07:06:22 2012
@@ -102,7 +102,7 @@ public class FileEndpoint extends Generi
     }
 
     public Exchange createExchange(GenericFile<File> file) {
-        Exchange exchange =  createExchange();
+        Exchange exchange = createExchange();
         if (file != null) {
             file.bindToExchange(exchange);
         }

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java Thu Apr 26 07:06:22 2012
@@ -178,11 +178,8 @@ public class FileOperations implements G
         // 3. write stream to file
         try {
 
-            // determine charset, exchange property overrides endpoint configuration
-            String charset = IOHelper.getCharsetName(exchange, false);
-            if (charset == null) {
-                charset = endpoint.getCharset();
-            }
+            // is there an explicit charset configured we must write the file as
+            String charset = endpoint.getCharset();
 
             // we can optimize and use file based if no charset must be used, and the input body is a file
             File source = null;
@@ -279,7 +276,7 @@ public class FileOperations implements G
         FileChannel out = null;
         try {
             out = prepareOutputFileChannel(target, out);
-            LOG.trace("Using FileChannel to transfer from: {} to: {}", in, out);
+            LOG.debug("Using FileChannel to write file: {}", target);
             long size = in.size();
             long position = 0;
             while (position < size) {
@@ -297,7 +294,7 @@ public class FileOperations implements G
         FileChannel out = null;
         try {
             out = prepareOutputFileChannel(target, out);
-            LOG.trace("Using InputStream to transfer from: {} to: {}", in, out);
+            LOG.debug("Using InputStream to write file: {}", target);
             int size = endpoint.getBufferSize();
             byte[] buffer = new byte[size];
             ByteBuffer byteBuffer = ByteBuffer.wrap(buffer);
@@ -321,7 +318,7 @@ public class FileOperations implements G
         boolean append = endpoint.getFileExist() == GenericFileExist.Append;
         Writer out = IOConverter.toWriter(target, append, charset);
         try {
-            LOG.trace("Using Reader to transfer from: {} to: {} with charset: {}", new Object[]{in, out, charset});
+            LOG.debug("Using Reader to write file: {} with charset: {}", target, charset);
             int size = endpoint.getBufferSize();
             IOHelper.copy(in, out, size);
         } finally {

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java Thu Apr 26 07:06:22 2012
@@ -44,6 +44,7 @@ public class GenericFile<T> implements W
     private T file;
     private GenericFileBinding<T> binding;
     private boolean absolute;
+    private String charset;
 
     public char getFileSeparator() {
         return File.separatorChar;
@@ -74,6 +75,7 @@ public class GenericFile<T> implements W
         result.setFile(source.getFile());
         result.setBody(source.getBody());
         result.setBinding(source.getBinding());
+        result.setCharset(source.getCharset());
 
         copyFromPopulateAdditional(source, result);
         return result;
@@ -251,9 +253,14 @@ public class GenericFile<T> implements W
         this.lastModified = lastModified;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.file.WrappedFile#getFile()
-     */
+    public String getCharset() {
+        return charset;
+    }
+
+    public void setCharset(String charset) {
+        this.charset = charset;
+    }
+
     @Override
     public T getFile() {
         return file;

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java Thu Apr 26 07:06:22 2012
@@ -16,9 +16,11 @@
  */
 package org.apache.camel.component.file;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.Reader;
 import java.io.Serializable;
 
 import org.apache.camel.Converter;
@@ -26,7 +28,10 @@ import org.apache.camel.Exchange;
 import org.apache.camel.FallbackConverter;
 import org.apache.camel.NoTypeConversionAvailableException;
 import org.apache.camel.TypeConverter;
+import org.apache.camel.converter.IOConverter;
 import org.apache.camel.spi.TypeConverterRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A set of converter methods for working with generic file types
@@ -34,12 +39,16 @@ import org.apache.camel.spi.TypeConverte
 @Converter
 public final class GenericFileConverter {
 
+    private static final Logger LOG = LoggerFactory.getLogger(GenericFileConverter.class);
+
     private GenericFileConverter() {
         // Helper Class
     }
 
     @FallbackConverter
-    public static Object convertTo(Class<?> type, Exchange exchange, Object value, TypeConverterRegistry registry) {
+    public static Object convertTo(Class<?> type, Exchange exchange, Object value, TypeConverterRegistry registry)
+        throws IOException, NoTypeConversionAvailableException {
+
         // use a fallback type converter so we can convert the embedded body if the value is GenericFile
         if (GenericFile.class.isAssignableFrom(value.getClass())) {
 
@@ -55,6 +64,36 @@ public final class GenericFileConverter 
             TypeConverter tc = registry.lookup(type, from);
             if (tc != null) {
                 Object body = file.getBody();
+                // if its a file and we have a charset then use a reader to ensure we read the content using the given charset
+                // this is a bit complicated, but a file consumer can be configured with an explicit charset, which means
+                // we should read the file content with that given charset, and ignore any other charset properties
+
+                // if the desired type is InputStream or Reader we can use the optimized methods
+                if (Reader.class.isAssignableFrom(type)) {
+                    Reader reader = genericFileToReader(file, exchange);
+                    if (reader != null) {
+                        return reader;
+                    }
+                }
+                if (InputStream.class.isAssignableFrom(type)) {
+                    InputStream is = genericFileToInputStream(file, exchange);
+                    if (is != null) {
+                        return is;
+                    }
+                }
+
+                // okay if the file has a charset configured then we must try to load the file using that charset
+                // which mean we have to use the Reader first, and then convert from there
+                if (body instanceof File && file.getCharset() != null) {
+                    Reader reader = genericFileToReader(file, exchange);
+                    // we dont want a reader back, so use the type converter registry to find a suitable converter
+                    TypeConverter readerTc = registry.lookup(type, Reader.class);
+                    if (readerTc != null) {
+                        // use the reader based type converter
+                        return readerTc.convertTo(type, exchange, reader);
+                    }
+                }
+                // fallback and use the type suitable type converter
                 return tc.convertTo(type, exchange, body);
             }
         }
@@ -64,15 +103,22 @@ public final class GenericFileConverter 
 
     @Converter
     public static InputStream genericFileToInputStream(GenericFile<?> file, Exchange exchange) throws IOException, NoTypeConversionAvailableException {
-        if (exchange != null) {
-            if (file.getFile() instanceof java.io.File) {
-                // prefer to use a file input stream if its a java.io.File (must use type converter to take care of encoding)
-                File f = (File) file.getFile();
-                InputStream is = exchange.getContext().getTypeConverter().convertTo(InputStream.class, exchange, f);
-                if (is != null) {
-                    return is;
+        if (file.getFile() instanceof File) {
+            // prefer to use a file input stream if its a java.io.File
+            File f = (File) file.getFile();
+            // the file must exists
+            if (f.exists()) {
+                // read the file using the specified charset
+                String charset = file.getCharset();
+                if (charset != null) {
+                    LOG.debug("Read file {} with charset {}", f, file.getCharset());
+                } else {
+                    LOG.debug("Read file {} (no charset)", f);
                 }
+                return IOConverter.toInputStream(f, charset);
             }
+        }
+        if (exchange != null) {
             // otherwise ensure the body is loaded as we want the input stream of the body
             file.getBinding().loadContent(exchange, file);
             return exchange.getContext().getTypeConverter().convertTo(InputStream.class, exchange, file.getBody());
@@ -83,9 +129,14 @@ public final class GenericFileConverter 
     }
 
     @Converter
-    public static String genericFileToString(GenericFile<?> file, Exchange exchange) throws IOException {
+    public static String genericFileToString(GenericFile<?> file, Exchange exchange) throws IOException, NoTypeConversionAvailableException {
+        // use reader first as it supports the file charset
+        BufferedReader reader = genericFileToReader(file, exchange);
+        if (reader != null) {
+            return IOConverter.toString(reader);
+        }
         if (exchange != null) {
-            // ensure the body is loaded as we do not want a toString of java.io.File handle returned, but the file content
+            // otherwise ensure the body is loaded as we want the content of the body
             file.getBinding().loadContent(exchange, file);
             return exchange.getContext().getTypeConverter().convertTo(String.class, exchange, file.getBody());
         } else {
@@ -95,14 +146,36 @@ public final class GenericFileConverter 
     }
 
     @Converter
-    public static Serializable genericFileToSerializable(GenericFile<?> file, Exchange exchange) throws IOException {
+    public static Serializable genericFileToSerializable(GenericFile<?> file, Exchange exchange) throws IOException, NoTypeConversionAvailableException {
         if (exchange != null) {
-            // ensure the body is loaded as we do not want a java.io.File handle returned, but the file content
-            file.getBinding().loadContent(exchange, file);
-            return exchange.getContext().getTypeConverter().convertTo(Serializable.class, exchange, file.getBody());
-        } else {
-            // should revert to fallback converter if we don't have an exchange
-            return null;
+            // load the file using input stream
+            InputStream is = genericFileToInputStream(file, exchange);
+            if (is != null) {
+                return exchange.getContext().getTypeConverter().convertTo(Serializable.class, exchange, is);
+            }
         }
+        // should revert to fallback converter if we don't have an exchange
+        return null;
+    }
+
+    private static BufferedReader genericFileToReader(GenericFile<?> file, Exchange exchange) throws IOException, NoTypeConversionAvailableException {
+        if (file.getFile() instanceof File) {
+            // prefer to use a file input stream if its a java.io.File
+            File f = (File) file.getFile();
+            // the file must exists
+            if (!f.exists()) {
+                return null;
+            }
+            // and use the charset if the file was explicit configured with a charset
+            String charset = file.getCharset();
+            if (charset != null) {
+                LOG.debug("Read file {} with charset {}", f, file.getCharset());
+                return IOConverter.toReader(f, charset);
+            } else {
+                LOG.debug("Read file {} (no charset)", f);
+                return IOConverter.toReader(f, exchange);
+            }
+        }
+        return null;
     }
 }

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java Thu Apr 26 07:06:22 2012
@@ -73,17 +73,35 @@ public final class IOConverter {
         return IOHelper.buffered(new FileInputStream(file));
     }
 
+    public static InputStream toInputStream(File file, String charset) throws IOException {
+        if (charset != null) {
+            final BufferedReader reader = toReader(file, charset);
+            return new InputStream() {
+                @Override
+                public int read() throws IOException {
+                    return reader.read();
+                }
+            };
+        } else {
+            return IOHelper.buffered(new FileInputStream(file));
+        }
+    }
+
     /**
      * @deprecated will be removed in Camel 3.0. Use the method which has 2 parameters.
      */
     @Deprecated
     public static BufferedReader toReader(File file) throws IOException {
-        return toReader(file, null);
+        return toReader(file, (String) null);
     }
 
     @Converter
     public static BufferedReader toReader(File file, Exchange exchange) throws IOException {
-        return IOHelper.buffered(new EncodingFileReader(file, IOHelper.getCharsetName(exchange)));
+        return toReader(file, IOHelper.getCharsetName(exchange));
+    }
+
+    public static BufferedReader toReader(File file, String charset) throws IOException {
+        return IOHelper.buffered(new EncodingFileReader(file, charset));
     }
 
     @Converter
@@ -285,7 +303,8 @@ public final class IOConverter {
     
     @Converter
     public static byte[] toByteArray(BufferedReader reader, Exchange exchange) throws IOException {
-        return toByteArray(toString(reader), exchange);
+        String s = toString(reader);
+        return toByteArray(s, exchange);
     }
 
     /**

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/ConvertBodyProcessor.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/ConvertBodyProcessor.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/ConvertBodyProcessor.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/ConvertBodyProcessor.java Thu Apr 26 07:06:22 2012
@@ -21,6 +21,7 @@ import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultMessage;
 import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * A processor which converts the payload of the input message to be of the given type
@@ -34,13 +35,15 @@ public class ConvertBodyProcessor implem
     private final String charset;
 
     public ConvertBodyProcessor(Class<?> type) {
+        ObjectHelper.notNull(type, "type", this);
         this.type = type;
         this.charset = null;
     }
 
     public ConvertBodyProcessor(Class<?> type, String charset) {
+        ObjectHelper.notNull(type, "type", this);
         this.type = type;
-        this.charset = charset;
+        this.charset = IOHelper.normalizeCharset(charset);
     }
 
     @Override
@@ -56,7 +59,9 @@ public class ConvertBodyProcessor implem
         }
 
         if (charset != null) {
-            exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(charset));
+            // override existing charset with configured charset as that is what the user
+            // have explicit configured and expects to be used
+            exchange.setProperty(Exchange.CHARSET_NAME, charset);
         }
         // use mandatory conversion
         Object value = in.getMandatoryBody(type);
@@ -71,6 +76,12 @@ public class ConvertBodyProcessor implem
         } else {
             exchange.setIn(msg);
         }
+
+        // remove charset when we are done as we should not propagate that,
+        // as that can lead to double converting later on
+        if (charset != null) {
+            exchange.removeProperty(Exchange.CHARSET_NAME);
+        }
     }
 
     public Class<?> getType() {

Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java Thu Apr 26 07:06:22 2012
@@ -98,7 +98,7 @@ public class FileConfigureTest extends C
             assertDirectoryEquals("For uri: " + endpointUri + " the file is not equal", expectedPath, path);
 
             file = new File(expectedPath + (expectedPath.endsWith(File.separator) ? "" : File.separator) + EXPECT_FILE);
-            GenericFile<File> consumedFile = FileConsumer.asGenericFile(endpoint.getFile().getPath(), file);
+            GenericFile<File> consumedFile = FileConsumer.asGenericFile(endpoint.getFile().getPath(), file, null);
 
             assertEquals(EXPECT_FILE, consumedFile.getRelativeFilePath());
         }

Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeCharsetTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeCharsetTest.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeCharsetTest.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeCharsetTest.java Thu Apr 26 07:06:22 2012
@@ -24,7 +24,7 @@ import org.apache.camel.builder.RouteBui
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
- * Unit test for consuming the same filename only.
+ *
  */
 public class FileConsumeCharsetTest extends ContextTestSupport {
 
@@ -51,7 +51,9 @@ public class FileConsumeCharsetTest exte
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("file://target/files/?fileName=report.txt&delete=true&charset=UTF-8").convertBodyTo(String.class).to("mock:result");
+                from("file://target/files/?fileName=report.txt&delete=true&charset=UTF-8")
+                    .convertBodyTo(String.class)
+                    .to("mock:result");
             }
         };
     }

Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java Thu Apr 26 07:06:22 2012
@@ -38,7 +38,7 @@ public class FileConsumerMoveFailureOnCo
         mock.expectedMessageCount(0);
         mock.expectedFileExists("target/failed/error/bye-error.txt", "Kabom");
 
-        getMockEndpoint("mock:failed").expectedBodiesReceived("Kabom");
+        getMockEndpoint("mock:failed").expectedMessageCount(1);
 
         template.sendBodyAndHeader("file://target/failed", "Kabom", Exchange.FILE_NAME, "bye.txt");
 
@@ -51,7 +51,7 @@ public class FileConsumerMoveFailureOnCo
         mock.expectedFileExists("target/failed/.camel/hello.txt", "Hello World");
         mock.expectedFileExists("target/failed/error/bye-error.txt", "Kabom");
 
-        getMockEndpoint("mock:failed").expectedBodiesReceived("Kabom");
+        getMockEndpoint("mock:failed").expectedMessageCount(1);
 
         template.sendBodyAndHeader("file://target/failed", "Hello World", Exchange.FILE_NAME, "hello.txt");
         template.sendBodyAndHeader("file://target/failed", "Kabom", Exchange.FILE_NAME, "bye.txt");

Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java Thu Apr 26 07:06:22 2012
@@ -165,7 +165,7 @@ public class FileLanguageTest extends La
 
         // get the file handle
         file = new File("target/filelanguage/test/hello.txt");
-        GenericFile<File> gf = FileConsumer.asGenericFile("target/filelanguage", file);
+        GenericFile<File> gf = FileConsumer.asGenericFile("target/filelanguage", file, null);
 
         FileEndpoint endpoint = getMandatoryEndpoint(uri, FileEndpoint.class);
 

Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java?rev=1330674&r1=1330673&r2=1330674&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java Thu Apr 26 07:06:22 2012
@@ -52,7 +52,8 @@ public class ConvertBodyTest extends Con
         });
 
         getMockEndpoint("mock:foo").expectedMessageCount(1);
-        getMockEndpoint("mock:foo").expectedPropertyReceived(Exchange.CHARSET_NAME, "iso-8859-1");
+        // do not propagate charset to avoid side effects with double conversion etc
+        getMockEndpoint("mock:foo").message(0).property(Exchange.CHARSET_NAME).isNull();
 
         template.sendBody("direct:foo", "Hello World");