diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java index ac9934ef15..2ad2b9d9c3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java @@ -1279,6 +1279,58 @@ public class StompTest extends StompTestBase { sendFrame(frame); } + @Test + public void testTopicExistsAfterNoUnsubscribeDisconnect() throws Exception { + + String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL; + sendFrame(frame); + + frame = receiveFrame(100000); + Assert.assertTrue(frame.startsWith("CONNECTED")); + + frame = "SUBSCRIBE\n" + "destination:" + + getTopicPrefix() + + getTopicName() + + "\n" + + "receipt: 12\n" + + "\n\n" + + Stomp.NULL; + sendFrame(frame); + // wait for SUBSCRIBE's receipt + frame = receiveFrame(10000); + Assert.assertTrue(frame.startsWith("RECEIPT")); + + // disconnect, _without unsubscribing_ + frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL; + sendFrame(frame); + waitForFrameToTakeEffect(); + + // connect again + reconnect(); + frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL; + sendFrame(frame); + + frame = receiveFrame(100000); + Assert.assertTrue(frame.startsWith("CONNECTED")); + + // send a receipted message to the topic + frame = "SEND\n" + "destination:" + getTopicPrefix() + getTopicName() + "\nreceipt:42\n\n\n" + "Hello World" + Stomp.NULL; + sendFrame(frame); + + // the topic should exist and receive the message, and we should get the requested receipt + frame = receiveFrame(2000); + log.info("Received frame: " + frame); + Assert.assertTrue(frame.startsWith("RECEIPT")); + + // ...and nothing else + frame = receiveFrame(2000); + log.info("Received frame: " + frame); + Assert.assertNull(frame); + + frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL; + sendFrame(frame); + } + @Test public void testClientAckNotPartOfTransaction() throws Exception {