Return-Path: Delivered-To: apmail-camel-commits-archive@www.apache.org Received: (qmail 32245 invoked from network); 30 Jun 2010 04:05:18 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Jun 2010 04:05:18 -0000 Received: (qmail 3514 invoked by uid 500); 30 Jun 2010 04:05:18 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 3457 invoked by uid 500); 30 Jun 2010 04:05:16 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 3449 invoked by uid 99); 30 Jun 2010 04:05:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Jun 2010 04:05:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Jun 2010 04:05:13 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9EAAD23888CE; Wed, 30 Jun 2010 04:03:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@camel.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100630040350.9EAAD23888CE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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"); } }; }