camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1040023 - /camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java
Date Mon, 29 Nov 2010 06:57:37 GMT
Author: davsclaus
Date: Mon Nov 29 06:57:36 2010
New Revision: 1040023

URL: http://svn.apache.org/viewvc?rev=1040023&view=rev
Log:
CAMEL-3372: Added unit test

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java
      - copied, changed from r1040022, camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureTest.java

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java
(from r1040022, camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureTest.java&r1=1040022&r2=1040023&rev=1040023&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureOnCompletionTest.java
Mon Nov 29 06:57:36 2010
@@ -25,7 +25,7 @@ import org.apache.camel.component.mock.M
 /**
  * @version $Revision$
  */
-public class FileConsumerMoveFailureTest extends ContextTestSupport {
+public class FileConsumerMoveFailureOnCompletionTest extends ContextTestSupport {
 
     @Override
     protected void setUp() throws Exception {
@@ -33,13 +33,26 @@ public class FileConsumerMoveFailureTest
         super.setUp();
     }
 
-    public void testMoveFailed() throws Exception {
+    public void testMoveFailedRollbackOnly() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedBodiesReceived("Hello World");
+        mock.expectedMessageCount(0);
+        mock.expectedFileExists("target/failed/error/bye-error.txt", "Kabom");
+
+        getMockEndpoint("mock:failed").expectedBodiesReceived("Kabom");
 
+        template.sendBodyAndHeader("file://target/failed", "Kabom", Exchange.FILE_NAME, "bye.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testMoveFailedCommitAndFailure() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
         mock.expectedFileExists("target/failed/.camel/hello.txt", "Hello World");
         mock.expectedFileExists("target/failed/error/bye-error.txt", "Kabom");
 
+        getMockEndpoint("mock:failed").expectedBodiesReceived("Kabom");
+
         template.sendBodyAndHeader("file://target/failed", "Hello World", Exchange.FILE_NAME,
"hello.txt");
         template.sendBodyAndHeader("file://target/failed", "Kabom", Exchange.FILE_NAME, "bye.txt");
 
@@ -52,6 +65,7 @@ public class FileConsumerMoveFailureTest
             @Override
             public void configure() throws Exception {
                 from("file://target/failed?moveFailed=error/${file:name.noext}-error.txt")
+                    .onCompletion().onFailureOnly().to("mock:failed").end()
                     .process(new Processor() {
                         public void process(Exchange exchange) throws Exception {
                             String body = exchange.getIn().getBody(String.class);



Mime
View raw message