camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r675923 - /activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithAnnotationAndExchangeTest.java
Date Fri, 11 Jul 2008 11:44:09 GMT
Author: davsclaus
Date: Fri Jul 11 04:44:08 2008
New Revision: 675923

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

Added:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithAnnotationAndExchangeTest.java
      - copied, changed from r675884, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithHeaderTest.java

Copied: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithAnnotationAndExchangeTest.java
(from r675884, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithHeaderTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithAnnotationAndExchangeTest.java?p2=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithAnnotationAndExchangeTest.java&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithHeaderTest.java&r1=675884&r2=675923&rev=675923&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithHeaderTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithAnnotationAndExchangeTest.java
Fri Jul 11 04:44:08 2008
@@ -18,20 +18,22 @@
 
 import javax.naming.Context;
 
+import org.apache.camel.Body;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
+import org.apache.camel.Header;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.util.jndi.JndiContext;
 
 /**
- * Unit test to demonstrate the headers can pass through beans.
+ * Unit test to demonstrate annotations combined with Exchange parameter.
  */
-public class BeanWithHeaderTest extends ContextTestSupport {
+public class BeanWithAnnotationAndExchangeTest extends ContextTestSupport {
 
-    public void testBeanWithHeader() throws Exception {
+    public void testBeanWithAnnotationAndExchangeTest() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedBodiesReceived("StartMyBeanMyBean");
+        mock.expectedBodiesReceived("StartMyBean");
         mock.expectedHeaderReceived("foo", "bar");
         mock.expectedHeaderReceived("user", "admin");
 
@@ -50,11 +52,7 @@
         return new RouteBuilder() {
             public void configure() throws Exception {
                 from("direct:in")
-                    .setHeader("foo", "bar")
-                    .to("bean:myBean")
-                    .to("seda:a");
-
-                from("seda:a")
+                    .setHeader("user", "admin")
                     .to("bean:myBean")
                     .to("mock:result");
             }
@@ -62,11 +60,14 @@
     }
 
     public static class MyBean {
-        public void doSomething(Exchange exchange) {
-            String body = exchange.getIn().getBody(String.class);
-            exchange.getIn().setHeader("user", "admin");
+
+        // START SNIPPET: e1
+        public void doSomething(@Header(name = "user") String user, @Body String body, Exchange
exchange) {
+            assertEquals("admin", user);
+
             exchange.getIn().setBody(body + "MyBean");
         }
+        // END SNIPPET: e1
     }
 
-}
+}
\ No newline at end of file



Mime
View raw message