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 d375c7f Fixed tests d375c7f is described below commit d375c7f82e4a6116284783f3754c995cf0141b81 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Feb 4 07:08:29 2021 +0100 Fixed tests --- .../component/file/watch/FileWatchComponentTest.java | 14 +++++++------- .../component/file/watch/SpringFileWatcherTest.java | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java index 0dbae10..ba4955a 100644 --- a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java +++ b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java @@ -75,12 +75,12 @@ public class FileWatchComponentTest extends FileWatchComponentTestBase { @Test public void testRemoveFile() throws Exception { MockEndpoint mock = getMockEndpoint("mock:watchDelete"); + mock.expectedMessageCount(2); + mock.setResultWaitTime(1000); Files.delete(testFiles.get(0)); Files.delete(testFiles.get(1)); - mock.expectedMessageCount(2); - mock.setResultWaitTime(1000); mock.assertIsSatisfied(); } @@ -120,11 +120,11 @@ public class FileWatchComponentTest extends FileWatchComponentTestBase { @Test public void createModifyReadBodyAsString() throws Exception { MockEndpoint mock = getMockEndpoint("mock:watchAll"); + mock.setExpectedCount(1); + mock.setResultWaitTime(1000); Files.write(testFiles.get(0), "Hello".getBytes(), StandardOpenOption.SYNC); - mock.setExpectedCount(1); - mock.setResultWaitTime(1000); mock.assertIsSatisfied(); assertEquals("Hello", mock.getExchanges().get(0).getIn().getBody(String.class)); } @@ -132,14 +132,14 @@ public class FileWatchComponentTest extends FileWatchComponentTestBase { @Test public void testCreateBatch() throws Exception { MockEndpoint mock = getMockEndpoint("mock:watchAll"); + mock.expectedMessageCount(10); + mock.expectedMessagesMatches(exchange -> exchange.getIn() + .getHeader(FileWatchComponent.EVENT_TYPE_HEADER, FileEventEnum.class) == FileEventEnum.CREATE); for (int i = 0; i < 10; i++) { createFile(testPath(), i + ""); } - mock.expectedMessageCount(10); - mock.expectedMessagesMatches(exchange -> exchange.getIn() - .getHeader(FileWatchComponent.EVENT_TYPE_HEADER, FileEventEnum.class) == FileEventEnum.CREATE); assertMockEndpointsSatisfied(); } diff --git a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/SpringFileWatcherTest.java b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/SpringFileWatcherTest.java index ed9cfd6..c5c7aa5 100644 --- a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/SpringFileWatcherTest.java +++ b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/SpringFileWatcherTest.java @@ -46,29 +46,32 @@ public class SpringFileWatcherTest extends CamelSpringTestSupport { @Test public void testDefaultConfig() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:springTest"); + mock.setExpectedCount(2); // two MODIFY events + mock.setResultWaitTime(1000); + Files.write(springTestFile.toPath(), "modification".getBytes(), StandardOpenOption.SYNC); - // Adding few millis to avoid fleaky tests + // Adding few millis to avoid flaky tests // The file hasher could sometimes evaluate these two changes as duplicate, as the second modification of file could be done before hashing is done Thread.sleep(50); Files.write(springTestFile.toPath(), "modification 2".getBytes(), StandardOpenOption.SYNC); - MockEndpoint mock = getMockEndpoint("mock:springTest"); - mock.setExpectedCount(2); // two MODIFY events - mock.setResultWaitTime(1000); + mock.assertIsSatisfied(); } @Test public void testCustomHasher() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:springTestCustomHasher"); + mock.setExpectedCount(1); // We passed dummy TestHasher which returns constant hashcode. This should cause, that second MODIFY event is discarded + mock.setResultWaitTime(1000); + Files.write(springTestCustomHasherFile.toPath(), "first modification".getBytes(), StandardOpenOption.SYNC); - // Adding few millis to avoid fleaky tests + // Adding few millis to avoid flaky tests // The file hasher could sometimes evaluate these two changes as duplicate, as the second modification of file could be done before hashing is done Thread.sleep(50); Files.write(springTestCustomHasherFile.toPath(), "second modification".getBytes(), StandardOpenOption.SYNC); - MockEndpoint mock = getMockEndpoint("mock:springTestCustomHasher"); - mock.setExpectedCount(1); // We passed dummy TestHasher which returns constant hashcode. This should cause, that second MODIFY event is discarded - mock.setResultWaitTime(1000); mock.assertIsSatisfied(); }