Repository: activemq-artemis Updated Branches: refs/heads/master 6956d1412 -> d58be06c3
Add test case for ARTEMIS-231 The test doesn't actually fail, but the test output shows the problem. Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/2d679e90 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/2d679e90 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/2d679e90 Branch: refs/heads/master Commit: 2d679e90713b946d6c62832f46bdcd0ff0b0768f Parents: 6956d14 Author: Julian Scheid <[email protected]> Authored: Thu Sep 24 22:05:33 2015 +0200 Committer: Clebert Suconic <[email protected]> Committed: Thu Sep 24 21:30:31 2015 -0400 ---------------------------------------------------------------------- .../stomp/StompConnectionCleanupTest.java | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2d679e90/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompConnectionCleanupTest.java ---------------------------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompConnectionCleanupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompConnectionCleanupTest.java index b6b44f2..98259e8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompConnectionCleanupTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompConnectionCleanupTest.java @@ -28,6 +28,49 @@ public class StompConnectionCleanupTest extends StompTestBase { private static final long CONNECTION_TTL = 2000; + // ARTEMIS-231 + @Test + public void testConnectionCleanupWithTopicSubscription() throws Exception { + String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL; + sendFrame(frame); + frame = receiveFrame(10000); + + //We send and consumer a message to ensure a STOMP connection and server session is created + + System.out.println("Received frame: " + frame); + + assertTrue(frame.startsWith("CONNECTED")); + + frame = "SUBSCRIBE\n" + "destination:" + getTopicPrefix() + getTopicName() + "\n" + "ack:auto\n\n" + Stomp.NULL; + sendFrame(frame); + + frame = "DISCONNECT\n\n" + Stomp.NULL; + sendFrame(frame); + + // Now we wait until the connection is cleared on the server, which will happen some time after ttl, since no data + // is being sent + + long start = System.currentTimeMillis(); + + while (true) { + int connCount = server.getActiveMQServer().getRemotingService().getConnections().size(); + + int sessionCount = server.getActiveMQServer().getSessions().size(); + + // All connections and sessions should be timed out including STOMP + JMS connection + + if (connCount == 0 && sessionCount == 0) { + break; + } + + Thread.sleep(10); + + if (System.currentTimeMillis() - start > 10000) { + fail("Timed out waiting for connection to be cleared up"); + } + } + } + @Test public void testConnectionCleanup() throws Exception { String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
