qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject [2/4] qpid-broker-j git commit: QPID-6933: [System Tests] Move ForeignMessageTest into JMS 1.1 system tests
Date Fri, 01 Dec 2017 17:02:41 GMT
QPID-6933: [System Tests] Move ForeignMessageTest into JMS 1.1 system tests


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/a2d083e1
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/a2d083e1
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/a2d083e1

Branch: refs/heads/master
Commit: a2d083e11fe1fc288f569703324bb4323627348f
Parents: c993263
Author: Alex Rudyy <orudyy@apache.org>
Authored: Fri Dec 1 16:17:19 2017 +0000
Committer: Alex Rudyy <orudyy@apache.org>
Committed: Fri Dec 1 17:02:15 2017 +0000

----------------------------------------------------------------------
 .../jms_1_1/message/ForeignMessageTest.java     |  99 ++++++++++++++++
 .../test/unit/message/ForeignMessageTest.java   | 118 -------------------
 2 files changed, 99 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a2d083e1/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/message/ForeignMessageTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/message/ForeignMessageTest.java
b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/message/ForeignMessageTest.java
new file mode 100644
index 0000000..790663a
--- /dev/null
+++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/message/ForeignMessageTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.qpid.systests.jms_1_1.message;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.UUID;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import org.junit.Test;
+
+import org.apache.qpid.systests.JmsTestBase;
+
+public class ForeignMessageTest extends JmsTestBase
+{
+    @Test
+    public void testSendForeignMessage() throws Exception
+    {
+        final Destination replyTo = createQueue(getTestName() + "_replyTo");
+        final Queue queue = createQueue(getTestName());
+        final Connection connection = getConnection();
+        try
+        {
+            final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            final String jmsType = "TestJmsType";
+            final String correlationId = "testCorrelationId";
+            final ObjectMessage message = session.createObjectMessage();
+            final ObjectMessage foreignMessage =
+                    Reflection.newProxy(ObjectMessage.class, new AbstractInvocationHandler()
+                    {
+                        @Override
+                        protected Object handleInvocation(final Object proxy, final Method
method, final Object[] args)
+                                throws Throwable
+                        {
+                            return method.invoke(message, args);
+                        }
+                    });
+
+            foreignMessage.setJMSCorrelationID(correlationId);
+            foreignMessage.setJMSType(jmsType);
+            foreignMessage.setJMSReplyTo(replyTo);
+            Serializable payload = UUID.randomUUID();
+            foreignMessage.setObject(payload);
+
+            final MessageConsumer consumer = session.createConsumer(queue);
+            final MessageProducer producer = session.createProducer(queue);
+            producer.send(foreignMessage);
+
+            connection.start();
+
+            Message receivedMessage = consumer.receive(getReceiveTimeout());
+            assertTrue("ObjectMessage was not received ", receivedMessage instanceof ObjectMessage);
+            assertEquals("JMSCorrelationID mismatch",
+                         foreignMessage.getJMSCorrelationID(),
+                         receivedMessage.getJMSCorrelationID());
+            assertEquals("JMSType mismatch", foreignMessage.getJMSType(), receivedMessage.getJMSType());
+            assertEquals("JMSReply To mismatch", foreignMessage.getJMSReplyTo(), receivedMessage.getJMSReplyTo());
+            assertEquals("JMSMessageID mismatch", foreignMessage.getJMSMessageID(), receivedMessage.getJMSMessageID());
+            assertEquals("JMS Default priority should be default",
+                         Message.DEFAULT_PRIORITY,
+                         receivedMessage.getJMSPriority());
+            assertEquals("Message payload not as expected", payload, ((ObjectMessage) receivedMessage).getObject());
+        }
+        finally
+        {
+            connection.close();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a2d083e1/systests/src/test/java/org/apache/qpid/test/unit/message/ForeignMessageTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/test/unit/message/ForeignMessageTest.java
b/systests/src/test/java/org/apache/qpid/test/unit/message/ForeignMessageTest.java
deleted file mode 100644
index 3d46315..0000000
--- a/systests/src/test/java/org/apache/qpid/test/unit/message/ForeignMessageTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.qpid.test.unit.message;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import com.google.common.reflect.AbstractInvocationHandler;
-import com.google.common.reflect.Reflection;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-
-public class ForeignMessageTest extends QpidBrokerTestCase
-{
-
-    private static final String JMS_CORR_ID = "QPIDID_01";
-    private static final String JMS_TYPE = "test.jms.type";
-    private static final String GROUP = "group";
-    private static final int JMSX_GROUP_SEQ_VALUE = 1;
-
-    /**
-     * Tests that a non-Qpid JMS message (in this case a proxy) can be sent and received.
-     */
-    public void testSendForeignMessage() throws Exception
-    {
-        final Connection con = getConnection();
-        final Session session = con.createSession(true, Session.SESSION_TRANSACTED);
-        Queue queue = createTestQueue(session);
-        Destination replyTo = createTestQueue(session, "my.replyto");
-
-        MessageConsumer consumer = session.createConsumer(queue);
-
-        final MessageProducer producer = session.createProducer(queue);
-
-        // create a 'foreign' JMS message using proxy
-        ObjectMessage sentMsg = getForeignObjectMessage(session.createObjectMessage());
-
-        sentMsg.setJMSCorrelationID(JMS_CORR_ID);
-        sentMsg.setJMSType(JMS_TYPE);
-        sentMsg.setStringProperty("JMSXGroupID", GROUP);
-        sentMsg.setIntProperty("JMSXGroupSeq", JMSX_GROUP_SEQ_VALUE);
-        sentMsg.setJMSReplyTo(replyTo);
-        Serializable payload = UUID.randomUUID();
-        sentMsg.setObject(payload);
-
-        // send it
-        producer.send(sentMsg);
-        String sentMessageId = sentMsg.getJMSMessageID();
-        session.commit();
-
-        con.start();
-
-        // get message and check JMS properties
-        ObjectMessage rm = (ObjectMessage) consumer.receive(getReceiveTimeout());
-        assertNotNull(rm);
-
-        assertEquals("JMS Correlation ID mismatch", sentMsg.getJMSCorrelationID(), rm.getJMSCorrelationID());
-        assertEquals("JMS Type mismatch", sentMsg.getJMSType(), rm.getJMSType());
-        assertEquals("JMS Reply To mismatch", sentMsg.getJMSReplyTo(), rm.getJMSReplyTo());
-        assertEquals("JMSMessageID mismatch:", sentMessageId, rm.getJMSMessageID());
-        assertEquals("JMS Default priority should be 4",Message.DEFAULT_PRIORITY,rm.getJMSPriority());
-
-        //Validate that the JMSX values are correct
-        assertEquals("JMSXGroupID is not as expected:", GROUP, rm.getStringProperty("JMSXGroupID"));
-        assertEquals("JMSXGroupSeq is not as expected:", JMSX_GROUP_SEQ_VALUE, rm.getIntProperty("JMSXGroupSeq"));
-
-        assertEquals("Message payload not as expected", payload, rm.getObject());
-
-        session.commit();
-    }
-
-    private ObjectMessage getForeignObjectMessage(final ObjectMessage message)
-    {
-        return Reflection.newProxy(ObjectMessage.class, new AbstractInvocationHandler()
-        {
-            @Override
-            protected Object handleInvocation(final Object proxy, final Method method, final
Object[] args)
-                    throws Throwable
-            {
-                return method.invoke(message, args);
-            }
-        });
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message