camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r791824 - in /camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues: JmsAnotherCustomJMSReplyToTest.java JmsJMSReplyToEndpointUsingInOutTest.java
Date Tue, 07 Jul 2009 13:15:56 GMT
Author: davsclaus
Date: Tue Jul  7 13:15:56 2009
New Revision: 791824

URL: http://svn.apache.org/viewvc?rev=791824&view=rev
Log:
CAMEL-1807: added some unit tests

Added:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsJMSReplyToEndpointUsingInOutTest.java
  (with props)
Modified:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsAnotherCustomJMSReplyToTest.java

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsAnotherCustomJMSReplyToTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsAnotherCustomJMSReplyToTest.java?rev=791824&r1=791823&r2=791824&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsAnotherCustomJMSReplyToTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsAnotherCustomJMSReplyToTest.java
Tue Jul  7 13:15:56 2009
@@ -37,7 +37,7 @@
     private ActiveMQComponent amq;
     private static String MQURI = "vm://localhost?broker.persistent=false&broker.useJmx=false";
 
-    public void testCustomJMSReplyToInOut() throws Exception {
+    public void testCustomJMSReplyToInOnly() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("My name is Arnio");
 

Added: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsJMSReplyToEndpointUsingInOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsJMSReplyToEndpointUsingInOutTest.java?rev=791824&view=auto
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsJMSReplyToEndpointUsingInOutTest.java
(added)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsJMSReplyToEndpointUsingInOutTest.java
Tue Jul  7 13:15:56 2009
@@ -0,0 +1,122 @@
+/**
+ * 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 java.util.concurrent.Executors;
+import java.util.concurrent.Callable;
+import javax.jms.TextMessage;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.JMSException;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Processor;
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.activemq.camel.component.ActiveMQComponent;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.jms.core.MessageCreator;
+import static org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent;
+
+/**
+ * Unit test using a fixed replyTo specified on the JMS endpoint
+ * 
+ * @version $Revision$
+ */
+public class JmsJMSReplyToEndpointUsingInOutTest extends ContextTestSupport {
+
+    private ActiveMQComponent amq;
+    private static String MQURI = "vm://localhost?broker.persistent=false&broker.useJmx=false";
+
+    public void testCustomJMSReplyToInOut() throws Exception {
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("My name is Arnio");
+
+        // do not use Camel to send and receive to simulate a non Camel client
+
+        // use another thread to listen and send the reply
+        Executors.newFixedThreadPool(1).submit(new Callable<Object>() {
+            public Object call() throws Exception {
+                JmsTemplate jms = new JmsTemplate(amq.getConfiguration().getConnectionFactory());
+
+                final TextMessage msg = (TextMessage) jms.receive("nameRequestor");
+                assertEquals("What's your name", msg.getText());
+
+                // there should be a JMSReplyTo so we know where to send the reply
+                final Destination replyTo = msg.getJMSReplyTo();
+
+                // send reply
+                jms.send(replyTo, new MessageCreator() {
+                    public Message createMessage(Session session) throws JMSException {
+                        TextMessage replyMsg = session.createTextMessage();
+                        replyMsg.setText("My name is Arnio");
+                        replyMsg.setJMSCorrelationID(msg.getJMSCorrelationID());
+                        return replyMsg;
+                    }
+                });
+
+                return null;
+            }
+        });
+
+
+        // now get started and send the first message that gets the ball rolling
+        JmsTemplate jms = new JmsTemplate(amq.getConfiguration().getConnectionFactory());
+
+        jms.send("hello", new MessageCreator() {
+            public Message createMessage(Session session) throws JMSException {
+                TextMessage msg = session.createTextMessage();
+                msg.setText("Hello, I'm here");
+                return msg;
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+    }
+
+    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.getOut().setBody("What's your name");
+                        }
+                    })
+                    // use in out to get a reply as well
+                    .to(ExchangePattern.InOut, "activemq:queue:nameRequestor?replyTo=queue:namedReplyQueue")
+                    // and send the reply to our mock for validation
+                    .to("mock:result");
+            }
+        };
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        amq = activeMQComponent(MQURI);
+        camelContext.addComponent("activemq", amq);
+        return camelContext;
+    }
+
+
+}
\ No newline at end of file

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

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



Mime
View raw message