camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1003752 - in /camel/trunk/components/camel-jms/src: main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java test/java/org/apache/camel/component/jms/JmsSimpleRequestReply2Test.java
Date Sat, 02 Oct 2010 08:00:31 GMT
Author: davsclaus
Date: Sat Oct  2 08:00:31 2010
New Revision: 1003752

URL: http://svn.apache.org/viewvc?rev=1003752&view=rev
Log:
Added unit test.

Added:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReply2Test.java
      - copied, changed from r1003532, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReplyTest.java
Modified:
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java?rev=1003752&r1=1003751&r2=1003752&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java
Sat Oct  2 08:00:31 2010
@@ -163,8 +163,7 @@ public class PersistentQueueReplyManager
 
         String replyToSelectorName = endpoint.getReplyToDestinationSelectorName();
         if (replyToSelectorName != null) {
-            // 24 max char is what IBM WebSphereMQ supports in CorrelationIDs
-            // use a fixed selector name so we can select the replies which is intended for
us
+            // create a random selector value we will use for the persistent reply queue
             replyToSelectorValue = "ID:" + new BigInteger(24 * 8, new Random()).toString(16);
             String fixedMessageSelector = replyToSelectorName + "='" + replyToSelectorValue
+ "'";
             answer = new PersistentQueueMessageListenerContainer(fixedMessageSelector);

Copied: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReply2Test.java
(from r1003532, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReplyTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReply2Test.java?p2=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReply2Test.java&p1=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReplyTest.java&r1=1003532&r2=1003752&rev=1003752&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReplyTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSimpleRequestReply2Test.java
Sat Oct  2 08:00:31 2010
@@ -20,51 +20,38 @@ import javax.jms.ConnectionFactory;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-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;
+
 import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
 
 /**
  * A simple request / reply test
  */
-public class JmsSimpleRequestReplyTest extends CamelTestSupport {
+public class JmsSimpleRequestReply2Test extends CamelTestSupport {
 
     protected String componentName = "activemq";
 
     @Test
-    public void testRequetReply() throws Exception {
-        MockEndpoint result = getMockEndpoint("mock:result");
-        result.expectedMessageCount(1);
-
-        Exchange out = template.send("activemq:queue:hello", ExchangePattern.InOut, new Processor()
{
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setBody("Hello World");
-                exchange.getIn().setHeader("foo", 123);
-            }
-        });
+    public void testWithInOnly() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
 
-        result.assertIsSatisfied();
+        // send an InOnly
+        template.sendBody("direct:start", "World");
 
-        assertNotNull(out);
-
-        assertEquals("Bye World", out.getOut().getBody(String.class));
-        assertEquals(123, out.getOut().getHeader("foo"));
+        assertMockEndpointsSatisfied();
     }
 
     @Test
-    public void testRequetReply2Messages() throws Exception {
-        MockEndpoint result = getMockEndpoint("mock:result");
-        result.expectedMessageCount(2);
+    public void testWithInOut() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
 
-        template.requestBody("activemq:queue:hello", "Hello World");
-        template.requestBody("activemq:queue:hello", "Gooday World");
+        // send an InOnly
+        String out = template.requestBody("direct:start", "World", String.class);
+        assertEquals("Hello World", out);
 
-        result.assertIsSatisfied();
+        assertMockEndpointsSatisfied();
     }
 
     protected CamelContext createCamelContext() throws Exception {
@@ -79,12 +66,12 @@ public class JmsSimpleRequestReplyTest e
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("activemq:queue:hello").process(new Processor() {
-                    public void process(Exchange exchange) throws Exception {
-                        exchange.getIn().setBody("Bye World");
-                        assertNotNull(exchange.getIn().getHeader("JMSReplyTo"));
-                    }
-                }).to("mock:result");
+                from("direct:start")
+                    .inOut("activemq:queue:foo")
+                    .to("mock:result");
+
+                from("activemq:queue:foo")
+                    .transform(body().prepend("Hello "));
             }
         };
     }



Mime
View raw message