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 b2cd1118f96 CAMEL-18467: [DOCS] Velocity component - missing java code
sample
b2cd1118f96 is described below
commit b2cd1118f9660df946b94aac2a90c777468087b2
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Sep 5 18:28:17 2022 +0200
CAMEL-18467: [DOCS] Velocity component - missing java code sample
---
.../src/main/docs/velocity-component.adoc | 38 +++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/components/camel-velocity/src/main/docs/velocity-component.adoc
b/components/camel-velocity/src/main/docs/velocity-component.adoc
index ef51863c8c8..01216b529da 100644
--- a/components/camel-velocity/src/main/docs/velocity-component.adoc
+++ b/components/camel-velocity/src/main/docs/velocity-component.adoc
@@ -204,6 +204,8 @@ from("direct:in").
In this sample we want to use Velocity templating for an order
confirmation email. The email template is laid out in Velocity as:
+.letter.vm
+[source,text]
----------------------------------------------
Dear ${headers.lastName}, ${headers.firstName}
@@ -213,8 +215,42 @@ Regards Camel Riders Bookstore
${body}
----------------------------------------------
-And the java code:
+And the java code (from an unit test):
+[source,java]
+----
+ private Exchange createLetter() {
+ Exchange exchange = context.getEndpoint("direct:a").createExchange();
+ Message msg = exchange.getIn();
+ msg.setHeader("firstName", "Claus");
+ msg.setHeader("lastName", "Ibsen");
+ msg.setHeader("item", "Camel in Action");
+ msg.setBody("PS: Next beer is on me, James");
+ return exchange;
+ }
+
+ @Test
+ public void testVelocityLetter() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.message(0).body(String.class).contains("Thanks for the order of
Camel in Action");
+
+ template.send("direct:a", createLetter());
+
+ mock.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:a")
+
.to("velocity:org/apache/camel/component/velocity/letter.vm")
+ .to("mock:result");
+ }
+ };
+ }
+----
include::spring-boot:partial$starter.adoc[]