camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r949128 - in /camel/trunk/components/camel-jms/src: main/java/org/apache/camel/component/jms/ test/java/org/apache/camel/component/jms/issues/
Date Fri, 28 May 2010 07:53:02 GMT
Author: davsclaus
Date: Fri May 28 07:53:02 2010
New Revision: 949128

URL: http://svn.apache.org/viewvc?rev=949128&view=rev
Log:
CAMEL-2715: Added unit test for routing slip with JMS.

Added:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsRoutingSlipIssueTest.java
  (with props)
Modified:
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsTemporaryTopicEndpoint.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/TempReplyToIssueTest.java

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsTemporaryTopicEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsTemporaryTopicEndpoint.java?rev=949128&r1=949127&r2=949128&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsTemporaryTopicEndpoint.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsTemporaryTopicEndpoint.java
Fri May 28 07:53:02 2010
@@ -21,14 +21,14 @@ import javax.jms.JMSException;
 import javax.jms.Session;
 import javax.jms.TemporaryTopic;
 
-
 /**
  * A <a href="http://activemq.apache.org/jms.html">JMS Endpoint</a>
  * for working with a {@link TemporaryTopic}
+ * <p/>
+ * <b>Important:</b> Need to be really careful to always use the same Connection
otherwise the destination goes stale
  *
  * @version $Revision$
  */
-// TODO need to be really careful to always use the same Connection otherwise the destination
goes stale
 public class JmsTemporaryTopicEndpoint extends JmsEndpoint implements DestinationEndpoint
{
     private Destination jmsDestination;
 
@@ -57,8 +57,8 @@ public class JmsTemporaryTopicEndpoint e
     }
     
     @Override
-    // We don't want to manage this temporary object
     public Object getManagedObject(JmsEndpoint object) {
+        // We don't want to manage this temporary object
         return null;
     }
 

Added: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsRoutingSlipIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsRoutingSlipIssueTest.java?rev=949128&view=auto
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsRoutingSlipIssueTest.java
(added)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsRoutingSlipIssueTest.java
Fri May 28 07:53:02 2010
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jms.issues;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
+
+/**
+ * @version $Revision$
+ */
+public class JmsRoutingSlipIssueTest extends CamelTestSupport {
+
+    @Test
+    public void testJmsRoutingSlip() throws Exception {
+        getMockEndpoint("mock:a").expectedBodiesReceived("Hello");
+        getMockEndpoint("mock:b").expectedBodiesReceived("HelloA");
+        getMockEndpoint("mock:c").expectedBodiesReceived("HelloAB");
+        getMockEndpoint("mock:result").expectedBodiesReceived("HelloABC");
+
+        String slip = "activemq:queue:a,activemq:queue:b,activemq:queue:c";
+        template.sendBodyAndHeader("direct:start", "Hello", "mySlip", slip);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+        camelContext.addComponent("activemq", jmsComponentClientAcknowledge(connectionFactory));
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    // need to use InOut as we do request/reply over JMS
+                    .setExchangePattern(ExchangePattern.InOut)
+                    .routingSlip("mySlip")
+                    .to("mock:result");
+
+                from("activemq:queue:a")
+                    .to("mock:a")
+                    .transform(body().append("A"));
+
+                from("activemq:queue:b")
+                    .to("mock:b")
+                    .transform(body().append("B"));
+
+                from("activemq:queue:c")
+                    .to("mock:c")
+                    .transform(body().append("C"));
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsRoutingSlipIssueTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsRoutingSlipIssueTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/TempReplyToIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/TempReplyToIssueTest.java?rev=949128&r1=949127&r2=949128&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/TempReplyToIssueTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/TempReplyToIssueTest.java
Fri May 28 07:53:02 2010
@@ -45,7 +45,8 @@ public class TempReplyToIssueTest extend
         assertEquals("Hello Moon", out);
     }
 
-    public String handleMessage(final @Header("JMSReplyTo") Destination jmsReplyTo, final
@Header("JMSCorrelationID") String id,
+    public String handleMessage(@Header("JMSReplyTo") final Destination jmsReplyTo,
+                                @Header("JMSCorrelationID") final String id,
                                 @Body String body, Exchange exchange) throws Exception {
         assertNotNull(jmsReplyTo);
         assertTrue("Should be a temp queue", jmsReplyTo.toString().startsWith("temp-queue"));



Mime
View raw message