[camel] branch master updated: CAMEL-13174: Added unit test

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: CAMEL-13174: Added unit test

davsclaus-2
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 126b702  CAMEL-13174: Added unit test
126b702 is described below

commit 126b702dd968ebbe9c292adf308f062a0490f0a5
Author: Claus Ibsen <[hidden email]>
AuthorDate: Mon Feb 11 08:04:13 2019 +0100

    CAMEL-13174: Added unit test
---
 .../camel-file/src/main/docs/file-component.adoc   |  2 +-
 .../camel/component/file/GenericFileEndpoint.java  |  2 +-
 .../camel-ftp/src/main/docs/ftp-component.adoc     |  2 +-
 .../camel-ftp/src/main/docs/ftps-component.adoc    |  2 +-
 .../camel-ftp/src/main/docs/sftp-component.adoc    |  2 +-
 ...erDirectoryMustExistBridgeErrorHandlerTest.java | 55 ++++++++++++++++++++++
 6 files changed, 60 insertions(+), 5 deletions(-)

diff --git a/components/camel-file/src/main/docs/file-component.adoc b/components/camel-file/src/main/docs/file-component.adoc
index 652c29a..8c55b97 100644
--- a/components/camel-file/src/main/docs/file-component.adoc
+++ b/components/camel-file/src/main/docs/file-component.adoc
@@ -89,7 +89,7 @@ with the following path and query parameters:
 | *preSort* (consumer) | When pre-sort is enabled then the consumer will sort the file and directory names during polling, that was retrieved from the file system. You may want to do this in case you need to operate on the files in a sorted order. The pre-sort is executed before the consumer starts to filter, and accept files to process by Camel. This option is default=false meaning disabled. | false | boolean
 | *recursive* (consumer) | If a directory, will look for files in all the sub-directories as well. | false | boolean
 | *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean
-| *directoryMustExist* (consumer) | Similar to startingDirectoryMustExist but this applies during polling recursive sub directories. | false | boolean
+| *directoryMustExist* (consumer) | Similar to the startingDirectoryMustExist option but this applies during polling (after starting the consumer). | false | boolean
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
 | *extendedAttributes* (consumer) | To define which file attributes of interest. Like posix:permissions,posix:owner,basic:lastAccessTime, it supports basic wildcard like posix:, basic:lastAccessTime |  | String
diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
index 46ce718..d02602b 100644
--- a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
+++ b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
@@ -1130,7 +1130,7 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple
     }
 
     /**
-     * Similar to startingDirectoryMustExist but this applies during polling recursive sub directories.
+     * Similar to the startingDirectoryMustExist option but this applies during polling (after starting the consumer).
      */
     public void setDirectoryMustExist(boolean directoryMustExist) {
         this.directoryMustExist = directoryMustExist;
diff --git a/components/camel-ftp/src/main/docs/ftp-component.adoc b/components/camel-ftp/src/main/docs/ftp-component.adoc
index 3973b1b..44ce825 100644
--- a/components/camel-ftp/src/main/docs/ftp-component.adoc
+++ b/components/camel-ftp/src/main/docs/ftp-component.adoc
@@ -127,7 +127,7 @@ with the following path and query parameters:
 | *resumeDownload* (consumer) | Configures whether resume download is enabled. This must be supported by the FTP server (almost all FTP servers support it). In addition the options localWorkDirectory must be configured so downloaded files are stored in a local directory, and the option binary must be enabled, which is required to support resuming of downloads. | false | boolean
 | *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean
 | *streamDownload* (consumer) | Sets the download method to use when not using a local working directory. If set to true, the remote files are streamed to the route as they are read. When set to false, the remote files are loaded into memory before being sent into the route. | false | boolean
-| *directoryMustExist* (consumer) | Similar to startingDirectoryMustExist but this applies during polling recursive sub directories. | false | boolean
+| *directoryMustExist* (consumer) | Similar to the startingDirectoryMustExist option but this applies during polling (after starting the consumer). | false | boolean
 | *download* (consumer) | Whether the FTP consumer should download the file. If this option is set to false, then the message body will be null, but the consumer will still trigger a Camel Exchange that has details about the file such as file name, file size, etc. It's just that the file will not be downloaded. | false | boolean
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
diff --git a/components/camel-ftp/src/main/docs/ftps-component.adoc b/components/camel-ftp/src/main/docs/ftps-component.adoc
index c4c834a..3993d4f 100644
--- a/components/camel-ftp/src/main/docs/ftps-component.adoc
+++ b/components/camel-ftp/src/main/docs/ftps-component.adoc
@@ -87,7 +87,7 @@ with the following path and query parameters:
 | *resumeDownload* (consumer) | Configures whether resume download is enabled. This must be supported by the FTP server (almost all FTP servers support it). In addition the options localWorkDirectory must be configured so downloaded files are stored in a local directory, and the option binary must be enabled, which is required to support resuming of downloads. | false | boolean
 | *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean
 | *streamDownload* (consumer) | Sets the download method to use when not using a local working directory. If set to true, the remote files are streamed to the route as they are read. When set to false, the remote files are loaded into memory before being sent into the route. | false | boolean
-| *directoryMustExist* (consumer) | Similar to startingDirectoryMustExist but this applies during polling recursive sub directories. | false | boolean
+| *directoryMustExist* (consumer) | Similar to the startingDirectoryMustExist option but this applies during polling (after starting the consumer). | false | boolean
 | *download* (consumer) | Whether the FTP consumer should download the file. If this option is set to false, then the message body will be null, but the consumer will still trigger a Camel Exchange that has details about the file such as file name, file size, etc. It's just that the file will not be downloaded. | false | boolean
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
diff --git a/components/camel-ftp/src/main/docs/sftp-component.adoc b/components/camel-ftp/src/main/docs/sftp-component.adoc
index 4e5f5c2..7679935 100644
--- a/components/camel-ftp/src/main/docs/sftp-component.adoc
+++ b/components/camel-ftp/src/main/docs/sftp-component.adoc
@@ -73,7 +73,7 @@ with the following path and query parameters:
 | *recursive* (consumer) | If a directory, will look for files in all the sub-directories as well. | false | boolean
 | *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean
 | *streamDownload* (consumer) | Sets the download method to use when not using a local working directory. If set to true, the remote files are streamed to the route as they are read. When set to false, the remote files are loaded into memory before being sent into the route. | false | boolean
-| *directoryMustExist* (consumer) | Similar to startingDirectoryMustExist but this applies during polling recursive sub directories. | false | boolean
+| *directoryMustExist* (consumer) | Similar to the startingDirectoryMustExist option but this applies during polling (after starting the consumer). | false | boolean
 | *download* (consumer) | Whether the FTP consumer should download the file. If this option is set to false, then the message body will be null, but the consumer will still trigger a Camel Exchange that has details about the file such as file name, file size, etc. It's just that the file will not be downloaded. | false | boolean
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryMustExistBridgeErrorHandlerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryMustExistBridgeErrorHandlerTest.java
new file mode 100644
index 0000000..64528a3
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryMustExistBridgeErrorHandlerTest.java
@@ -0,0 +1,55 @@
+/**
+ * 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.builder.RouteBuilder;
+import org.junit.Test;
+
+public class FileConsumerDirectoryMustExistBridgeErrorHandlerTest extends ContextTestSupport {
+
+    @Override
+    public void setUp() throws Exception {
+        deleteDirectory("target/doesnotexists");
+        super.setUp();
+    }
+
+    @Test
+    public void testBridgeErrorHandler() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+        getMockEndpoint("mock:dead").expectedMinimumMessageCount(1);
+
+        context.getRouteController().startRoute("foo");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("file:target/doesnotexists?initialDelay=1&delay=1"
+                    + "&autoCreate=false&directoryMustExist=true&bridgeErrorHandler=true")
+                    .routeId("foo").noAutoStartup()
+                    .to("mock:result");
+            }
+        };
+    }
+}