This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c29f5375b67 CAMEL-20686 change File tests for incorrectly shared
resources - set 8 (#16681)
c29f5375b67 is described below
commit c29f5375b6728d18315c9d072a8374188168ac35
Author: Jang-Vijay Singh <[email protected]>
AuthorDate: Thu Jan 2 06:23:49 2025 +0000
CAMEL-20686 change File tests for incorrectly shared resources - set 8
(#16681)
* AMEL-20686 - set 7: review File tests for incorrectly shared resource
* CAMEL-20686 change File tests for incorrectly shared resources - set 8
---
.../file/AntPathMatcherGenericFileFilterTest.java | 41 +++++++-----
.../camel/component/file/BeanToFileTest.java | 7 +-
.../component/file/DirectoryCreateIssueTest.java | 6 +-
.../component/file/FileAbsolutePathIssueTest.java | 11 +++-
.../component/file/FileBrowsableEndpointTest.java | 43 +++++++-----
.../file/FileConsumeBackoffMultiplierTest.java | 5 +-
.../component/file/FileConsumeCharsetTest.java | 8 ++-
.../file/FileConsumeDoneFileIssueTest.java | 76 ++++++++++++----------
...eConsumeDynamicDoneFileNameWithTwoDotsTest.java | 10 +--
.../component/file/FileConsumeHiddenDirsTest.java | 11 ++--
.../file/FileConsumeMaxMessagesPerPollTest.java | 9 ++-
.../file/FileConsumeMoveRelativeNameTest.java | 16 +++--
.../file/FileConsumerBeginRenameStrategyTest.java | 9 ++-
.../component/file/FileToFileNioLowBufferTest.java | 7 +-
.../FilerConsumerMoveFailedDoneFileNameTest.java | 6 +-
15 files changed, 162 insertions(+), 103 deletions(-)
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java
index 1757f375e8e..2d3d82aae13 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.file;
import java.io.File;
+import java.util.UUID;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
@@ -29,6 +30,7 @@ import org.junit.jupiter.api.Test;
* Unit tests for {@link AntPathMatcherGenericFileFilter}.
*/
public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport {
+ private static final String TEST_DIR_NAME = "test" + UUID.randomUUID();
@Override
public boolean isUseRouteBuilder() {
@@ -53,7 +55,8 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
@Override
public void configure() {
from(fileUri(
-
"files/ant-path-1?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antFilterCaseSensitive=true"))
+ TEST_DIR_NAME
+ +
"/ant-path-1?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antFilterCaseSensitive=true"))
.convertBodyTo(String.class)
.to("mock:result1");
}
@@ -63,7 +66,7 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result1");
mock.expectedBodiesReceivedInAnyOrder("Hello World");
- String endpointUri = fileUri("files/ant-path-1/x/y/z");
+ String endpointUri = fileUri(TEST_DIR_NAME + "/ant-path-1/x/y/z");
template.sendBodyAndHeader(endpointUri, "Hello World",
Exchange.FILE_NAME, "report.txt");
template.sendBodyAndHeader(endpointUri, "Hello World 2",
Exchange.FILE_NAME, "b.TXT");
@@ -78,7 +81,7 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
-
from(fileUri("files/ant-path-2?initialDelay=0&delay=10&recursive=true&antExclude=**/*.bak"))
+ from(fileUri(TEST_DIR_NAME +
"/ant-path-2?initialDelay=0&delay=10&recursive=true&antExclude=**/*.bak"))
.convertBodyTo(String.class).to("mock:result2");
}
});
@@ -87,7 +90,7 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result2");
mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World
3", "Hello World 4");
- String endpointUri = fileUri("files/ant-path-2/x/y/z");
+ String endpointUri = fileUri(TEST_DIR_NAME + "/ant-path-2/x/y/z");
template.sendBodyAndHeader(endpointUri, "Hello World 1",
Exchange.FILE_NAME, "report.bak");
template.sendBodyAndHeader(endpointUri, "Hello World 2",
Exchange.FILE_NAME, "report.txt");
template.sendBodyAndHeader(endpointUri, "Hello World 3",
Exchange.FILE_NAME, "b.BAK");
@@ -105,7 +108,8 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
@Override
public void configure() {
from(fileUri(
-
"files/ant-path-3?initialDelay=0&delay=10&recursive=true&antInclude=**/*.pdf,**/*.txt&antExclude=**/a*,**/b*"))
+ TEST_DIR_NAME
+ +
"/ant-path-3?initialDelay=0&delay=10&recursive=true&antInclude=**/*.pdf,**/*.txt&antExclude=**/a*,**/b*"))
.convertBodyTo(String.class)
.to("mock:result3");
}
@@ -115,7 +119,7 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result3");
mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World
4");
- String endpointUri = fileUri("files/ant-path-3/x/y/z");
+ String endpointUri = fileUri(TEST_DIR_NAME + "/ant-path-3/x/y/z");
template.sendBodyAndHeader(endpointUri, "Hello World 1",
Exchange.FILE_NAME, "a.pdf");
template.sendBodyAndHeader(endpointUri, "Hello World 2",
Exchange.FILE_NAME, "m.pdf");
template.sendBodyAndHeader(endpointUri, "Hello World 3",
Exchange.FILE_NAME, "b.txt");
@@ -141,7 +145,8 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
@Override
public void configure() {
from(fileUri(
-
"files/ant-path-4?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antExclude=**/a*&filter=#filter"))
+ TEST_DIR_NAME
+ +
"/ant-path-4?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antExclude=**/a*&filter=#filter"))
.convertBodyTo(String.class)
.to("mock:result4");
}
@@ -151,7 +156,7 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result4");
mock.expectedBodiesReceivedInAnyOrder("Hello World 3");
- String endpointUri = fileUri("files/ant-path-4/x/y/z");
+ String endpointUri = fileUri(TEST_DIR_NAME + "/ant-path-4/x/y/z");
template.sendBodyAndHeader(endpointUri, "Hello World 1",
Exchange.FILE_NAME, "a.txt");
template.sendBodyAndHeader(endpointUri, "Hello World 2",
Exchange.FILE_NAME, "b.txt");
template.sendBodyAndHeader(endpointUri, "Hello World 3",
Exchange.FILE_NAME, "c.txt");
@@ -169,7 +174,8 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
@Override
public void configure() {
from(fileUri(
-
"files/ant-path-5?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antFilterCaseSensitive=false"))
+ TEST_DIR_NAME
+ +
"/ant-path-5?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antFilterCaseSensitive=false"))
.convertBodyTo(String.class)
.to("mock:result5");
}
@@ -179,7 +185,7 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result5");
mock.expectedBodiesReceivedInAnyOrder("Hello World");
- String endpointUri = fileUri("files/ant-path-5/x/y/z");
+ String endpointUri = fileUri(TEST_DIR_NAME + "/ant-path-5/x/y/z");
template.sendBodyAndHeader(endpointUri, "Hello World",
Exchange.FILE_NAME,
"report.TXT");
@@ -195,7 +201,8 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
@Override
public void configure() {
from(fileUri(
-
"files/ant-path-6?initialDelay=0&delay=10&recursive=true&antExclude=**/*.bak&antFilterCaseSensitive=false"))
+ TEST_DIR_NAME
+ +
"/ant-path-6?initialDelay=0&delay=10&recursive=true&antExclude=**/*.bak&antFilterCaseSensitive=false"))
.convertBodyTo(String.class)
.to("mock:result6");
@@ -206,7 +213,7 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result6");
mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World
4");
- String endpointUri = fileUri("files/ant-path-6/x/y/z");
+ String endpointUri = fileUri(TEST_DIR_NAME + "/ant-path-6/x/y/z");
template.sendBodyAndHeader(endpointUri, "Hello World 1",
Exchange.FILE_NAME, "report.bak");
template.sendBodyAndHeader(endpointUri, "Hello World 2",
Exchange.FILE_NAME, "report.txt");
template.sendBodyAndHeader(endpointUri, "Hello World 3",
Exchange.FILE_NAME, "b.BAK");
@@ -224,7 +231,8 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
@Override
public void configure() {
from(fileUri(
-
"files/ant-path-7?initialDelay=0&delay=10&recursive=true&antInclude=**/*.Pdf,**/*.txt&antExclude=**/a*,**/b*&antFilterCaseSensitive=false"))
+ TEST_DIR_NAME
+ +
"/ant-path-7?initialDelay=0&delay=10&recursive=true&antInclude=**/*.Pdf,**/*.txt&antExclude=**/a*,**/b*&antFilterCaseSensitive=false"))
.convertBodyTo(String.class).to("mock:result7");
}
@@ -234,7 +242,7 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result7");
mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World
4", "Hello World 8", "Hello World 10");
- String endpointUri = fileUri("files/ant-path-7/x/y/z");
+ String endpointUri = fileUri(TEST_DIR_NAME + "/ant-path-7/x/y/z");
template.sendBodyAndHeader(endpointUri, "Hello World 1",
Exchange.FILE_NAME, "a.pdf");
template.sendBodyAndHeader(endpointUri, "Hello World 2",
Exchange.FILE_NAME, "m.pdf");
template.sendBodyAndHeader(endpointUri, "Hello World 3",
Exchange.FILE_NAME, "b.txt");
@@ -260,7 +268,8 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
@Override
public void configure() {
from(fileUri(
-
"files/ant-path-8?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antExclude=**/a*&filter=#caseInsensitiveFilter"))
+ TEST_DIR_NAME
+ +
"/ant-path-8?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antExclude=**/a*&filter=#caseInsensitiveFilter"))
.convertBodyTo(String.class).to("mock:result8");
}
});
@@ -269,7 +278,7 @@ public class AntPathMatcherGenericFileFilterTest extends
ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result8");
mock.expectedBodiesReceivedInAnyOrder("Hello World 3", "Hello World
4");
- String endpointUri = fileUri("files/ant-path-8/x/y/z");
+ String endpointUri = fileUri(TEST_DIR_NAME + "/ant-path-8/x/y/z");
template.sendBodyAndHeader(endpointUri, "Hello World 1",
Exchange.FILE_NAME, "a.txt");
template.sendBodyAndHeader(endpointUri, "Hello World 2",
Exchange.FILE_NAME, "b.txt");
template.sendBodyAndHeader(endpointUri, "Hello World 3",
Exchange.FILE_NAME, "c.txt");
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/BeanToFileTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/BeanToFileTest.java
index 0c7808df39d..d7769371af8 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/BeanToFileTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/BeanToFileTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.file;
+import java.util.UUID;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
@@ -27,13 +29,14 @@ import org.junit.jupiter.api.Test;
* Unit test that we can chain bean and file producer.
*/
public class BeanToFileTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME = "BeanToFileTest" +
UUID.randomUUID() + ".txt";
@Test
public void testBeanToFile() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
- mock.expectedFileExists(testFile("BeanToFileTest.txt"), "Bye World");
+ mock.expectedFileExists(testFile(TEST_FILE_NAME), "Bye World");
template.sendBody("direct:in", "World");
@@ -51,7 +54,7 @@ public class BeanToFileTest extends ContextTestSupport {
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
-
from("direct:in").to("bean:myBean").setHeader(Exchange.FILE_NAME,
constant("BeanToFileTest.txt"))
+
from("direct:in").to("bean:myBean").setHeader(Exchange.FILE_NAME,
constant(TEST_FILE_NAME))
.to(fileUri("?fileExist=Override"), "mock:result");
}
};
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
index 4de83f9ee98..adbe478662e 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.file;
import java.nio.file.Files;
+import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.apache.camel.ContextTestSupport;
@@ -31,6 +32,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class DirectoryCreateIssueTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME_PREFIX = "file" +
UUID.randomUUID();
private final int numFiles = 10;
@@ -43,7 +45,7 @@ public class DirectoryCreateIssueTest extends
ContextTestSupport {
for (int i = 0; i < numFiles; i++) {
destinations[i] = "direct:file" + i;
- from("direct:file" + i).setHeader(Exchange.FILE_NAME,
constant("file" + i + ".txt"))
+ from("direct:file" + i).setHeader(Exchange.FILE_NAME,
constant(TEST_FILE_NAME_PREFIX + i + ".txt"))
.to(fileUri("a/b/c/d/e/f/g/h/?fileExist=Override&noop=true"), "mock:result");
}
@@ -67,7 +69,7 @@ public class DirectoryCreateIssueTest extends
ContextTestSupport {
// wait a little while for the files to settle down
Awaitility.await().pollDelay(50,
TimeUnit.MILLISECONDS).untilAsserted(() -> {
for (int i = 0; i < numFiles; i++) {
- assertTrue(Files.isRegularFile(testFile("a/b/c/d/e/f/g/h/file"
+ i + ".txt")));
+ assertTrue(Files.isRegularFile(testFile("a/b/c/d/e/f/g/h/" +
TEST_FILE_NAME_PREFIX + i + ".txt")));
}
});
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileAbsolutePathIssueTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileAbsolutePathIssueTest.java
index 55b24a1eaf2..96baeb36423 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileAbsolutePathIssueTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileAbsolutePathIssueTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.component.file;
+import java.io.File;
+import java.util.UUID;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
@@ -24,6 +27,8 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class FileAbsolutePathIssueTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME = "hello" + UUID.randomUUID() +
".txt";
+ private static final String FILE_SEPARATOR = File.separator;
private String uri;
private String start;
@@ -34,7 +39,7 @@ public class FileAbsolutePathIssueTest extends
ContextTestSupport {
public void setUp() throws Exception {
start = testDirectory("issue").toAbsolutePath().toString();
done = testDirectory("done").toAbsolutePath().toString();
- uri = "file:" + start + "?initialDelay=0&delay=10&move=" + done +
"/${file:name}";
+ uri = "file:" + start + "?initialDelay=0&delay=10&move=" + done +
FILE_SEPARATOR + "${file:name}";
super.setUp();
}
@@ -42,9 +47,9 @@ public class FileAbsolutePathIssueTest extends
ContextTestSupport {
public void testMoveAbsolute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
- mock.expectedFileExists(done + "/hello.txt");
+ mock.expectedFileExists(done + FILE_SEPARATOR + TEST_FILE_NAME);
- template.sendBodyAndHeader("file:" + start, "Hello World",
Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file:" + start, "Hello World",
Exchange.FILE_NAME, TEST_FILE_NAME);
assertMockEndpointsSatisfied();
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileBrowsableEndpointTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileBrowsableEndpointTest.java
index 3d70afa5a2c..10bd53d2193 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileBrowsableEndpointTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileBrowsableEndpointTest.java
@@ -16,8 +16,10 @@
*/
package org.apache.camel.component.file;
+import java.io.File;
import java.nio.file.Files;
import java.util.List;
+import java.util.UUID;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
@@ -33,6 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*
*/
public class FileBrowsableEndpointTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME_PREFIX =
UUID.randomUUID().toString();
@Test
public void testBrowsableNoFiles() {
@@ -47,7 +50,7 @@ public class FileBrowsableEndpointTest extends
ContextTestSupport {
@Test
public void testBrowsableOneFile() {
- template.sendBodyAndHeader(fileUri(), "A", Exchange.FILE_NAME,
"a.txt");
+ template.sendBodyAndHeader(fileUri(), "A", Exchange.FILE_NAME,
TEST_FILE_NAME_PREFIX + "a.txt");
FileEndpoint endpoint =
context.getEndpoint(fileUri("?initialDelay=0&delay=10"), FileEndpoint.class);
assertNotNull(endpoint);
@@ -59,19 +62,19 @@ public class FileBrowsableEndpointTest extends
ContextTestSupport {
assertNotNull(list);
assertEquals(1, list.size());
- assertEquals("a.txt",
list.get(0).getIn().getHeader(Exchange.FILE_NAME));
+ assertEquals(TEST_FILE_NAME_PREFIX + "a.txt",
list.get(0).getIn().getHeader(Exchange.FILE_NAME));
// the in progress repo should not leak
assertEquals(0, repo.getCacheSize());
// and the file is still there
- assertTrue(Files.exists(testFile("a.txt")), "File should exist a.txt");
+ assertTrue(Files.exists(testFile(TEST_FILE_NAME_PREFIX + "a.txt")),
"File should exist a.txt");
}
@Test
public void testBrowsableTwoFiles() {
- template.sendBodyAndHeader(fileUri(), "A", Exchange.FILE_NAME,
"a.txt");
- template.sendBodyAndHeader(fileUri(), "B", Exchange.FILE_NAME,
"b.txt");
+ template.sendBodyAndHeader(fileUri(), "A", Exchange.FILE_NAME,
TEST_FILE_NAME_PREFIX + "a.txt");
+ template.sendBodyAndHeader(fileUri(), "B", Exchange.FILE_NAME,
TEST_FILE_NAME_PREFIX + "b.txt");
FileEndpoint endpoint
=
context.getEndpoint(fileUri("?initialDelay=0&delay=10&sortBy=file:name"),
FileEndpoint.class);
@@ -84,22 +87,24 @@ public class FileBrowsableEndpointTest extends
ContextTestSupport {
assertNotNull(list);
assertEquals(2, list.size());
- assertEquals("a.txt",
list.get(0).getIn().getHeader(Exchange.FILE_NAME));
- assertEquals("b.txt",
list.get(1).getIn().getHeader(Exchange.FILE_NAME));
+ assertEquals(TEST_FILE_NAME_PREFIX + "a.txt",
list.get(0).getIn().getHeader(Exchange.FILE_NAME));
+ assertEquals(TEST_FILE_NAME_PREFIX + "b.txt",
list.get(1).getIn().getHeader(Exchange.FILE_NAME));
// the in progress repo should not leak
assertEquals(0, repo.getCacheSize());
// and the files is still there
- assertTrue(Files.exists(testFile("a.txt")), "File should exist a.txt");
- assertTrue(Files.exists(testFile("b.txt")), "File should exist b.txt");
+ assertTrue(Files.exists(testFile(TEST_FILE_NAME_PREFIX + "a.txt")),
"File should exist a.txt");
+ assertTrue(Files.exists(testFile(TEST_FILE_NAME_PREFIX + "b.txt")),
"File should exist b.txt");
}
@Test
public void testBrowsableThreeFilesRecursive() {
- template.sendBodyAndHeader(fileUri(), "A", Exchange.FILE_NAME,
"a.txt");
- template.sendBodyAndHeader(fileUri(), "B", Exchange.FILE_NAME,
"foo/b.txt");
- template.sendBodyAndHeader(fileUri(), "C", Exchange.FILE_NAME,
"bar/c.txt");
+ template.sendBodyAndHeader(fileUri(), "A", Exchange.FILE_NAME,
TEST_FILE_NAME_PREFIX + "a.txt");
+ template.sendBodyAndHeader(fileUri(), "B", Exchange.FILE_NAME,
+ "foo" + File.separator + TEST_FILE_NAME_PREFIX + "b.txt");
+ template.sendBodyAndHeader(fileUri(), "C", Exchange.FILE_NAME,
+ "bar" + File.separator + TEST_FILE_NAME_PREFIX + "c.txt");
FileEndpoint endpoint = context.getEndpoint(
fileUri("?initialDelay=0&delay=10&recursive=true&sortBy=file:name"),
FileEndpoint.class);
@@ -112,16 +117,18 @@ public class FileBrowsableEndpointTest extends
ContextTestSupport {
assertNotNull(list);
assertEquals(3, list.size());
- assertEquals("a.txt",
list.get(0).getIn().getHeader(Exchange.FILE_NAME));
- assertEquals("c.txt",
list.get(1).getIn().getHeader(Exchange.FILE_NAME_ONLY));
- assertEquals("b.txt",
list.get(2).getIn().getHeader(Exchange.FILE_NAME_ONLY));
+ assertEquals(TEST_FILE_NAME_PREFIX + "a.txt",
list.get(0).getIn().getHeader(Exchange.FILE_NAME));
+ assertEquals(TEST_FILE_NAME_PREFIX + "c.txt",
list.get(1).getIn().getHeader(Exchange.FILE_NAME_ONLY));
+ assertEquals(TEST_FILE_NAME_PREFIX + "b.txt",
list.get(2).getIn().getHeader(Exchange.FILE_NAME_ONLY));
// the in progress repo should not leak
assertEquals(0, repo.getCacheSize());
// and the files is still there
- assertTrue(Files.exists(testFile("a.txt")), "File should exist a.txt");
- assertTrue(Files.exists(testFile("foo/b.txt")), "File should exist
foo/b.txt");
- assertTrue(Files.exists(testFile("bar/c.txt")), "File should exist
bar/c.txt");
+ assertTrue(Files.exists(testFile(TEST_FILE_NAME_PREFIX + "a.txt")),
"File should exist a.txt");
+ assertTrue(Files.exists(testFile("foo" + File.separator +
TEST_FILE_NAME_PREFIX + "b.txt")),
+ "File should exist foo/b.txt");
+ assertTrue(Files.exists(testFile("bar" + File.separator +
TEST_FILE_NAME_PREFIX + "c.txt")),
+ "File should exist bar/c.txt");
}
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeBackoffMultiplierTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeBackoffMultiplierTest.java
index 4224c8648ee..fc697bfee69 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeBackoffMultiplierTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeBackoffMultiplierTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.file;
+import java.util.UUID;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
@@ -27,12 +29,13 @@ import org.junit.jupiter.api.Test;
*
*/
public class FileConsumeBackoffMultiplierTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME = "report" + UUID.randomUUID()
+ ".txt";
@Override
@BeforeEach
public void setUp() throws Exception {
super.setUp();
- template.sendBodyAndHeader(fileUri(), "Hello World",
Exchange.FILE_NAME, "report.txt");
+ template.sendBodyAndHeader(fileUri(), "Hello World",
Exchange.FILE_NAME, TEST_FILE_NAME);
}
@Test
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeCharsetTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeCharsetTest.java
index 9b237c4ddeb..34efab19190 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeCharsetTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeCharsetTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.file;
import java.nio.file.Files;
+import java.util.UUID;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
@@ -31,13 +32,14 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
*
*/
public class FileConsumeCharsetTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME = "report" + UUID.randomUUID()
+ ".txt";
@Override
@BeforeEach
public void setUp() throws Exception {
super.setUp();
template.sendBodyAndHeader(fileUri("?charset=UTF-8"), "Hello World
\u4f60\u597d", Exchange.FILE_NAME,
- "report.txt");
+ TEST_FILE_NAME);
}
@Test
@@ -50,14 +52,14 @@ public class FileConsumeCharsetTest extends
ContextTestSupport {
oneExchangeDone.matchesWaitTime();
// file should not exists
- assertFalse(Files.exists(testFile("report.txt")), "File should been
deleted");
+ assertFalse(Files.exists(testFile(TEST_FILE_NAME)), "File should been
deleted");
}
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
-
from(fileUri("?initialDelay=0&delay=10&fileName=report.txt&delete=true&charset=UTF-8"))
+ from(fileUri("?initialDelay=0&delay=10&fileName=" +
TEST_FILE_NAME + "&delete=true&charset=UTF-8"))
.convertBodyTo(String.class).to("mock:result");
}
};
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDoneFileIssueTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDoneFileIssueTest.java
index 404ddf10729..a46d02f28a1 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDoneFileIssueTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDoneFileIssueTest.java
@@ -16,7 +16,9 @@
*/
package org.apache.camel.component.file;
+import java.io.File;
import java.nio.file.Files;
+import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.apache.camel.ContextTestSupport;
@@ -33,19 +35,21 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* CAMEL-5848
*/
public class FileConsumeDoneFileIssueTest extends ContextTestSupport {
+ private static final String TEST_DIR_NAME = "done" +
UUID.randomUUID().toString();
+ private static final String TEST_DIR_NAME_2 = "done2" +
UUID.randomUUID().toString();
@Test
public void testFileConsumeDoneFileIssue() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();
- template.sendBodyAndHeader(fileUri() + "/done", "A",
Exchange.FILE_NAME, "foo-a.txt");
- template.sendBodyAndHeader(fileUri() + "/done", "B",
Exchange.FILE_NAME, "foo-b.txt");
- template.sendBodyAndHeader(fileUri() + "/done", "C",
Exchange.FILE_NAME, "foo-c.txt");
- template.sendBodyAndHeader(fileUri() + "/done", "D",
Exchange.FILE_NAME, "foo-d.txt");
- template.sendBodyAndHeader(fileUri() + "/done", "E",
Exchange.FILE_NAME, "foo-e.txt");
- template.sendBodyAndHeader(fileUri() + "/done", "E",
Exchange.FILE_NAME, "foo.done");
+ template.sendBodyAndHeader(fileUri() + File.separator + TEST_DIR_NAME,
"A", Exchange.FILE_NAME, "foo-a.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator + TEST_DIR_NAME,
"B", Exchange.FILE_NAME, "foo-b.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator + TEST_DIR_NAME,
"C", Exchange.FILE_NAME, "foo-c.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator + TEST_DIR_NAME,
"D", Exchange.FILE_NAME, "foo-d.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator + TEST_DIR_NAME,
"E", Exchange.FILE_NAME, "foo-e.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator + TEST_DIR_NAME,
"E", Exchange.FILE_NAME, "foo.done");
- assertTrue(Files.exists(testFile("done/foo.done")), "Done file should
exists");
+ assertTrue(Files.exists(testFile(TEST_DIR_NAME + File.separator +
"foo.done")), "Done file should exists");
getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("A",
"B", "C", "D", "E");
@@ -56,23 +60,24 @@ public class FileConsumeDoneFileIssueTest extends
ContextTestSupport {
// the done file should be deleted
Awaitility.await().atLeast(50, TimeUnit.MILLISECONDS).untilAsserted(
- () -> assertFalse(Files.exists(testFile("done/foo.done")),
"Done file should be deleted"));
+ () -> assertFalse(Files.exists(testFile(TEST_DIR_NAME +
File.separator + "foo.done")),
+ "Done file should be deleted"));
}
@Test
public void testFileConsumeDynamicDoneFileName() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();
- template.sendBodyAndHeader(fileUri() + "/done2", "A",
Exchange.FILE_NAME, "a.txt");
- template.sendBodyAndHeader(fileUri() + "/done2", "B",
Exchange.FILE_NAME, "b.txt");
- template.sendBodyAndHeader(fileUri() + "/done2", "C",
Exchange.FILE_NAME, "c.txt");
- template.sendBodyAndHeader(fileUri() + "/done2", "a",
Exchange.FILE_NAME, "a.txt.done");
- template.sendBodyAndHeader(fileUri() + "/done2", "b",
Exchange.FILE_NAME, "b.txt.done");
- template.sendBodyAndHeader(fileUri() + "/done2", "c",
Exchange.FILE_NAME, "c.txt.done");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "A", Exchange.FILE_NAME, "a.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "B", Exchange.FILE_NAME, "b.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "C", Exchange.FILE_NAME, "c.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "a", Exchange.FILE_NAME, "a.txt.done");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "b", Exchange.FILE_NAME, "b.txt.done");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "c", Exchange.FILE_NAME, "c.txt.done");
- assertTrue(Files.exists(testFile("done2/a.txt.done")), "Done file
should exists");
- assertTrue(Files.exists(testFile("done2/b.txt.done")), "Done file
should exists");
- assertTrue(Files.exists(testFile("done2/c.txt.done")), "Done file
should exists");
+ assertTrue(Files.exists(testFile(TEST_DIR_NAME_2 + File.separator +
"a.txt.done")), "Done file should exists");
+ assertTrue(Files.exists(testFile(TEST_DIR_NAME_2 + File.separator +
"b.txt.done")), "Done file should exists");
+ assertTrue(Files.exists(testFile(TEST_DIR_NAME_2 + File.separator +
"c.txt.done")), "Done file should exists");
getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("A",
"B", "C");
@@ -83,11 +88,12 @@ public class FileConsumeDoneFileIssueTest extends
ContextTestSupport {
// the done file should be deleted
Awaitility.await().atLeast(50, TimeUnit.MILLISECONDS).untilAsserted(
- () -> assertFalse(Files.exists(testFile("done2/a.txt.done")),
"Done file should be deleted"));
+ () -> assertFalse(Files.exists(testFile(TEST_DIR_NAME_2 +
File.separator + "a.txt.done")),
+ "Done file should be deleted"));
// the done file should be deleted
- assertFalse(Files.exists(testFile("done2/b.txt.done")), "Done file
should be deleted");
- assertFalse(Files.exists(testFile("done2/c.txt.done")), "Done file
should be deleted");
+ assertFalse(Files.exists(testFile(TEST_DIR_NAME_2 + File.separator +
"b.txt.done")), "Done file should be deleted");
+ assertFalse(Files.exists(testFile(TEST_DIR_NAME_2 + File.separator +
"c.txt.done")), "Done file should be deleted");
}
@@ -95,16 +101,16 @@ public class FileConsumeDoneFileIssueTest extends
ContextTestSupport {
public void testFileDoneFileNameContainingDollarSign() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();
- template.sendBodyAndHeader(fileUri() + "/done2", "A",
Exchange.FILE_NAME, "$a$.txt");
- template.sendBodyAndHeader(fileUri() + "/done2", "B",
Exchange.FILE_NAME, "$b.txt");
- template.sendBodyAndHeader(fileUri() + "/done2", "C",
Exchange.FILE_NAME, "c$.txt");
- template.sendBodyAndHeader(fileUri() + "/done2", "a",
Exchange.FILE_NAME, "$a$.txt.done");
- template.sendBodyAndHeader(fileUri() + "/done2", "b",
Exchange.FILE_NAME, "$b.txt.done");
- template.sendBodyAndHeader(fileUri() + "/done2", "c",
Exchange.FILE_NAME, "c$.txt.done");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "A", Exchange.FILE_NAME, "$a$.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "B", Exchange.FILE_NAME, "$b.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "C", Exchange.FILE_NAME, "c$.txt");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "a", Exchange.FILE_NAME, "$a$.txt.done");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "b", Exchange.FILE_NAME, "$b.txt.done");
+ template.sendBodyAndHeader(fileUri() + File.separator +
TEST_DIR_NAME_2, "c", Exchange.FILE_NAME, "c$.txt.done");
- assertTrue(Files.exists(testFile("done2/$a$.txt.done")), "Done file
should exists");
- assertTrue(Files.exists(testFile("done2/$b.txt.done")), "Done file
should exists");
- assertTrue(Files.exists(testFile("done2/c$.txt.done")), "Done file
should exists");
+ assertTrue(Files.exists(testFile(TEST_DIR_NAME_2 + File.separator +
"$a$.txt.done")), "Done file should exists");
+ assertTrue(Files.exists(testFile(TEST_DIR_NAME_2 + File.separator +
"$b.txt.done")), "Done file should exists");
+ assertTrue(Files.exists(testFile(TEST_DIR_NAME_2 + File.separator +
"c$.txt.done")), "Done file should exists");
getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("A",
"B", "C");
@@ -115,10 +121,11 @@ public class FileConsumeDoneFileIssueTest extends
ContextTestSupport {
// the done file should be deleted
Awaitility.await().atLeast(50, TimeUnit.MILLISECONDS).untilAsserted(
- () ->
assertFalse(Files.exists(testFile("done2/$a$.txt.done")), "Done file should be
deleted"));
+ () -> assertFalse(Files.exists(testFile(TEST_DIR_NAME_2 +
File.separator + "$a$.txt.done")),
+ "Done file should be deleted"));
- assertFalse(Files.exists(testFile("done2/$b.txt.done")), "Done file
should be deleted");
- assertFalse(Files.exists(testFile("done2/c$.txt.done")), "Done file
should be deleted");
+ assertFalse(Files.exists(testFile(TEST_DIR_NAME_2 + File.separator +
"$b.txt.done")), "Done file should be deleted");
+ assertFalse(Files.exists(testFile(TEST_DIR_NAME_2 + File.separator +
"c$.txt.done")), "Done file should be deleted");
}
@Override
@@ -126,10 +133,11 @@ public class FileConsumeDoneFileIssueTest extends
ContextTestSupport {
return new RouteBuilder() {
@Override
public void configure() {
-
from(fileUri("done?doneFileName=foo.done&initialDelay=0&delay=10")).routeId("foo").autoStartup(false)
+ from(fileUri(TEST_DIR_NAME +
"?doneFileName=foo.done&initialDelay=0&delay=10")).routeId("foo")
+ .autoStartup(false)
.convertBodyTo(String.class).to("mock:result");
-
from(fileUri("done2?doneFileName=${file:name}.done&initialDelay=0&delay=10")).routeId("bar")
+ from(fileUri(TEST_DIR_NAME_2 +
"?doneFileName=${file:name}.done&initialDelay=0&delay=10")).routeId("bar")
.autoStartup(false).convertBodyTo(String.class).to("mock:result");
}
};
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDynamicDoneFileNameWithTwoDotsTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDynamicDoneFileNameWithTwoDotsTest.java
index 913a12c926b..bd304be4f1e 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDynamicDoneFileNameWithTwoDotsTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeDynamicDoneFileNameWithTwoDotsTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.file;
import java.nio.file.Files;
+import java.util.UUID;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
@@ -31,20 +32,21 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* This class tests an issue where an input file is not picked up due to a
dynamic doneFileName containing two dots.
*/
public class FileConsumeDynamicDoneFileNameWithTwoDotsTest extends
ContextTestSupport {
+ private static final String TEST_FILE_NAME_PREFIX =
UUID.randomUUID().toString();
@Test
public void testDynamicDoneFileNameContainingTwoDots() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("input-body");
- template.sendBodyAndHeader(fileUri(), "input-body",
Exchange.FILE_NAME, "test.twodot.txt");
- template.sendBodyAndHeader(fileUri(), "done-body", Exchange.FILE_NAME,
"test.twodot.done");
+ template.sendBodyAndHeader(fileUri(), "input-body",
Exchange.FILE_NAME, TEST_FILE_NAME_PREFIX + "test.twodot.txt");
+ template.sendBodyAndHeader(fileUri(), "done-body", Exchange.FILE_NAME,
TEST_FILE_NAME_PREFIX + "test.twodot.done");
assertMockEndpointsSatisfied();
assertTrue(notify.matchesWaitTime());
- assertFalse(Files.exists(testFile("test.twodot.txt")), "Input file
should be deleted");
- assertFalse(Files.exists(testFile("test.twodot.done")), "Done file
should be deleted");
+ assertFalse(Files.exists(testFile(TEST_FILE_NAME_PREFIX +
"test.twodot.txt")), "Input file should be deleted");
+ assertFalse(Files.exists(testFile(TEST_FILE_NAME_PREFIX +
"test.twodot.txt")), "Done file should be deleted");
}
@Override
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeHiddenDirsTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeHiddenDirsTest.java
index 45c61257d16..402cc45791b 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeHiddenDirsTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeHiddenDirsTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.file;
import java.nio.file.Files;
+import java.util.UUID;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
@@ -31,21 +32,23 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
* Unit test for consuming hidden dirs.
*/
public class FileConsumeHiddenDirsTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME_1 = "report1" +
UUID.randomUUID() + ".txt";
+ private static final String TEST_FILE_NAME_2 = "report2" +
UUID.randomUUID() + ".txt";
@Test
public void testConsumeHiddenDirs() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("Report 123", "Report 456");
- template.sendBodyAndHeader(fileUri(".hidden"), "Report 123",
Exchange.FILE_NAME, "report1.txt");
- template.sendBodyAndHeader(fileUri("obvious"), "Report 456",
Exchange.FILE_NAME, "report2.txt");
+ template.sendBodyAndHeader(fileUri(".hidden"), "Report 123",
Exchange.FILE_NAME, TEST_FILE_NAME_1);
+ template.sendBodyAndHeader(fileUri("obvious"), "Report 456",
Exchange.FILE_NAME, TEST_FILE_NAME_2);
assertMockEndpointsSatisfied();
Awaitility.await().untilAsserted(() -> {
// file should be deleted
- assertFalse(Files.exists(testFile(".hidden/report1.txt")), "File
should been deleted");
- assertFalse(Files.exists(testFile("obvious/report2.txt")), "File
should been deleted");
+ assertFalse(Files.exists(testFile(".hidden/" + TEST_FILE_NAME_1)),
"File should been deleted");
+ assertFalse(Files.exists(testFile("obvious/" + TEST_FILE_NAME_2)),
"File should been deleted");
});
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMaxMessagesPerPollTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMaxMessagesPerPollTest.java
index 66af0f84c3b..e688dbb0016 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMaxMessagesPerPollTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMaxMessagesPerPollTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.file;
+import java.util.UUID;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
@@ -26,6 +28,7 @@ import org.junit.jupiter.api.Test;
* Unit test for max messages per poll
*/
public class FileConsumeMaxMessagesPerPollTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME_PREFIX =
UUID.randomUUID().toString();
public static final String FILE_QUERY =
"?initialDelay=0&delay=10&maxMessagesPerPoll=2";
@@ -37,9 +40,9 @@ public class FileConsumeMaxMessagesPerPollTest extends
ContextTestSupport {
mock.message(0).exchangeProperty(Exchange.BATCH_SIZE).isEqualTo(2);
mock.message(1).exchangeProperty(Exchange.BATCH_SIZE).isEqualTo(2);
String fileUri = fileUri(FILE_QUERY);
- template.sendBodyAndHeader(fileUri, "Bye World", Exchange.FILE_NAME,
"bye.txt");
- template.sendBodyAndHeader(fileUri, "Hello World", Exchange.FILE_NAME,
"hello.txt");
- template.sendBodyAndHeader(fileUri, "Godday World",
Exchange.FILE_NAME, "godday.txt");
+ template.sendBodyAndHeader(fileUri, "Bye World", Exchange.FILE_NAME,
TEST_FILE_NAME_PREFIX + "bye.txt");
+ template.sendBodyAndHeader(fileUri, "Hello World", Exchange.FILE_NAME,
TEST_FILE_NAME_PREFIX + "hello.txt");
+ template.sendBodyAndHeader(fileUri, "Godday World",
Exchange.FILE_NAME, TEST_FILE_NAME_PREFIX + "godday.txt");
// start route
context.getRouteController().startRoute("foo");
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMoveRelativeNameTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMoveRelativeNameTest.java
index 1a543a12ec0..56d4913790c 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMoveRelativeNameTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMoveRelativeNameTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.file;
+import java.util.UUID;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
@@ -26,6 +28,7 @@ import org.junit.jupiter.api.Test;
* Unit test for consuming multiple directories.
*/
public class FileConsumeMoveRelativeNameTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME_PREFIX =
UUID.randomUUID().toString();
public static final String FILE_QUERY =
"?initialDelay=0&delay=10&recursive=true&move=.done/${file:name}.old";
@@ -34,13 +37,14 @@ public class FileConsumeMoveRelativeNameTest extends
ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("Bye World", "Hello World",
"Goodday World");
- mock.expectedFileExists(testFile(".done/bye.txt.old"));
- mock.expectedFileExists(testFile(".done/sub/hello.txt.old"));
- mock.expectedFileExists(testFile(".done/sub/sub2/goodday.txt.old"));
+ mock.expectedFileExists(testFile(".done/" + TEST_FILE_NAME_PREFIX +
"bye.txt.old"));
+ mock.expectedFileExists(testFile(".done/" + TEST_FILE_NAME_PREFIX +
"sub/hello.txt.old"));
+ mock.expectedFileExists(testFile(".done/" + TEST_FILE_NAME_PREFIX +
"sub/sub2/goodday.txt.old"));
String fileUrl = fileUri(FILE_QUERY);
- template.sendBodyAndHeader(fileUrl, "Bye World", Exchange.FILE_NAME,
"bye.txt");
- template.sendBodyAndHeader(fileUrl, "Hello World", Exchange.FILE_NAME,
"sub/hello.txt");
- template.sendBodyAndHeader(fileUrl, "Goodday World",
Exchange.FILE_NAME, "sub/sub2/goodday.txt");
+ template.sendBodyAndHeader(fileUrl, "Bye World", Exchange.FILE_NAME,
TEST_FILE_NAME_PREFIX + "bye.txt");
+ template.sendBodyAndHeader(fileUrl, "Hello World", Exchange.FILE_NAME,
TEST_FILE_NAME_PREFIX + "sub/hello.txt");
+ template.sendBodyAndHeader(fileUrl, "Goodday World",
Exchange.FILE_NAME,
+ TEST_FILE_NAME_PREFIX + "sub/sub2/goodday.txt");
context.getRouteController().startRoute("foo");
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
index 54056ec1e4d..1691128eb1f 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBeginRenameStrategyTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.file;
import java.io.File;
import java.io.FileWriter;
+import java.util.UUID;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
@@ -33,6 +34,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* Unit test for the FileRenameStrategy using preMove options
*/
public class FileConsumerBeginRenameStrategyTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME_1 = "paris" + UUID.randomUUID()
+ ".txt";
+ private static final String TEST_FILE_NAME_2 = "london" +
UUID.randomUUID() + ".txt";
@Test
public void testRenameSuccess() throws Exception {
@@ -40,7 +43,7 @@ public class FileConsumerBeginRenameStrategyTest extends
ContextTestSupport {
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Hello Paris");
- template.sendBodyAndHeader(fileUri("reports"), "Hello Paris",
Exchange.FILE_NAME, "paris.txt");
+ template.sendBodyAndHeader(fileUri("reports"), "Hello Paris",
Exchange.FILE_NAME, TEST_FILE_NAME_1);
mock.assertIsSatisfied();
}
@@ -50,7 +53,7 @@ public class FileConsumerBeginRenameStrategyTest extends
ContextTestSupport {
// create a file in inprogress to let there be a duplicate file
testDirectory("inprogress", true);
- try (FileWriter fw = new
FileWriter(testFile("inprogress/london.txt").toFile())) {
+ try (FileWriter fw = new FileWriter(testFile("inprogress/" +
TEST_FILE_NAME_2).toFile())) {
fw.write("I was there once in London");
fw.flush();
}
@@ -58,7 +61,7 @@ public class FileConsumerBeginRenameStrategyTest extends
ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:report");
mock.expectedBodiesReceived("Hello London");
- template.sendBodyAndHeader(fileUri("reports"), "Hello London",
Exchange.FILE_NAME, "london.txt");
+ template.sendBodyAndHeader(fileUri("reports"), "Hello London",
Exchange.FILE_NAME, TEST_FILE_NAME_2);
mock.assertIsSatisfied();
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileToFileNioLowBufferTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileToFileNioLowBufferTest.java
index 6cbeb2de752..0f8c26c3f46 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileToFileNioLowBufferTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileToFileNioLowBufferTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.file;
+import java.util.UUID;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
@@ -23,15 +25,16 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
public class FileToFileNioLowBufferTest extends ContextTestSupport {
+ private static final String TEST_FILE_NAME = "hello" + UUID.randomUUID() +
".txt";
@Test
public void testFileToFileNioLowBuffer() throws Exception {
String body = "1234567890123456789012345678901234567890";
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
- mock.expectedFileExists(testFile("out/hello.txt"), body);
+ mock.expectedFileExists(testFile("out/" + TEST_FILE_NAME), body);
- template.sendBodyAndHeader(fileUri("in"), body, Exchange.FILE_NAME,
"hello.txt");
+ template.sendBodyAndHeader(fileUri("in"), body, Exchange.FILE_NAME,
TEST_FILE_NAME);
assertMockEndpointsSatisfied();
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FilerConsumerMoveFailedDoneFileNameTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FilerConsumerMoveFailedDoneFileNameTest.java
index d9848a88428..8b9ed7152d5 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FilerConsumerMoveFailedDoneFileNameTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FilerConsumerMoveFailedDoneFileNameTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file;
+import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.apache.camel.ContextTestSupport;
@@ -27,12 +28,13 @@ import org.junit.jupiter.api.Test;
* Unit test done files with moveFailed option
*/
public class FilerConsumerMoveFailedDoneFileNameTest extends
ContextTestSupport {
+ private static final String TEST_FILE_NAME = "hello" + UUID.randomUUID() +
".txt";
@Test
public void testDoneFile() throws Exception {
getMockEndpoint("mock:input").expectedMessageCount(1);
- template.sendBodyAndHeader(fileUri(), "Hello World",
Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader(fileUri(), "Hello World",
Exchange.FILE_NAME, TEST_FILE_NAME);
template.sendBodyAndHeader(fileUri(), "", Exchange.FILE_NAME, "done");
// wait a bit for the file processing to complete
@@ -44,7 +46,7 @@ public class FilerConsumerMoveFailedDoneFileNameTest extends
ContextTestSupport
assertFileNotExists(testFile("done"));
// as well the original file should be moved to failed
- assertFileExists(testFile("failed/hello.txt"));
+ assertFileExists(testFile("failed/" + TEST_FILE_NAME));
}
@Override