camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r992224 - /camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToHeaderTest.java
Date Fri, 03 Sep 2010 07:18:53 GMT
Author: davsclaus
Date: Fri Sep  3 07:18:53 2010
New Revision: 992224

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

Added:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToHeaderTest.java
      - copied, changed from r992204, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyFixedReplyToInEndpointTest.java

Copied: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToHeaderTest.java
(from r992204, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyFixedReplyToInEndpointTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToHeaderTest.java?p2=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToHeaderTest.java&p1=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyFixedReplyToInEndpointTest.java&r1=992204&r2=992224&rev=992224&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyFixedReplyToInEndpointTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToHeaderTest.java
Fri Sep  3 07:18:53 2010
@@ -23,6 +23,7 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
@@ -31,52 +32,26 @@ import static org.apache.camel.component
 /**
  * @version $Revision$
  */
-public class JmsRequestReplyFixedReplyToInEndpointTest extends CamelTestSupport {
+public class JmsInOnlyWithReplyToHeaderTest extends CamelTestSupport {
 
     @Test
-    public void testJmsRequestReplyTempReplyTo() throws Exception {
-        Exchange reply = template.request("activemq:queue:foo", new Processor() {
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setBody("World");
-            }
-        });
-        assertEquals("Hello World", reply.getOut().getBody());
-        assertTrue("Should have headers", reply.getOut().hasHeaders());
-        String replyTo = reply.getOut().getHeader("JMSReplyTo", String.class);
-        assertTrue("Should be a temp queue", replyTo.startsWith("temp-queue"));
-    }
+    public void testJmsInOnlyWithReplyToHeader() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+        mock.expectedHeaderReceived("JMSReplyTo", "queue://bar");
 
-    @Test
-    public void testJmsRequestReplyFixedReplyToInEndpoint() throws Exception {
-        Exchange reply = template.request("activemq:queue:foo?replyTo=bar", new Processor()
{
+        template.send("activemq:queue:foo?preserveMessageQos=true", new Processor() {
             public void process(Exchange exchange) throws Exception {
                 exchange.getIn().setBody("World");
+                exchange.getIn().setHeader("JMSReplyTo", "bar");
             }
         });
-        assertEquals("Hello World", reply.getOut().getBody());
-        assertTrue("Should have headers", reply.getOut().hasHeaders());
-        assertEquals("queue://bar", reply.getOut().getHeader("JMSReplyTo", String.class));
-    }
 
-    @Test
-    public void testJmsRequestReplyFixedReplyToInEndpointTwoMessages() throws Exception {
-        Exchange reply = template.request("activemq:queue:foo?replyTo=bar", new Processor()
{
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setBody("World");
-            }
-        });
-        assertEquals("Hello World", reply.getOut().getBody());
-        assertTrue("Should have headers", reply.getOut().hasHeaders());
-        assertEquals("queue://bar", reply.getOut().getHeader("JMSReplyTo", String.class));
+        assertMockEndpointsSatisfied();
 
-        reply = template.request("activemq:queue:foo?replyTo=bar", new Processor() {
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setBody("Moon");
-            }
-        });
-        assertEquals("Hello Moon", reply.getOut().getBody());
-        assertTrue("Should have headers", reply.getOut().hasHeaders());
-        assertEquals("queue://bar", reply.getOut().getHeader("JMSReplyTo", String.class));
+        // reply is in bar queue so lets consume it
+        String reply = consumer.receiveBody("activemq:queue:bar", 5000, String.class);
+        assertEquals("Hello World", reply);
     }
 
     protected CamelContext createCamelContext() throws Exception {
@@ -92,7 +67,8 @@ public class JmsRequestReplyFixedReplyTo
             @Override
             public void configure() throws Exception {
                 from("activemq:queue:foo")
-                    .transform(body().prepend("Hello "));
+                    .transform(body().prepend("Hello "))
+                    .to("mock:result");
             }
         };
     }



Mime
View raw message