activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1378100 - in /activemq/trunk/activemq-camel: pom.xml src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteForceTest.java src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java
Date Tue, 28 Aug 2012 12:19:08 GMT
Author: davsclaus
Date: Tue Aug 28 12:19:07 2012
New Revision: 1378100

URL: http://svn.apache.org/viewvc?rev=1378100&view=rev
Log:
AMQ-3967: Fixed unit test after upgrading Camel

Added:
    activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteForceTest.java
      - copied, changed from r1378004, activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java
Modified:
    activemq/trunk/activemq-camel/pom.xml
    activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java

Modified: activemq/trunk/activemq-camel/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-camel/pom.xml?rev=1378100&r1=1378099&r2=1378100&view=diff
==============================================================================
--- activemq/trunk/activemq-camel/pom.xml (original)
+++ activemq/trunk/activemq-camel/pom.xml Tue Aug 28 12:19:07 2012
@@ -213,8 +213,6 @@
           </systemProperties>
           <excludes>
               <exclude>**/JmsJdbcXALoadTest.java</exclude><!-- used only for
manual xa performance testing -->
-              <!-- This currently fails with Camel 2.10-->
-              <exclude>**/ActiveMQJmsHeaderRouteTest.*</exclude>
           </excludes>
         </configuration>
       </plugin>

Copied: activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteForceTest.java
(from r1378004, activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java)
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteForceTest.java?p2=activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteForceTest.java&p1=activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java&r1=1378004&r2=1378100&rev=1378100&view=diff
==============================================================================
--- activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java
(original)
+++ activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteForceTest.java
Tue Aug 28 12:19:07 2012
@@ -16,91 +16,33 @@
  */
 package org.apache.activemq.camel.component;
 
-import java.util.Date;
-import java.util.List;
-
-import javax.jms.Destination;
-import org.apache.activemq.command.ActiveMQQueue;
-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.AssertionClause;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import static org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent;
+import org.apache.camel.component.jms.JmsMessage;
 
 /**
  * 
  */
-public class ActiveMQJmsHeaderRouteTest extends CamelTestSupport {
-    private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQJmsHeaderRouteTest.class);
-
-    protected Object expectedBody = "<time>" + new Date() + "</time>";
-    protected ActiveMQQueue replyQueue = new ActiveMQQueue("test.reply.queue");
-    protected String correlationID = "ABC-123";
-    protected String messageType = getClass().getName();
-
-    @Test
-    public void testForwardingAMessageAcrossJMSKeepingCustomJMSHeaders() throws Exception
{
-        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
-
-        resultEndpoint.expectedBodiesReceived(expectedBody);
-        AssertionClause firstMessageExpectations = resultEndpoint.message(0);
-        firstMessageExpectations.header("cheese").isEqualTo(123);
-        firstMessageExpectations.header("JMSReplyTo").isEqualTo(replyQueue);
-        firstMessageExpectations.header("JMSCorrelationID").isEqualTo(correlationID);
-        firstMessageExpectations.header("JMSType").isEqualTo(messageType);
-
-        template.sendBodyAndHeader("activemq:test.a", expectedBody, "cheese", 123);
-
-        resultEndpoint.setResultWaitTime(10000);
-        //resultEndpoint.assertIsSatisfied();
-
-        List<Exchange> list = resultEndpoint.getReceivedExchanges();
-        System.err.println("The lisr  = " + list);
-        Exchange exchange = list.get(0);
-        Object replyTo = exchange.getIn().getHeader("JMSReplyTo");
-        LOG.info("Reply to is: " + replyTo);
-        Destination destination = assertIsInstanceOf(Destination.class, replyTo);
-        assertEquals("ReplyTo", replyQueue.toString(), destination.toString());
-    }
-
-    protected CamelContext createCamelContext() throws Exception {
-        CamelContext camelContext = super.createCamelContext();
-        camelContext.setTracing(true);
-
-        // START SNIPPET: example
-        camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false"));
-        // END SNIPPET: example
-
-        return camelContext;
-    }
+public class ActiveMQJmsHeaderRouteForceTest extends ActiveMQJmsHeaderRouteTest {
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                /***
-                from("activemq:test.a").process(new Processor() {
+                // do not map jms message as we want to tamper with the JMS message directly,
and not use the Camel API for that
+                from("activemq:test.a?mapJmsMessage=false").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         // lets set the custom JMS headers using the JMS API
-						JmsMessage jmsMessage = assertIsInstanceOf(JmsMessage.class, exchange.getIn());
-						
+                        JmsMessage jmsMessage = assertIsInstanceOf(JmsMessage.class, exchange.getIn());
+
                         jmsMessage.getJmsMessage().setJMSReplyTo(replyQueue);
                         jmsMessage.getJmsMessage().setJMSCorrelationID(correlationID);
-                        jmsMessage.getJmsMessage().setJMSType(messageType);
-                    }
-                }).to("activemq:test.b?preserveMessageQos=true");
+                        jmsMessage.getJmsMessage().setJMSType(messageType);             
      }
+                // force sending the incoming JMS Message, as we want to tamper with the
JMS API directly
+                // instead of using the Camel API for setting JMS headers.
+                }).to("activemq:test.b?preserveMessageQos=true&forceSendOriginalMessage=true");
 
                 from("activemq:test.b").to("mock:result");
-
-                 */
-                from("activemq:test.b").to("mock:result");
-                from("activemq:test.a").to("activemq:test.b?preserveMessageQos=true");
-
-
             }
         };
     }

Modified: activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java?rev=1378100&r1=1378099&r2=1378100&view=diff
==============================================================================
--- activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java
(original)
+++ activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java
Tue Aug 28 12:19:07 2012
@@ -18,11 +18,12 @@ package org.apache.activemq.camel.compon
 
 import java.util.Date;
 import java.util.List;
-
 import javax.jms.Destination;
+
 import org.apache.activemq.command.ActiveMQQueue;
 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.AssertionClause;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -30,6 +31,7 @@ import org.apache.camel.test.junit4.Came
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import static org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent;
 
 /**
@@ -56,11 +58,9 @@ public class ActiveMQJmsHeaderRouteTest 
 
         template.sendBodyAndHeader("activemq:test.a", expectedBody, "cheese", 123);
 
-        resultEndpoint.setResultWaitTime(10000);
-        //resultEndpoint.assertIsSatisfied();
+        resultEndpoint.assertIsSatisfied();
 
         List<Exchange> list = resultEndpoint.getReceivedExchanges();
-        System.err.println("The lisr  = " + list);
         Exchange exchange = list.get(0);
         Object replyTo = exchange.getIn().getHeader("JMSReplyTo");
         LOG.info("Reply to is: " + replyTo);
@@ -82,25 +82,17 @@ public class ActiveMQJmsHeaderRouteTest 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                /***
                 from("activemq:test.a").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
-                        // lets set the custom JMS headers using the JMS API
-						JmsMessage jmsMessage = assertIsInstanceOf(JmsMessage.class, exchange.getIn());
-						
-                        jmsMessage.getJmsMessage().setJMSReplyTo(replyQueue);
-                        jmsMessage.getJmsMessage().setJMSCorrelationID(correlationID);
-                        jmsMessage.getJmsMessage().setJMSType(messageType);
+                        // lets set the custom JMS headers using the Camel API
+                        exchange.getIn().setHeader("JMSReplyTo", replyQueue);
+                        exchange.getIn().setHeader("JMSCorrelationID", correlationID);
+                        exchange.getIn().setHeader("JMSType", messageType);
                     }
                 }).to("activemq:test.b?preserveMessageQos=true");
 
                 from("activemq:test.b").to("mock:result");
 
-                 */
-                from("activemq:test.b").to("mock:result");
-                from("activemq:test.a").to("activemq:test.b?preserveMessageQos=true");
-
-
             }
         };
     }



Mime
View raw message