You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2016/10/21 16:57:36 UTC
activemq git commit: NO-JIRA Add new test for session close
Repository: activemq
Updated Branches:
refs/heads/master 4c838c5fa -> bd8f17700
NO-JIRA Add new test for session close
Add a test that checks that closing a session does not provoke the
remote to close the session resources explicitly.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/bd8f1770
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/bd8f1770
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/bd8f1770
Branch: refs/heads/master
Commit: bd8f17700c32652883c0372c85f5296276cd1128
Parents: 4c838c5
Author: Timothy Bish <ta...@gmail.com>
Authored: Fri Oct 21 12:57:10 2016 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Fri Oct 21 12:57:10 2016 -0400
----------------------------------------------------------------------
.../transport/amqp/interop/AmqpSessionTest.java | 46 +++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/bd8f1770/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSessionTest.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSessionTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSessionTest.java
index 32aed69..cf647e0 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSessionTest.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpSessionTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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.
@@ -21,14 +21,22 @@ import static org.junit.Assert.assertNotNull;
import org.apache.activemq.transport.amqp.client.AmqpClient;
import org.apache.activemq.transport.amqp.client.AmqpClientTestSupport;
import org.apache.activemq.transport.amqp.client.AmqpConnection;
+import org.apache.activemq.transport.amqp.client.AmqpReceiver;
import org.apache.activemq.transport.amqp.client.AmqpSession;
+import org.apache.activemq.transport.amqp.client.AmqpValidator;
+import org.apache.qpid.proton.engine.Receiver;
+import org.apache.qpid.proton.engine.Session;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Test for creation and configuration of AMQP sessions.
*/
public class AmqpSessionTest extends AmqpClientTestSupport {
+ protected static final Logger LOG = LoggerFactory.getLogger(AmqpSessionTest.class);
+
@Test
public void testCreateSession() throws Exception {
AmqpClient client = createAmqpClient();
@@ -37,4 +45,40 @@ public class AmqpSessionTest extends AmqpClientTestSupport {
assertNotNull(session);
connection.close();
}
+
+ @Test(timeout = 60000)
+ public void testSessionClosedDoesNotGetReceiverDetachFromRemote() throws Exception {
+ AmqpClient client = createAmqpClient();
+ assertNotNull(client);
+
+ 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) {
+ markAsInvalid("Broker should not close receiver linked to closed session.");
+ }
+ });
+
+ AmqpConnection connection = trackConnection(client.connect());
+ assertNotNull(connection);
+ AmqpSession session = connection.createSession();
+ assertNotNull(session);
+ AmqpReceiver receiver = session.createReceiver("queue://" + getTestName());
+ assertNotNull(receiver);
+
+ session.close();
+
+ connection.getStateInspector().assertValid();
+ connection.close();
+ }
}