You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/11/02 11:49:32 UTC

[camel] branch master updated: Added test on user forum issue

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new fcd200c  Added test on user forum issue
fcd200c is described below

commit fcd200c4e13c35bb9a63924bbc3e2d6a643c31cf
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Nov 2 12:48:07 2017 +0100

    Added test on user forum issue
---
 ...leConsumerIdempotentOnExceptionHandledTest.java | 58 ++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentOnExceptionHandledTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentOnExceptionHandledTest.java
new file mode 100644
index 0000000..4a7fe2d
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentOnExceptionHandledTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+public class FileConsumerIdempotentOnExceptionHandledTest extends ContextTestSupport {
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory("target/messages/input");
+        super.setUp();
+    }
+
+    public void testIdempotent() throws Exception {
+        getMockEndpoint("mock:invalid").expectedMessageCount(1);
+
+        template.sendBodyAndHeader("file:target/messages/input/", "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+        oneExchangeDone.matchesMockWaitTime();
+
+        assertMockEndpointsSatisfied();
+
+        // the error is handled and the file is regarded as success and therefore moved to .camel
+        assertFileNotExists("target/messages/input/hello.txt");
+        assertFileExists("target/messages/input/.camel/hello.txt");
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                onException(Exception.class).handled(true).to("mock:invalid");
+
+                // our route logic to process files from the input folder
+                from("file:target/messages/input/?initialDelay=0&delay=10&idempotent=true").
+                    to("mock:input")
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        };
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <co...@camel.apache.org>'].