camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r959184 - in /camel/trunk/camel-core/src/test/java/org/apache/camel/component/file: FileConsumerDeleteAndMoveFailureTest.java FileConsumerMoveFailureTest.java
Date Wed, 30 Jun 2010 04:03:50 GMT
Author: ningjiang
Date: Wed Jun 30 04:03:50 2010
New Revision: 959184

URL: http://svn.apache.org/viewvc?rev=959184&view=rev
Log:
CAMEL-2878 Polish the unit tests

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDeleteAndMoveFailureTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveFailureTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDeleteAndMoveFailureTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDeleteAndMoveFailureTest.java?rev=959184&r1=959183&r2=959184&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDeleteAndMoveFailureTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDeleteAndMoveFailureTest.java
Wed Jun 30 04:03:50 2010
@@ -44,6 +44,21 @@ public class FileConsumerDeleteAndMoveFa
 
         assertMockEndpointsSatisfied();
     }
+    
+    public void testDeletAndMoveFailedOption() throws Exception {
+        try {
+            context.addRoutes(new RouteBuilder() {
+                public void configure() throws Exception {
+                    from("file://target/test?delete=true&moveFailed=target/failed/error").to("mock:failed");
+                }
+            });
+            fail("Expect an exception here");
+        } catch (IllegalArgumentException ex) {
+            // expect the error here
+            ex.getMessage().startsWith("You cannot set both deleted=true and move");
+        }
+        
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {

Modified: 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/FileConsumerMoveFailureTest.java?rev=959184&r1=959183&r2=959184&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/FileConsumerMoveFailureTest.java
Wed Jun 30 04:03:50 2010
@@ -33,49 +33,33 @@ public class FileConsumerMoveFailureTest
         super.setUp();
     }
 
-    public void testMoveFailedWithOnException() throws Exception {
+    public void testMoveFailed() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedBodiesReceived("Hello World IS processed!");
-        
-        mock.expectedFileExists("target/failed/error/bye.txt", "Kabom");
+        mock.expectedBodiesReceived("Hello World");
+
+        mock.expectedFileExists("target/failed/.camel/hello.txt", "Hello World");
+        mock.expectedFileExists("target/failed/error/bye-error.txt", "Kabom");
 
         template.sendBodyAndHeader("file://target/failed", "Hello World", Exchange.FILE_NAME,
"hello.txt");
         template.sendBodyAndHeader("file://target/failed", "Kabom", Exchange.FILE_NAME, "bye.txt");
 
         assertMockEndpointsSatisfied();
     }
-    
-    public void testDeletAndMoveFailedOption() throws Exception {
-        try {
-            context.addRoutes(new RouteBuilder() {
-                public void configure() throws Exception {
-                    from("file://target/test?delete=true&moveFailed=target/failed/error").to("mock:failed");
-                }
-            });
-            fail("Expect an exception here");
-        } catch (IllegalArgumentException ex) {
-            // expect the error here
-            ex.getMessage().startsWith("You cannot set both deleted=true and move");
-        }
-        
-    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                onException(IllegalArgumentException.class).useOriginalMessage().to("file://target/failed/error");
-                from("file://target/failed?delete=true")
-                    .setBody(simple("${body} IS processed!"))
+                from("file://target/failed?moveFailed=error/${file:name.noext}-error.txt")
                     .process(new Processor() {
                         public void process(Exchange exchange) throws Exception {
                             String body = exchange.getIn().getBody(String.class);
-                            if (body != null && body.startsWith("Kabom")) {
+                            if ("Kabom".equals(body)) {
                                 throw new IllegalArgumentException("Forced");
                             }
                         }
-                    }).to("mock:result");
+                    }).convertBodyTo(String.class).to("mock:result");
             }
         };
     }



Mime
View raw message