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 6c41abb CAMEL-14982: Added unit test
6c41abb is described below
commit 6c41abb76e01ea5a04beaf324e5427cfe0bfb529
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Apr 29 17:01:30 2020 +0200
CAMEL-14982: Added unit test
---
.../camel/builder/endpoint/FileDelayTest.java | 59 ++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git
a/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/FileDelayTest.java
b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/FileDelayTest.java
new file mode 100644
index 0000000..8de3c7e
--- /dev/null
+++
b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/FileDelayTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.builder.endpoint;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Before;
+import org.junit.Test;
+
+public class FileDelayTest extends ContextTestSupport {
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ deleteDirectory("target/data/files");
+ super.setUp();
+ template.sendBodyAndHeader("file://target/data/files", "Hello World",
Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://target/data/files", "Bye World",
Exchange.FILE_NAME, "bye.txt");
+ }
+
+ @Test
+ public void testDelay() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceivedInAnyOrder("Hello World", "Bye World");
+ mock.message(1).arrives().between(1500, 3000).millis().afterPrevious();
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new EndpointRouteBuilder() {
+ public void configure() throws Exception {
+
from(file("target/data/files/").initialDelay(0).delay(2).timeUnit(TimeUnit.SECONDS).delete(true).maxMessagesPerPoll(1))
+ .convertBodyTo(String.class)
+ .to(mock("result"));
+ }
+ };
+ }
+
+}