qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject svn commit: r1546609 - in /qpid/jms/trunk/src/test/java/org/apache/qpid/jms: MessageProducerIntegrationTest.java SenderIntegrationTest.java
Date Fri, 29 Nov 2013 16:59:11 GMT
Author: robbie
Date: Fri Nov 29 16:59:10 2013
New Revision: 1546609

URL: http://svn.apache.org/r1546609
Log:
QPIDJMS-9: consolidate sender test classes

Removed:
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/MessageProducerIntegrationTest.java
Modified:
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SenderIntegrationTest.java

Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SenderIntegrationTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SenderIntegrationTest.java?rev=1546609&r1=1546608&r2=1546609&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SenderIntegrationTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SenderIntegrationTest.java Fri Nov 29
16:59:10 2013
@@ -20,11 +20,13 @@ package org.apache.qpid.jms;
 
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.junit.Assert.assertEquals;
 
 import java.util.Calendar;
 import java.util.Date;
 
 import javax.jms.Connection;
+import javax.jms.DeliveryMode;
 import javax.jms.Message;
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
@@ -42,6 +44,64 @@ public class SenderIntegrationTest exten
     private final IntegrationTestFixture _testFixture = new IntegrationTestFixture();
 
     @Test
+    public void testDefaultDeliveryModeProducesDurableMessages() throws Exception
+    {
+        try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
+        {
+            Connection connection = _testFixture.establishConnecton(testPeer);
+            testPeer.expectBegin();
+            testPeer.expectSenderAttach();
+
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            Queue queue = session.createQueue("myQueue");
+            MessageProducer producer = session.createProducer(queue);
+
+            //Create and transfer a new message
+            TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
+            MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
+            messageMatcher.setHeadersMatcher(headersMatcher);
+            testPeer.expectTransfer(messageMatcher);
+
+            Message message = session.createTextMessage();
+            assertEquals(DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
+
+            producer.send(message);
+            assertEquals(DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
+        }
+    }
+
+    @Test
+    public void testProducerOverridesMessageDeliveryMode() throws Exception
+    {
+        try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
+        {
+            Connection connection = _testFixture.establishConnecton(testPeer);
+            testPeer.expectBegin();
+            testPeer.expectSenderAttach();
+
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            Queue queue = session.createQueue("myQueue");
+            MessageProducer producer = session.createProducer(queue);
+
+            //Create and transfer a new message, explicitly setting the deliveryMode on the
+            //message (which applications shouldn't) to NON_PERSISTENT and sending it to
check
+            //that the producer ignores this value and sends the message as PERSISTENT(/durable)
+            TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
+            MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
+            messageMatcher.setHeadersMatcher(headersMatcher);
+            testPeer.expectTransfer(messageMatcher);
+
+            Message message = session.createTextMessage();
+            message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+            assertEquals(DeliveryMode.NON_PERSISTENT, message.getJMSDeliveryMode());
+
+            producer.send(message);
+
+            assertEquals(DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
+        }
+    }
+
+    @Test
     public void testSendingMessageSetsJMSDestination() throws Exception
     {
         try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)



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


Mime
View raw message