This is an automated email from the ASF dual-hosted git repository. acosentino 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 6c7d25e6e3d CAMEL-20686 - Appended static test filenames with UUID (set 5) (#14845) 6c7d25e6e3d is described below commit 6c7d25e6e3db6f6ca2e6726507c2fceb0215d447 Author: Jang-Vijay Singh <jvs...@gmail.com> AuthorDate: Wed Jul 17 13:31:55 2024 +0100 CAMEL-20686 - Appended static test filenames with UUID (set 5) (#14845) * CAMEL--20686 - appended static test filenames with UUID (set 5) * CAMEL-20686 - fixed static filename reference + removed @DisabledOnOs * CAMEL-20686 - dynamic filenames+wait to address flakiness --- .../file/FileBeginFailureOneTimeTest.java | 11 +- .../FileConsumerAbsolutePathDefaultMoveTest.java | 15 ++- ...FileConsumerIdempotentKeyChangedIssue2Test.java | 8 +- .../file/FileProducerFileExistIgnoreTest.java | 9 +- .../file/FileProducerFileExistOverrideTest.java | 11 +- .../file/FileProducerFileExistTryRenameTest.java | 15 ++- .../file/FileRouteOnDosWithNoVolTest.java | 13 ++- .../camel/impl/DefaultConsumerTemplateTest.java | 117 +++++++++++---------- 8 files changed, 112 insertions(+), 87 deletions(-) diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileBeginFailureOneTimeTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileBeginFailureOneTimeTest.java index e09ad152f88..29faaf12f6d 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileBeginFailureOneTimeTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileBeginFailureOneTimeTest.java @@ -17,6 +17,7 @@ package org.apache.camel.component.file; import java.io.File; +import java.util.UUID; import java.util.concurrent.atomic.LongAdder; import org.apache.camel.ContextTestSupport; @@ -29,7 +30,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; public class FileBeginFailureOneTimeTest extends ContextTestSupport { - + private static final String TEST_FILE_NAME = "hello" + UUID.randomUUID() + ".txt"; private final MyStrategy myStrategy = new MyStrategy(); @Override @@ -44,7 +45,7 @@ public class FileBeginFailureOneTimeTest extends ContextTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, TEST_FILE_NAME); assertMockEndpointsSatisfied(); @@ -68,7 +69,7 @@ public class FileBeginFailureOneTimeTest extends ContextTestSupport { @Override public void prepareOnStartup( - GenericFileOperations<File> fileGenericFileOperations, GenericFileEndpoint<File> fileGenericFileEndpoint) { + GenericFileOperations<File> fileGenericFileOperations, GenericFileEndpoint<File> fileGenericFileEndpoint) { //noop } @Override @@ -95,14 +96,14 @@ public class FileBeginFailureOneTimeTest extends ContextTestSupport { public void commit( GenericFileOperations<File> fileGenericFileOperations, GenericFileEndpoint<File> fileGenericFileEndpoint, Exchange exchange, - GenericFile<File> fileGenericFile) { + GenericFile<File> fileGenericFile) { // noop - has to implement interface, but nothing to do } @Override public void rollback( GenericFileOperations<File> fileGenericFileOperations, GenericFileEndpoint<File> fileGenericFileEndpoint, Exchange exchange, - GenericFile<File> fileGenericFile) { + GenericFile<File> fileGenericFile) { //noop - has to implement interface, but nothing to do } public int getInvoked() { diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerAbsolutePathDefaultMoveTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerAbsolutePathDefaultMoveTest.java index 1069b4538a1..862fb61d29d 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerAbsolutePathDefaultMoveTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerAbsolutePathDefaultMoveTest.java @@ -16,24 +16,35 @@ */ package org.apache.camel.component.file; +import java.util.UUID; +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.awaitility.Awaitility; import org.junit.jupiter.api.Test; /** * Unit test for consuming from an absolute path */ public class FileConsumerAbsolutePathDefaultMoveTest extends ContextTestSupport { + private static final String TEST_FILE_NAME = "paris" + UUID.randomUUID() + ".txt"; @Test public void testConsumeFromAbsolutePath() throws Exception { MockEndpoint mock = getMockEndpoint("mock:report"); mock.expectedBodiesReceived("Hello Paris"); - mock.expectedFileExists(testFile(".camel/paris.txt")); + mock.expectedFileExists(testFile(".camel/" + TEST_FILE_NAME)); - template.sendBodyAndHeader(fileUri(), "Hello Paris", Exchange.FILE_NAME, "paris.txt"); + Awaitility.await() + .atMost(5, TimeUnit.SECONDS) + .pollDelay(250, TimeUnit.MILLISECONDS) + .untilAsserted(() -> { + template.sendBodyAndHeader(fileUri(), "Hello Paris", Exchange.FILE_NAME, TEST_FILE_NAME); + assertMockEndpointsSatisfied(); + }); mock.assertIsSatisfied(); } diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentKeyChangedIssue2Test.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentKeyChangedIssue2Test.java index 9de17aabc59..5997e0bdfef 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentKeyChangedIssue2Test.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentKeyChangedIssue2Test.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; @@ -26,6 +27,7 @@ import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; public class FileConsumerIdempotentKeyChangedIssue2Test extends ContextTestSupport { + private static final String TEST_FILE_NAME = "hello" + UUID.randomUUID() + ".txt"; private Endpoint endpoint; @@ -33,7 +35,7 @@ public class FileConsumerIdempotentKeyChangedIssue2Test extends ContextTestSuppo public void testFile() throws Exception { getMockEndpoint("mock:file").expectedBodiesReceived("Hello World"); - template.sendBodyAndHeader(endpoint, "Hello World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader(endpoint, "Hello World", Exchange.FILE_NAME, TEST_FILE_NAME); context.getRouteController().startAllRoutes(); @@ -46,7 +48,7 @@ public class FileConsumerIdempotentKeyChangedIssue2Test extends ContextTestSuppo // wait a bit to allow the consumer to poll once and see a non-changed // file Awaitility.await().pollDelay(250, TimeUnit.MILLISECONDS).untilAsserted(() -> { - template.sendBodyAndHeader(endpoint, "Hello World Again", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader(endpoint, "Hello World Again", Exchange.FILE_NAME, TEST_FILE_NAME); assertMockEndpointsSatisfied(); }); } @@ -59,7 +61,7 @@ public class FileConsumerIdempotentKeyChangedIssue2Test extends ContextTestSuppo endpoint = endpoint(fileUri("?noop=true&initialDelay=0&delay=100" + "&idempotentKey=${file:name}-${file:size}-${file:modified}")); - from(endpoint).noAutoStartup().convertBodyTo(String.class).to("log:file").to("mock:file"); + from(endpoint).autoStartup(false).convertBodyTo(String.class).to("log:file").to("mock:file"); } }; } diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistIgnoreTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistIgnoreTest.java index 060820542d4..741a89989c8 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistIgnoreTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistIgnoreTest.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 FileProducerFileExistIgnoreTest extends ContextTestSupport { + private static final String TEST_FILE_NAME = "hello" + UUID.randomUUID() + ".txt"; @Test public void testIgnore() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedBodiesReceived("Hello World"); - mock.expectedFileExists(testFile("hello.txt"), "Hello World"); + mock.expectedFileExists(testFile(TEST_FILE_NAME), "Hello World"); - template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, "hello.txt"); - template.sendBodyAndHeader(fileUri("?fileExist=Ignore"), "Bye World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, TEST_FILE_NAME); + template.sendBodyAndHeader(fileUri("?fileExist=Ignore"), "Bye World", Exchange.FILE_NAME, TEST_FILE_NAME); assertMockEndpointsSatisfied(); } diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistOverrideTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistOverrideTest.java index 2f9b029117d..7462c364573 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistOverrideTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistOverrideTest.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 FileProducerFileExistOverrideTest extends ContextTestSupport { + private static final String TEST_FILE_NAME = "hello" + UUID.randomUUID() + ".txt"; @Test public void testOverride() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedBodiesReceived("Bye World"); - mock.expectedFileExists(testFile("hello.txt"), "Bye World"); + mock.expectedFileExists(testFile(TEST_FILE_NAME), "Bye World"); - template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, "hello.txt"); - template.sendBodyAndHeader(fileUri("?fileExist=Override"), "Bye World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, TEST_FILE_NAME); + template.sendBodyAndHeader(fileUri("?fileExist=Override"), "Bye World", Exchange.FILE_NAME, TEST_FILE_NAME); context.getRouteController().startAllRoutes(); @@ -43,7 +46,7 @@ public class FileProducerFileExistOverrideTest extends ContextTestSupport { return new RouteBuilder() { @Override public void configure() { - from(fileUri("?noop=true&initialDelay=0&delay=10")).noAutoStartup().convertBodyTo(String.class) + from(fileUri("?noop=true&initialDelay=0&delay=10")).autoStartup(false).convertBodyTo(String.class) .to("mock:result"); } }; diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistTryRenameTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistTryRenameTest.java index 5caf6cdd37f..c524ee38d95 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistTryRenameTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerFileExistTryRenameTest.java @@ -16,27 +16,26 @@ */ 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; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; -@DisabledOnOs(OS.WINDOWS) public class FileProducerFileExistTryRenameTest extends ContextTestSupport { + private static final String TEST_FILE_NAME = "hello" + UUID.randomUUID() + ".txt"; @Test public void testIgnore() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedBodiesReceived("Bye World"); - mock.expectedFileExists(testFile("hello.txt"), "Bye World"); + mock.expectedFileExists(testFile(TEST_FILE_NAME), "Bye World"); - template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, TEST_FILE_NAME); template.sendBodyAndHeader(fileUri("?fileExist=TryRename&tempPrefix=tmp"), "Bye World", - Exchange.FILE_NAME, "hello.txt"); - + Exchange.FILE_NAME, TEST_FILE_NAME); context.getRouteController().startAllRoutes(); assertMockEndpointsSatisfied(); @@ -47,7 +46,7 @@ public class FileProducerFileExistTryRenameTest extends ContextTestSupport { return new RouteBuilder() { @Override public void configure() { - from(fileUri("?noop=true&initialDelay=0&delay=10")).noAutoStartup().convertBodyTo(String.class) + from(fileUri("?noop=true&initialDelay=0&delay=10")).autoStartup(false).convertBodyTo(String.class) .to("mock:result"); } }; diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileRouteOnDosWithNoVolTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileRouteOnDosWithNoVolTest.java index 87778202213..6531f9af592 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileRouteOnDosWithNoVolTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileRouteOnDosWithNoVolTest.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; @@ -30,6 +32,7 @@ import org.junit.jupiter.api.Test; * will work on windows system. */ public class FileRouteOnDosWithNoVolTest extends ContextTestSupport { + private static final String TEST_FILE_NAME = "hello" + UUID.randomUUID() + ".txt"; private String path; @@ -49,9 +52,9 @@ public class FileRouteOnDosWithNoVolTest extends ContextTestSupport { public void testRouteFileToFile() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - mock.expectedFileExists(path + "/route/out/hello.txt"); + mock.expectedFileExists(path + "/route/out/" + TEST_FILE_NAME); - template.sendBodyAndHeader("file://" + path + "/route/poller", "Hello World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader("file://" + path + "/route/poller", "Hello World", Exchange.FILE_NAME, TEST_FILE_NAME); assertMockEndpointsSatisfied(); } @@ -61,7 +64,7 @@ public class FileRouteOnDosWithNoVolTest extends ContextTestSupport { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - template.sendBodyAndHeader("file://" + path + "/from/poller", "Hello World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader("file://" + path + "/from/poller", "Hello World", Exchange.FILE_NAME, TEST_FILE_NAME); assertMockEndpointsSatisfied(); } @@ -70,9 +73,9 @@ public class FileRouteOnDosWithNoVolTest extends ContextTestSupport { public void testRouteToFileOnly() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); - mock.expectedFileExists(path + "/to/out/hello.txt"); + mock.expectedFileExists(path + "/to/out/" + TEST_FILE_NAME); - template.sendBodyAndHeader("direct:report", "Hello World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader("direct:report", "Hello World", Exchange.FILE_NAME, TEST_FILE_NAME); assertMockEndpointsSatisfied(); } diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerTemplateTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerTemplateTest.java index 6f6d33755c1..cc0831386ed 100644 --- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerTemplateTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerTemplateTest.java @@ -16,6 +16,7 @@ */ package org.apache.camel.impl; +import java.util.UUID; import java.util.concurrent.TimeUnit; import org.apache.camel.ConsumerTemplate; @@ -39,6 +40,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; public class DefaultConsumerTemplateTest extends ContextTestSupport { + private static final String TEST_FILE_NAME = "hello" + UUID.randomUUID() + ".txt"; + private static final String TEST_SEDA_CONSUMER = "foo" + UUID.randomUUID(); private DefaultConsumerTemplate consumer; @@ -59,9 +62,9 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeReceive() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); - Exchange out = consumer.receive("seda:foo"); + Exchange out = consumer.receive("seda:" + TEST_SEDA_CONSUMER); assertNotNull(out); assertEquals("Hello", out.getIn().getBody()); @@ -70,28 +73,28 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeTwiceReceive() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); - Exchange out = consumer.receive("seda:foo"); + Exchange out = consumer.receive("seda:" + TEST_SEDA_CONSUMER); assertNotNull(out); assertEquals("Hello", out.getIn().getBody()); - template.sendBody("seda:foo", "Bye"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Bye"); - out = consumer.receive("seda:foo"); + out = consumer.receive("seda:" + TEST_SEDA_CONSUMER); assertNotNull(out); assertEquals("Bye", out.getIn().getBody()); } @Test public void testConsumeReceiveNoWait() { - Exchange out = consumer.receiveNoWait("seda:foo"); + Exchange out = consumer.receiveNoWait("seda:" + TEST_SEDA_CONSUMER); assertNull(out); - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); await().atMost(1, TimeUnit.SECONDS).until(() -> { - Exchange foo = consumer.receiveNoWait("seda:foo"); + Exchange foo = consumer.receiveNoWait("seda:" + TEST_SEDA_CONSUMER); if (foo != null) { assertEquals("Hello", foo.getIn().getBody()); } @@ -102,91 +105,91 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeReceiveTimeout() { StopWatch watch = new StopWatch(); - Exchange out = consumer.receive("seda:foo", 1000); + Exchange out = consumer.receive("seda:" + TEST_SEDA_CONSUMER, 1000); assertNull(out); long delta = watch.taken(); assertTrue(delta < 1500, "Should take about 1 sec: " + delta); - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); - out = consumer.receive("seda:foo"); + out = consumer.receive("seda:" + TEST_SEDA_CONSUMER); assertEquals("Hello", out.getIn().getBody()); } @Test public void testConsumeReceiveBody() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); - Object body = consumer.receiveBody("seda:foo"); + Object body = consumer.receiveBody("seda:" + TEST_SEDA_CONSUMER); assertEquals("Hello", body); } @Test public void testConsumeTwiceReceiveBody() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); - Object body = consumer.receiveBody("seda:foo"); + Object body = consumer.receiveBody("seda:" + TEST_SEDA_CONSUMER); assertEquals("Hello", body); - template.sendBody("seda:foo", "Bye"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Bye"); - body = consumer.receiveBody("seda:foo"); + body = consumer.receiveBody("seda:" + TEST_SEDA_CONSUMER); assertEquals("Bye", body); } @Test public void testConsumeReceiveBodyNoWait() { - Object body = consumer.receiveBodyNoWait("seda:foo"); + Object body = consumer.receiveBodyNoWait("seda:" + TEST_SEDA_CONSUMER); assertNull(body); - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); await().atMost(1, TimeUnit.SECONDS).untilAsserted(() -> { - Object foo = consumer.receiveBodyNoWait("seda:foo"); + Object foo = consumer.receiveBodyNoWait("seda:" + TEST_SEDA_CONSUMER); assertEquals("Hello", foo); }); } @Test public void testConsumeReceiveBodyString() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); - String body = consumer.receiveBody("seda:foo", String.class); + String body = consumer.receiveBody("seda:" + TEST_SEDA_CONSUMER, String.class); assertEquals("Hello", body); } @Test public void testConsumeTwiceReceiveBodyString() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); - String body = consumer.receiveBody("seda:foo", String.class); + String body = consumer.receiveBody("seda:" + TEST_SEDA_CONSUMER, String.class); assertEquals("Hello", body); - template.sendBody("seda:foo", "Bye"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Bye"); - body = consumer.receiveBody("seda:foo", String.class); + body = consumer.receiveBody("seda:" + TEST_SEDA_CONSUMER, String.class); assertEquals("Bye", body); } @Test public void testConsumeReceiveBodyStringNoWait() { - String body = consumer.receiveBodyNoWait("seda:foo", String.class); + String body = consumer.receiveBodyNoWait("seda:" + TEST_SEDA_CONSUMER, String.class); assertNull(body); - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); await().atMost(1, TimeUnit.SECONDS).untilAsserted(() -> { - String foo = consumer.receiveBodyNoWait("seda:foo", String.class); + String foo = consumer.receiveBodyNoWait("seda:" + TEST_SEDA_CONSUMER, String.class); assertEquals("Hello", foo); }); } @Test public void testConsumeReceiveEndpoint() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); assertNotNull(consumer.getCamelContext()); - Endpoint endpoint = context.getEndpoint("seda:foo"); + Endpoint endpoint = context.getEndpoint("seda:" + TEST_SEDA_CONSUMER); Exchange out = consumer.receive(endpoint); assertEquals("Hello", out.getIn().getBody()); @@ -194,10 +197,10 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeReceiveEndpointTimeout() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); assertNotNull(consumer.getCamelContext()); - Endpoint endpoint = context.getEndpoint("seda:foo"); + Endpoint endpoint = context.getEndpoint("seda:" + TEST_SEDA_CONSUMER); Exchange out = consumer.receive(endpoint, 1000); assertEquals("Hello", out.getIn().getBody()); @@ -206,12 +209,12 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeReceiveEndpointNoWait() { assertNotNull(consumer.getCamelContext()); - Endpoint endpoint = context.getEndpoint("seda:foo"); + Endpoint endpoint = context.getEndpoint("seda:" + TEST_SEDA_CONSUMER); Exchange out = consumer.receiveNoWait(endpoint); assertNull(out); - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); await().atMost(1, TimeUnit.SECONDS).until(() -> { Exchange foo = consumer.receiveNoWait(endpoint); @@ -224,10 +227,10 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeReceiveEndpointBody() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); assertNotNull(consumer.getCamelContext()); - Endpoint endpoint = context.getEndpoint("seda:foo"); + Endpoint endpoint = context.getEndpoint("seda:" + TEST_SEDA_CONSUMER); Object body = consumer.receiveBody(endpoint); assertEquals("Hello", body); @@ -235,10 +238,10 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeReceiveEndpointBodyTimeout() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); assertNotNull(consumer.getCamelContext()); - Endpoint endpoint = context.getEndpoint("seda:foo"); + Endpoint endpoint = context.getEndpoint("seda:" + TEST_SEDA_CONSUMER); Object body = consumer.receiveBody(endpoint, 1000); assertEquals("Hello", body); @@ -246,10 +249,10 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeReceiveEndpointBodyType() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); assertNotNull(consumer.getCamelContext()); - Endpoint endpoint = context.getEndpoint("seda:foo"); + Endpoint endpoint = context.getEndpoint("seda:" + TEST_SEDA_CONSUMER); String body = consumer.receiveBody(endpoint, String.class); assertEquals("Hello", body); @@ -257,10 +260,10 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeReceiveEndpointBodyTimeoutType() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); assertNotNull(consumer.getCamelContext()); - Endpoint endpoint = context.getEndpoint("seda:foo"); + Endpoint endpoint = context.getEndpoint("seda:" + TEST_SEDA_CONSUMER); String body = consumer.receiveBody(endpoint, 1000, String.class); assertEquals("Hello", body); @@ -268,21 +271,21 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeReceiveBodyTimeoutType() { - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); - String body = consumer.receiveBody("seda:foo", 1000, String.class); + String body = consumer.receiveBody("seda:" + TEST_SEDA_CONSUMER, 1000, String.class); assertEquals("Hello", body); } @Test public void testConsumeReceiveEndpointBodyTypeNoWait() { assertNotNull(consumer.getCamelContext()); - Endpoint endpoint = context.getEndpoint("seda:foo"); + Endpoint endpoint = context.getEndpoint("seda:" + TEST_SEDA_CONSUMER); String out = consumer.receiveBodyNoWait(endpoint, String.class); assertNull(out); - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); await().atMost(1, TimeUnit.SECONDS).untilAsserted(() -> { String foo = consumer.receiveBodyNoWait(endpoint, String.class); @@ -293,12 +296,12 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testConsumeReceiveEndpointBodyNoWait() { assertNotNull(consumer.getCamelContext()); - Endpoint endpoint = context.getEndpoint("seda:foo"); + Endpoint endpoint = context.getEndpoint("seda:" + TEST_SEDA_CONSUMER); Object out = consumer.receiveBodyNoWait(endpoint); assertNull(out); - template.sendBody("seda:foo", "Hello"); + template.sendBody("seda:" + TEST_SEDA_CONSUMER, "Hello"); await().atMost(1, TimeUnit.SECONDS).untilAsserted(() -> { Object foo = consumer.receiveBodyNoWait(endpoint); @@ -311,12 +314,12 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { Exchange exchange = new DefaultExchange(context); exchange.setException(new IllegalArgumentException("Damn")); - Exchange out = template.send("seda:foo", exchange); + Exchange out = template.send("seda:" + TEST_SEDA_CONSUMER, exchange); assertTrue(out.isFailed()); assertNotNull(out.getException()); try { - consumer.receiveBody("seda:foo", String.class); + consumer.receiveBody("seda:" + TEST_SEDA_CONSUMER, String.class); fail("Should have thrown an exception"); } catch (RuntimeCamelException e) { assertIsInstanceOf(IllegalArgumentException.class, e.getCause()); @@ -328,9 +331,9 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { public void testReceiveOut() { Exchange exchange = new DefaultExchange(context); exchange.getMessage().setBody("Bye World"); - template.send("seda:foo", exchange); + template.send("seda:" + TEST_SEDA_CONSUMER, exchange); - String out = consumer.receiveBody("seda:foo", String.class); + String out = consumer.receiveBody("seda:" + TEST_SEDA_CONSUMER, String.class); assertEquals("Bye World", out); } @@ -388,18 +391,18 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport { @Test public void testDoneUoW() { - template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, "hello.txt"); + template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, TEST_FILE_NAME); Exchange exchange = consumer.receive(fileUri("?initialDelay=0&delay=10&delete=true")); assertNotNull(exchange); assertEquals("Hello World", exchange.getIn().getBody(String.class)); // file should still exists - assertFileExists(testFile("hello.txt")); + assertFileExists(testFile(TEST_FILE_NAME)); // done the exchange consumer.doneUoW(exchange); - assertFileNotExists(testFile("hello.txt")); + assertFileNotExists(testFile(TEST_FILE_NAME)); } }