This is an automated email from the ASF dual-hosted git repository. robbie pushed a commit to branch new-logging in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit b1e4f9e8d052ac2adca7d570f1d16be998cbd986 Author: Robbie Gemmell <[email protected]> AuthorDate: Mon Aug 15 15:47:25 2022 +0100 ensure method or class based cleanups for AssertionLoggerHandler exist or will be effective, where startCapture() has been called previously --- .../impl/WrongRoleFileConfigurationParserTest.java | 10 ++++---- .../amqp/connect/ValidateAMQPErrorsTest.java | 27 ++++++++++++---------- .../clientcrash/PendingDeliveriesTest.java | 1 - .../integration/paging/AddressFullLoggingTest.java | 8 ++++--- .../tests/integration/paging/PagingTest.java | 9 +++++--- .../server/PotentialOOMELoggingTest.java | 10 ++++---- .../integration/server/SimpleStartStopTest.java | 1 - .../ssl/CoreClientOverOneWaySSLTest.java | 13 +++++++---- .../artemis/tests/integration/stomp/StompTest.java | 1 - 9 files changed, 44 insertions(+), 36 deletions(-) diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java index 73c04f7b53..1850d0e097 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java @@ -37,6 +37,11 @@ public class WrongRoleFileConfigurationParserTest extends ActiveMQTestBase { AssertionLoggerHandler.startCapture(); } + @AfterClass + public static void clearLogger() { + AssertionLoggerHandler.stopCapture(); + } + /** * * @@ -53,11 +58,6 @@ public class WrongRoleFileConfigurationParserTest extends ActiveMQTestBase { assertTrue(AssertionLoggerHandler.findText("AMQ222177", "delete-durable-queue")); } - @AfterClass - public static void clearLogger() { - AssertionLoggerHandler.stopCapture(); - } - private static final String configuration = "<configuration xmlns=\"urn:activemq\"\n" + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + "xsi:schemaLocation=\"urn:activemq /schema/artemis-configuration.xsd\">\n" + diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java index dc31742586..2de77ed22c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java @@ -90,20 +90,23 @@ public class ValidateAMQPErrorsTest extends AmqpClientTestSupport { @After public void stop() throws Exception { - if (mockServer != null) { - mockServer.close(); - mockServer = null; - } - if (vertx != null) { - try { - CountDownLatch latch = new CountDownLatch(1); - vertx.close((x) -> latch.countDown()); - Assert.assertTrue(latch.await(10, TimeUnit.SECONDS)); - } finally { - vertx = null; + try { + if (mockServer != null) { + mockServer.close(); + mockServer = null; } + if (vertx != null) { + try { + CountDownLatch latch = new CountDownLatch(1); + vertx.close((x) -> latch.countDown()); + Assert.assertTrue(latch.await(10, TimeUnit.SECONDS)); + } finally { + vertx = null; + } + } + } finally { + AssertionLoggerHandler.stopCapture(); // Just in case startCapture was called in any of the tests here } - AssertionLoggerHandler.stopCapture(); // Just in case startCapture was called in any of the tests here } @Override diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/PendingDeliveriesTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/PendingDeliveriesTest.java index 7e9401c346..38061ebdb8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/PendingDeliveriesTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/PendingDeliveriesTest.java @@ -49,7 +49,6 @@ public class PendingDeliveriesTest extends ClientTestBase { @After public void clearLogger() throws Exception { AssertionLoggerHandler.stopCapture(); - AssertionLoggerHandler.clear(); } private static final String AMQP_URI = "amqp://localhost:61616?amqp.saslLayer=false"; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java index 97821433c3..2e28738192 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java @@ -59,9 +59,11 @@ public class AddressFullLoggingTest extends ActiveMQTestBase { @AfterClass public static void clearLogger() { - AssertionLoggerHandler.stopCapture(); - - AssertionLoggerHandler.setLevel(SERVER_LOGGER_NAME, previousLevel); + try { + AssertionLoggerHandler.stopCapture(); + } finally { + AssertionLoggerHandler.setLevel(SERVER_LOGGER_NAME, previousLevel); + } } @Test diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java index d6551a8b4e..bd2d88eed2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java @@ -2652,10 +2652,13 @@ public class PagingTest extends ActiveMQTestBase { sf.close(); locator.close(); } finally { - if (storeType != StoreConfiguration.StoreType.DATABASE) { - Assert.assertTrue(AssertionLoggerHandler.findText("AMQ144010")); + try { + if (storeType != StoreConfiguration.StoreType.DATABASE) { + Assert.assertTrue(AssertionLoggerHandler.findText("AMQ144010")); + } + } finally { + AssertionLoggerHandler.stopCapture(); } - AssertionLoggerHandler.stopCapture(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PotentialOOMELoggingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PotentialOOMELoggingTest.java index 20b49f7b77..acb7be4c9b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PotentialOOMELoggingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PotentialOOMELoggingTest.java @@ -35,6 +35,11 @@ public class PotentialOOMELoggingTest extends ActiveMQTestBase { AssertionLoggerHandler.startCapture(); } + @AfterClass + public static void clearLogger() { + AssertionLoggerHandler.stopCapture(); + } + /** * When running this test from an IDE add this to the test command line so that the AssertionLoggerHandler works properly: * @@ -53,9 +58,4 @@ public class PotentialOOMELoggingTest extends ActiveMQTestBase { // Using the code only so the test doesn't fail just because someone edits the log text Assert.assertTrue("Expected to find 222205", AssertionLoggerHandler.findText("AMQ222205")); } - - @AfterClass - public static void clearLogger() { - AssertionLoggerHandler.stopCapture(); - } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java index f4b0a4a80f..24ff0503f5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java @@ -39,7 +39,6 @@ public class SimpleStartStopTest extends ActiveMQTestBase { */ @Test public void testStartStopAndCleanupIDs() throws Exception { - AssertionLoggerHandler.clear(); AssertionLoggerHandler.startCapture(); try { ActiveMQServer server = null; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java index 65ce1550c1..1f480b6549 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java @@ -109,12 +109,15 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { @After public void afterValidateLogging() { - if (this.generateWarning) { - Assert.assertTrue(AssertionLoggerHandler.findText("AMQ212080")); - } else { - Assert.assertFalse(AssertionLoggerHandler.findText("AMQ212080")); + try { + if (this.generateWarning) { + Assert.assertTrue(AssertionLoggerHandler.findText("AMQ212080")); + } else { + Assert.assertFalse(AssertionLoggerHandler.findText("AMQ212080")); + } + } finally { + AssertionLoggerHandler.stopCapture(); } - AssertionLoggerHandler.clear(); } @Test 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 88b433ec17..497e29f8f6 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 @@ -194,7 +194,6 @@ public class StompTest extends StompTestBase { // It should encounter the exception on logs AssertionLoggerHandler.findText("AMQ119119"); } finally { - AssertionLoggerHandler.clear(); AssertionLoggerHandler.stopCapture(); } }
