This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0e6abd0d858340a57535fef23ee97af4b53a122f Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Oct 24 13:30:19 2019 +0200 Camel-Seda: Added the example code --- .../camel-seda/src/main/docs/seda-component.adoc | 60 +++++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/components/camel-seda/src/main/docs/seda-component.adoc b/components/camel-seda/src/main/docs/seda-component.adoc index f63dcab..4c4c00d 100644 --- a/components/camel-seda/src/main/docs/seda-component.adoc +++ b/components/camel-seda/src/main/docs/seda-component.adoc @@ -238,14 +238,70 @@ to the original caller. [source,java] ---- -include::{examplesdir}/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaAsyncRouteTest.java[tags=example] + @Test + public void testSendAsync() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedBodiesReceived("Hello World"); + + // START SNIPPET: e2 + Object out = template.requestBody("direct:start", "Hello World"); + assertEquals("OK", out); + // END SNIPPET: e2 + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + // START SNIPPET: e1 + public void configure() throws Exception { + from("direct:start") + // send it to the seda queue that is async + .to("seda:next") + // return a constant response + .transform(constant("OK")); + + from("seda:next").to("mock:result"); + } + // END SNIPPET: e1 + }; + } ---- Here we send a Hello World message and expects the reply to be OK. [source,java] ---- -include::{examplesdir}/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaAsyncRouteTest.java[tags=example] + @Test + public void testSendAsync() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedBodiesReceived("Hello World"); + + // START SNIPPET: e2 + Object out = template.requestBody("direct:start", "Hello World"); + assertEquals("OK", out); + // END SNIPPET: e2 + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + // START SNIPPET: e1 + public void configure() throws Exception { + from("direct:start") + // send it to the seda queue that is async + .to("seda:next") + // return a constant response + .transform(constant("OK")); + + from("seda:next").to("mock:result"); + } + // END SNIPPET: e1 + }; + } ----