mirror of https://github.com/apache/activemq.git
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.
This commit is contained in:
parent
4c838c5fa3
commit
bd8f17700c
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
* this work for additional information regarding copyright ownership.
|
* 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.AmqpClient;
|
||||||
import org.apache.activemq.transport.amqp.client.AmqpClientTestSupport;
|
import org.apache.activemq.transport.amqp.client.AmqpClientTestSupport;
|
||||||
import org.apache.activemq.transport.amqp.client.AmqpConnection;
|
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.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.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for creation and configuration of AMQP sessions.
|
* Test for creation and configuration of AMQP sessions.
|
||||||
*/
|
*/
|
||||||
public class AmqpSessionTest extends AmqpClientTestSupport {
|
public class AmqpSessionTest extends AmqpClientTestSupport {
|
||||||
|
|
||||||
|
protected static final Logger LOG = LoggerFactory.getLogger(AmqpSessionTest.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateSession() throws Exception {
|
public void testCreateSession() throws Exception {
|
||||||
AmqpClient client = createAmqpClient();
|
AmqpClient client = createAmqpClient();
|
||||||
|
@ -37,4 +45,40 @@ public class AmqpSessionTest extends AmqpClientTestSupport {
|
||||||
assertNotNull(session);
|
assertNotNull(session);
|
||||||
connection.close();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue