camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r761591 - in /camel/trunk/components/camel-velocity/src/test: java/org/apache/camel/component/velocity/VelocitySomeValuesNotInExchangeTest.java resources/org/apache/camel/component/velocity/someValuesNotInExchange.vm
Date Fri, 03 Apr 2009 09:56:10 GMT
Author: davsclaus
Date: Fri Apr  3 09:56:10 2009
New Revision: 761591

URL: http://svn.apache.org/viewvc?rev=761591&view=rev
Log:
Added veloicty test based on user on user forum.

Added:
    camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySomeValuesNotInExchangeTest.java
      - copied, changed from r761528, camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityLetterTest.java
    camel/trunk/components/camel-velocity/src/test/resources/org/apache/camel/component/velocity/someValuesNotInExchange.vm
      - copied, changed from r761528, camel/trunk/components/camel-velocity/src/test/resources/org/apache/camel/component/velocity/example.vm

Copied: camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySomeValuesNotInExchangeTest.java
(from r761528, camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityLetterTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySomeValuesNotInExchangeTest.java?p2=camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySomeValuesNotInExchangeTest.java&p1=camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityLetterTest.java&r1=761528&r2=761591&rev=761591&view=diff
==============================================================================
--- camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityLetterTest.java
(original)
+++ camel/trunk/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySomeValuesNotInExchangeTest.java
Fri Apr  3 09:56:10 2009
@@ -16,44 +16,50 @@
  */
 package org.apache.camel.component.velocity;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
- * Unit test for wiki documentation
+ * Unit test with some variables missing.
  */
-public class VelocityLetterTest extends ContextTestSupport {
+public class VelocitySomeValuesNotInExchangeTest extends ContextTestSupport {
+
+    public void testWithAllValues() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hello Claus\n"
+                + "You have id: 123 if an id was assigned to you.");
+
+        Map headers = new HashMap();
+        headers.put("name", "Claus");
+        headers.put("id", 123);
+        template.sendBodyAndHeaders("direct:a", "", headers);
 
-    // START SNIPPET: e1
-    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;
+        assertMockEndpointsSatisfied();
     }
 
-    public void testVelocityLetter() throws Exception {
+    public void testWithSomeValues() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
-        mock.expectedBodiesReceived("Dear Ibsen, Claus\n\nThanks for the order of Camel in
Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on me, James");
+        mock.expectedBodiesReceived("Hello Claus\n"
+                + "You have id:  if an id was assigned to you.");
 
-        template.send("direct:a", createLetter());
+        Map headers = new HashMap();
+        headers.put("name", "Claus");
+        template.sendBodyAndHeaders("direct:a", "", headers);
 
-        mock.assertIsSatisfied();
+        assertMockEndpointsSatisfied();
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("direct:a").to("velocity:org/apache/camel/component/velocity/letter.vm").to("mock:result");
+                from("direct:a").to("velocity:org/apache/camel/component/velocity/someValuesNotInExchange.vm").to("mock:result");
             }
         };
     }
-    // END SNIPPET: e1
-}
+}
\ No newline at end of file

Copied: camel/trunk/components/camel-velocity/src/test/resources/org/apache/camel/component/velocity/someValuesNotInExchange.vm
(from r761528, camel/trunk/components/camel-velocity/src/test/resources/org/apache/camel/component/velocity/example.vm)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-velocity/src/test/resources/org/apache/camel/component/velocity/someValuesNotInExchange.vm?p2=camel/trunk/components/camel-velocity/src/test/resources/org/apache/camel/component/velocity/someValuesNotInExchange.vm&p1=camel/trunk/components/camel-velocity/src/test/resources/org/apache/camel/component/velocity/example.vm&r1=761528&r2=761591&rev=761591&view=diff
==============================================================================
--- camel/trunk/components/camel-velocity/src/test/resources/org/apache/camel/component/velocity/example.vm
(original)
+++ camel/trunk/components/camel-velocity/src/test/resources/org/apache/camel/component/velocity/someValuesNotInExchange.vm
Fri Apr  3 09:56:10 2009
@@ -14,4 +14,5 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ------------------------------------------------------------------------
-<hello>${headers.cheese}</hello>
\ No newline at end of file
+Hello ${headers.name}
+You have id: $!{headers.id} if an id was assigned to you.
\ No newline at end of file



Mime
View raw message