From ef295414b2beb42cf9e9086b06454f0e5cb20988 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Wed, 17 Feb 2016 11:34:25 -0500 Subject: [PATCH] NO-JIRA: Add some additional assertions so tests fail more cleanly in the case of a receive not getting a message before it's assigned timeout. (cherry picked from commit 33e27a4f5ac864c3bd7ee124b2e2f2e43e8c5983) --- .../transport/amqp/interop/AmqpSendReceiveTest.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java index 906febf73c..4dd2f0caba 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSendReceiveTest.java @@ -67,6 +67,7 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { AmqpReceiver receiver1 = session.createReceiver("queue://" + getTestName()); receiver1.flow(MSG_COUNT); AmqpMessage received = receiver1.receive(5, TimeUnit.SECONDS); + assertNotNull("Should have got a message", received); assertEquals("msg0", received.getMessageId()); receiver1.close(); @@ -74,6 +75,7 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { receiver2.flow(200); for (int i = 0; i < MSG_COUNT; ++i) { received = receiver2.receive(5, TimeUnit.SECONDS); + assertNotNull("Should have got a message", received); assertEquals("msg" + i, received.getMessageId()); } @@ -103,7 +105,7 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { AmqpReceiver receiver = session.createReceiver("queue://" + getTestName(), "sn = 100"); receiver.flow(2); AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS); - assertNotNull(received); + assertNotNull("Should have read a message", received); assertEquals(100, received.getApplicationProperty("sn")); assertEquals("abcdefg", received.getGroupId()); received.accept(); @@ -139,6 +141,8 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { receiver1.flow(2); AmqpMessage message1 = receiver1.receive(5, TimeUnit.SECONDS); AmqpMessage message2 = receiver1.receive(5, TimeUnit.SECONDS); + assertNotNull("Should have read message 1", message1); + assertNotNull("Should have read message 2", message2); assertEquals("msg0", message1.getMessageId()); assertEquals("msg1", message2.getMessageId()); message1.accept(); @@ -148,6 +152,8 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { receiver2.flow(2); AmqpMessage message3 = receiver2.receive(5, TimeUnit.SECONDS); AmqpMessage message4 = receiver2.receive(5, TimeUnit.SECONDS); + assertNotNull("Should have read message 3", message3); + assertNotNull("Should have read message 4", message4); assertEquals("msg2", message3.getMessageId()); assertEquals("msg3", message4.getMessageId()); message3.accept(); @@ -156,6 +162,7 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { receiver1.flow(MSG_COUNT - 4); for (int i = 4; i < MSG_COUNT - 4; i++) { AmqpMessage message = receiver1.receive(5, TimeUnit.SECONDS); + assertNotNull("Should have read a message", message); assertEquals("msg" + i, message.getMessageId()); message.accept(); } @@ -185,6 +192,7 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { assertEquals(1, queue.getQueueSize()); receiver1.flow(1); message1 = receiver1.receive(50, TimeUnit.SECONDS); + assertNotNull("Should have read a message", message1); assertFalse("First message sent should not be durable", message1.isDurable()); message1.accept(); @@ -198,6 +206,7 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { assertEquals(1, queue.getQueueSize()); receiver1.flow(1); message2 = receiver1.receive(50, TimeUnit.SECONDS); + assertNotNull("Should have read a message", message2); assertTrue("Second message sent should be durable", message2.isDurable()); message2.accept();