camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1339299 - in /camel/branches/camel-2.8.x/components/camel-stream/src: main/java/org/apache/camel/component/stream/StreamProducer.java test/java/org/apache/camel/component/stream/StreamFileTest.java
Date Wed, 16 May 2012 18:20:19 GMT
Author: hadrian
Date: Wed May 16 18:20:19 2012
New Revision: 1339299

URL: http://svn.apache.org/viewvc?rev=1339299&view=rev
Log:
CAMEL-5279. Open file in append mode in camel-stream

Modified:
    camel/branches/camel-2.8.x/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java
    camel/branches/camel-2.8.x/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamFileTest.java

Modified: camel/branches/camel-2.8.x/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java?rev=1339299&r1=1339298&r2=1339299&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java
Wed May 16 18:20:19 2012
@@ -93,7 +93,7 @@ public class StreamProducer extends Defa
         File f = new File(fileName);
         // will create a new file if missing or append to existing
         f.createNewFile();
-        return new FileOutputStream(f);
+        return new FileOutputStream(f, true);
     }
 
     private OutputStream resolveStreamFromHeader(Object o, Exchange exchange) throws CamelExchangeException
{

Modified: camel/branches/camel-2.8.x/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamFileTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamFileTest.java?rev=1339299&r1=1339298&r2=1339299&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamFileTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamFileTest.java
Wed May 16 18:20:19 2012
@@ -23,6 +23,7 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
 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.test.junit4.CamelTestSupport;
 import org.junit.Before;
@@ -79,4 +80,27 @@ public class StreamFileTest extends Came
         }
     }
 
+    @Test
+    public void testFileProducer() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hadrian", "Camel");
+        
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").routeId("produce")
+                    .to("stream:file?fileName=target/stream/StreamFileTest.txt");
+                from("file://target/stream?fileName=StreamFileTest.txt").routeId("consume").autoStartup(false)
+                    .split().tokenize("\n").to("mock:result");
+            }
+        });
+        context.start();
+
+        template.sendBody("direct:start", "Hadrian");
+        template.sendBody("direct:start", "Camel");
+        
+        context.startRoute("consume");
+        assertMockEndpointsSatisfied();
+        context.stop();
+    }
 }
\ No newline at end of file



Mime
View raw message