activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1394280 - in /activemq/trunk/activemq-amqp: pom.xml src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
Date Thu, 04 Oct 2012 21:39:38 GMT
Author: chirino
Date: Thu Oct  4 21:39:37 2012
New Revision: 1394280

URL: http://svn.apache.org/viewvc?rev=1394280&view=rev
Log:
Test against the qpid JMS client.

Added:
    activemq/trunk/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
Modified:
    activemq/trunk/activemq-amqp/pom.xml

Modified: activemq/trunk/activemq-amqp/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-amqp/pom.xml?rev=1394280&r1=1394279&r2=1394280&view=diff
==============================================================================
--- activemq/trunk/activemq-amqp/pom.xml (original)
+++ activemq/trunk/activemq-amqp/pom.xml Thu Oct  4 21:39:37 2012
@@ -53,6 +53,13 @@
 
     <!-- Testing Dependencies -->
     <dependency>
+      <groupId>org.apache.qpid</groupId>
+      <artifactId>qpid-amqp-1-0-client-jms</artifactId>
+      <version>0.18</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
       <groupId>org.apache.activemq</groupId>
       <artifactId>activemq-core</artifactId>
       <type>test-jar</type>

Added: activemq/trunk/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java?rev=1394280&view=auto
==============================================================================
--- activemq/trunk/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
(added)
+++ activemq/trunk/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
Thu Oct  4 21:39:37 2012
@@ -0,0 +1,88 @@
+/**
+ * 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.activemq.transport.amqp;
+
+import org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl;
+import org.apache.qpid.amqp_1_0.jms.impl.QueueImpl;
+import org.junit.Test;
+
+import javax.jms.*;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public class JMSClientTest extends AmqpTestSupport {
+
+    @Test
+    public void testSendReceive() throws Exception {
+
+        QueueImpl queue = new QueueImpl("BURL:direct://amq.direct//test");
+        int nMsgs = 100;
+        final String dataFormat = "%01024d";
+
+        final ConnectionFactoryImpl factory = new ConnectionFactoryImpl("localhost", port,
null, null);
+
+        try {
+            final Connection connection = factory.createConnection();
+            connection.setExceptionListener(new ExceptionListener() {
+                @Override
+                public void onException(JMSException exception) {
+                    exception.printStackTrace();
+                }
+            });
+            connection.start();
+            {
+                Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+                MessageProducer p = session.createProducer(queue);
+                for (int i = 0; i < nMsgs; i++) {
+                    System.out.println("Sending " + i);
+                    p.send(session.createTextMessage(String.format(dataFormat, i)));
+                }
+                p.close();
+                session.close();
+            }
+            System.out.println("=======================================================================================");
+            System.out.println(" receiving ");
+            System.out.println("=======================================================================================");
+            {
+                Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+                MessageConsumer c = session.createConsumer(queue);
+
+                // Receive messages non-transacted
+                int i = 0;
+                while ( i < nMsgs) {
+                    TextMessage msg = (TextMessage) c.receive();
+                    if( msg!=null ) {
+                        String s = msg.getText();
+                        assertEquals(String.format(dataFormat, i), s);
+                        System.out.println("Received: " + i);
+                        i++;
+                    }
+                }
+                c.close();
+                session.close();
+            }
+            connection.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+}



Mime
View raw message