camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1355225 - /camel/branches/camel-2.8.x/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamSystemOutTest.java
Date Fri, 29 Jun 2012 03:20:52 GMT
Author: ningjiang
Date: Fri Jun 29 03:20:51 2012
New Revision: 1355225

URL: http://svn.apache.org/viewvc?rev=1355225&view=rev
Log:
Fixed the build error of StreamSystemOutTest

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

Modified: camel/branches/camel-2.8.x/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamSystemOutTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamSystemOutTest.java?rev=1355225&r1=1355224&r2=1355225&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamSystemOutTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamSystemOutTest.java
Fri Jun 29 03:20:51 2012
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.stream;
 
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
@@ -25,15 +28,43 @@ import org.junit.Test;
  */
 public class StreamSystemOutTest extends CamelTestSupport {
 
+    String message = "Hello World";
+
+    PrintStream stdOut = System.out;
+
+    ByteArrayOutputStream mockOut = new ByteArrayOutputStream();
+
     // START SNIPPET: e1
-    @Test
+     @Test
     public void testStringContent() throws Exception {
-        template.sendBody("direct:in", "Hello Text World\n");
+        try {
+            // Given
+            System.setOut(new PrintStream(mockOut));
+
+            // When
+            template.sendBody("direct:in", message);
+
+            // Then
+            assertEquals(message + "\n", new String(mockOut.toByteArray()));
+        } finally {
+            System.setOut(stdOut);
+        }
     }
 
     @Test
     public void testBinaryContent() {
-        template.sendBody("direct:in", "Hello Bytes World\n".getBytes());
+        try {
+            // Given
+            System.setOut(new PrintStream(mockOut));
+
+            // When
+            template.sendBody("direct:in", message.getBytes());
+
+            // Then
+            assertEquals(message, new String(mockOut.toByteArray()));
+        } finally {
+            System.setOut(stdOut);
+        }
     }
 
     @Test



Mime
View raw message