From 51f105da7b1d416bc42533895645e34c34d0371d Mon Sep 17 00:00:00 2001 From: Howard Gao Date: Thu, 22 Mar 2018 12:24:39 +0800 Subject: [PATCH] ARTEMIS-1765 Adding StompWithLargeMessageTest This closes #1965 --- .../stomp/StompWithLargeMessagesTest.java | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWithLargeMessagesTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWithLargeMessagesTest.java index 38da2d2084..eb515bda74 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWithLargeMessagesTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWithLargeMessagesTest.java @@ -69,29 +69,33 @@ public class StompWithLargeMessagesTest extends StompTestBase { public void testSendReceiveLargeMessage() throws Exception { StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri); - String address = "testLargeMessageAddress"; - server.getActiveMQServer().createQueue(SimpleString.toSimpleString(address), RoutingType.ANYCAST, SimpleString.toSimpleString(address), null, true, false); + try { + String address = "testLargeMessageAddress"; + server.getActiveMQServer().createQueue(SimpleString.toSimpleString(address), RoutingType.ANYCAST, SimpleString.toSimpleString(address), null, true, false); - // STOMP default is UTF-8 == 1 byte per char. - int largeMessageStringSize = 10 * 1024 * 1024; // 10MB - StringBuilder b = new StringBuilder(largeMessageStringSize); - for (int i = 0; i < largeMessageStringSize; i++) { - b.append('t'); + // STOMP default is UTF-8 == 1 byte per char. + int largeMessageStringSize = 10 * 1024 * 1024; // 10MB + StringBuilder b = new StringBuilder(largeMessageStringSize); + for (int i = 0; i < largeMessageStringSize; i++) { + b.append('t'); + } + String payload = b.toString(); + + // Set up STOMP subscription + conn.connect(defUser, defPass); + subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO, null, null, address, true); + + // Send Large Message + System.out.println("Sending Message Size: " + largeMessageStringSize); + send(conn, address, null, payload); + + // Receive STOMP Message + ClientStompFrame frame = conn.receiveFrame(); + System.out.println(frame.getBody().length()); + assertTrue(frame.getBody().equals(payload)); + } finally { + conn.disconnect(); } - String payload = b.toString(); - - // Set up STOMP subscription - conn.connect(defUser, defPass); - subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO, null, null, address, true); - - // Send Large Message - System.out.println("Sending Message Size: " + largeMessageStringSize); - send(conn, address, null, payload); - - // Receive STOMP Message - ClientStompFrame frame = conn.receiveFrame(); - System.out.println(frame.getBody().length()); - assertTrue(frame.getBody().equals(payload)); } //stomp sender -> large -> stomp receiver