From 6ece896aee92e1da83814e9e3cb2306870c3f895 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Mon, 22 Jul 2019 19:08:04 -0400 Subject: [PATCH] NO-JIRA Fixing broken test at StompV11Test StompV11Test::testConnection was leaking a NettyConnector what was leaving threads running. This would then fail ThreadLeakCheckRule --- .../integration/stomp/v11/StompV11Test.java | 59 +++++++++++-------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java index ec226090ff..78134f0621 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java @@ -100,44 +100,57 @@ public class StompV11Test extends StompTestBase { server.getSecurityStore().setSecurityEnabled(true); StompClientConnection connection = StompClientConnectionFactory.createClientConnection(v10Uri); - connection.connect(defUser, defPass); + try { - assertTrue(connection.isConnected()); + connection.connect(defUser, defPass); - assertEquals("1.0", connection.getVersion()); + assertTrue(connection.isConnected()); - connection.disconnect(); + assertEquals("1.0", connection.getVersion()); - connection = StompClientConnectionFactory.createClientConnection(uri); + connection.disconnect(); - connection.connect(defUser, defPass); + connection.closeTransport(); - assertTrue(connection.isConnected()); + connection = StompClientConnectionFactory.createClientConnection(uri); - assertEquals("1.1", connection.getVersion()); + connection.connect(defUser, defPass); - connection.disconnect(); + assertTrue(connection.isConnected()); - connection = StompClientConnectionFactory.createClientConnection(uri); + assertEquals("1.1", connection.getVersion()); - connection.connect(); + connection.disconnect(); - assertFalse(connection.isConnected()); + connection.closeTransport(); - //new way of connection - StompClientConnectionV11 conn = (StompClientConnectionV11) StompClientConnectionFactory.createClientConnection(uri); - conn.connect1(defUser, defPass); + connection = StompClientConnectionFactory.createClientConnection(uri); - assertTrue(conn.isConnected()); + connection.connect(); - conn.disconnect(); + assertFalse(connection.isConnected()); - //invalid user - conn = (StompClientConnectionV11) StompClientConnectionFactory.createClientConnection(uri); - ClientStompFrame frame = conn.connect("invaliduser", defPass); - assertFalse(conn.isConnected()); - assertTrue(Stomp.Responses.ERROR.equals(frame.getCommand())); - assertTrue(frame.getBody().contains("Security Error occurred")); + //new way of connection + StompClientConnectionV11 conn = (StompClientConnectionV11) StompClientConnectionFactory.createClientConnection(uri); + conn.connect1(defUser, defPass); + + assertTrue(conn.isConnected()); + + conn.disconnect(); + + conn.closeTransport(); + + //invalid user + conn = (StompClientConnectionV11) StompClientConnectionFactory.createClientConnection(uri); + ClientStompFrame frame = conn.connect("invaliduser", defPass); + assertFalse(conn.isConnected()); + assertTrue(Stomp.Responses.ERROR.equals(frame.getCommand())); + assertTrue(frame.getBody().contains("Security Error occurred")); + + conn.closeTransport(); + } finally { + connection.closeTransport(); + } } @Test