This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.18.x by this push:
     new 6dd8745903c CAMEL-18467: [DOCS] Velocity component - missing java code 
sample
6dd8745903c is described below

commit 6dd8745903ccdea902409a6478d180927133564f
Author: Claus Ibsen <claus.ib...@gmail.com>
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[]

Reply via email to