activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: NO-JIRA Add new test to receiver tests
Date Fri, 21 Oct 2016 23:40:53 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.14.x 8f301ed57 -> b0ee133ea


NO-JIRA Add new test to receiver tests

test showing that remote close and not detach is triggered on close of
the receiver.
(cherry picked from commit 1a811b72ddfae5874016de71300e73d8a286a8c6)


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/b0ee133e
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/b0ee133e
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/b0ee133e

Branch: refs/heads/activemq-5.14.x
Commit: b0ee133eafec4d9ddb74485661e41b6f4efb0e35
Parents: 8f301ed
Author: Timothy Bish <tabish121@gmail.com>
Authored: Fri Oct 21 19:40:05 2016 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Fri Oct 21 19:40:50 2016 -0400

----------------------------------------------------------------------
 .../amqp/interop/AmqpReceiverTest.java          | 43 ++++++++++++++++++++
 1 file changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/b0ee133e/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpReceiverTest.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpReceiverTest.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpReceiverTest.java
index 3cda78d..08df785 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpReceiverTest.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpReceiverTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.broker.jmx.QueueViewMBean;
 import org.apache.activemq.junit.ActiveMQTestRunner;
@@ -46,6 +47,7 @@ import org.apache.qpid.proton.amqp.messaging.Source;
 import org.apache.qpid.proton.amqp.messaging.TerminusDurability;
 import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy;
 import org.apache.qpid.proton.engine.Receiver;
+import org.apache.qpid.proton.engine.Session;
 import org.apache.qpid.proton.message.Message;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -62,6 +64,47 @@ public class AmqpReceiverTest extends AmqpClientTestSupport {
     }
 
     @Test(timeout = 60000)
+    public void testReceiverCloseSendsRemoteClose() throws Exception {
+        AmqpClient client = createAmqpClient();
+        assertNotNull(client);
+
+        final AtomicBoolean closed = new AtomicBoolean();
+
+        client.setValidator(new AmqpValidator() {
+
+            @Override
+            public void inspectClosedResource(Session session) {
+                LOG.info("Session closed: {}", session.getContext());
+            }
+
+            @Override
+            public void inspectDetachedResource(Receiver receiver) {
+                markAsInvalid("Broker should not detach receiver linked to closed session.");
+            }
+
+            @Override
+            public void inspectClosedResource(Receiver receiver) {
+                LOG.info("Receiver closed: {}", receiver.getContext());
+                closed.set(true);
+            }
+        });
+
+        AmqpConnection connection = trackConnection(client.connect());
+        assertNotNull(connection);
+        AmqpSession session = connection.createSession();
+        assertNotNull(session);
+        AmqpReceiver receiver = session.createReceiver("queue://" + getTestName());
+        assertNotNull(receiver);
+
+        receiver.close();
+
+        assertTrue("Did not process remote close as expected", closed.get());
+        connection.getStateInspector().assertValid();
+
+        connection.close();
+    }
+
+    @Test(timeout = 60000)
     public void testCreateQueueReceiver() throws Exception {
         AmqpClient client = createAmqpClient();
         AmqpConnection connection = trackConnection(client.connect());


Mime
View raw message