camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1407548 - /camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileProducerAppendManyMessagesFastTest.java
Date Fri, 09 Nov 2012 17:22:34 GMT
Author: davsclaus
Date: Fri Nov  9 17:22:34 2012
New Revision: 1407548

URL: http://svn.apache.org/viewvc?rev=1407548&view=rev
Log:
Added test based on user forum issue

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileProducerAppendManyMessagesFastTest.java
      - copied, changed from r1407546, camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileProducerAppendManyMessagesTest.java

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileProducerAppendManyMessagesFastTest.java
(from r1407546, camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileProducerAppendManyMessagesTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileProducerAppendManyMessagesFastTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileProducerAppendManyMessagesFastTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileProducerAppendManyMessagesTest.java&r1=1407546&r2=1407548&rev=1407548&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileProducerAppendManyMessagesTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileProducerAppendManyMessagesFastTest.java
Fri Nov  9 17:22:34 2012
@@ -18,15 +18,18 @@ package org.apache.camel.component.file.
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.OutputStream;
 
 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;
 
 /**
  *
  */
-public class FileProducerAppendManyMessagesTest extends ContextTestSupport {
+public class FileProducerAppendManyMessagesFastTest extends ContextTestSupport {
 
     private boolean enabled;
 
@@ -38,6 +41,8 @@ public class FileProducerAppendManyMessa
 
         deleteDirectory("target/big");
         createDirectory("target/big");
+        deleteDirectory("target/out");
+        createDirectory("target/out");
 
         // create a big file
         File file = new File("target/big/data.txt");
@@ -69,10 +74,34 @@ public class FileProducerAppendManyMessa
             @Override
             public void configure() throws Exception {
                 from("file:target/big")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            // store a output stream we use for writing
+                            FileOutputStream fos = new FileOutputStream("target/out/also-big.txt",
true);
+                            exchange.setProperty("myStream", fos);
+                        }
+                    })
                     .split(body().tokenize(LS)).streaming()
                         .to("log:processing?groupSize=1000")
-                        .to("file:target/out/also-big.txt?fileExist=Append")
+                        .process(new Processor() {
+                            @Override
+                            public void process(Exchange exchange) throws Exception {
+                                OutputStream fos = exchange.getProperty("myStream", OutputStream.class);
+                                byte[] data = exchange.getIn().getBody(byte[].class);
+                                fos.write(data);
+                                fos.write(LS.getBytes());
+                            }
+                        })
                     .end()
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            OutputStream fos = exchange.getProperty("myStream", OutputStream.class);
+                            fos.close();
+                            exchange.removeProperty("myStream");
+                        }
+                    })
                     .to("mock:done");
             }
         };



Mime
View raw message