You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ro...@apache.org on 2022/08/11 17:09:59 UTC
[activemq-artemis] branch new-logging updated: restore one of the remaining tests using JBL, manipulating levels
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
The following commit(s) were added to refs/heads/new-logging by this push:
new 157140b9df restore one of the remaining tests using JBL, manipulating levels
157140b9df is described below
commit 157140b9df7f4ae1c45189934060bce4c1f6d182
Author: Robbie Gemmell <ro...@apache.org>
AuthorDate: Thu Aug 11 18:07:53 2022 +0100
restore one of the remaining tests using JBL, manipulating levels
---
.../activemq/artemis/logs/AssertionLoggerHandler.java | 11 +++++++++--
tests/integration-tests/pom.xml | 8 ++++++++
.../integration/MultiThreadedAuditLoggingTest.java | 19 +++++++++++--------
3 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java b/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java
index 4456c5d34d..2c4b4037b7 100644
--- a/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java
+++ b/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java
@@ -32,6 +32,7 @@ import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
@@ -114,9 +115,15 @@ public class AssertionLoggerHandler extends AbstractAppender {
public static LogLevel setLevel(String loggerName, LogLevel level) {
final Logger logger = LogManager.getLogger(loggerName);
- final Level implLevel = logger.getLevel();
+ final Level existingLevel = logger.getLevel();
- return LogLevel.fromImplLevel(implLevel);
+ final Level newLevel = level.toImplLevel();
+
+ if (!existingLevel.equals(newLevel)) {
+ Configurator.setLevel(logger, newLevel);
+ }
+
+ return LogLevel.fromImplLevel(existingLevel);
}
public static boolean findText(long mstimeout, String... text) {
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index 7b0994e297..870559818e 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -33,6 +33,14 @@
</properties>
<dependencies>
+ <!-- TODO: seems like this shouldnt be needed, some other dep is
+ causing the commons-logging output to occur, investigate. -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-quorum-ri</artifactId>
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/MultiThreadedAuditLoggingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/MultiThreadedAuditLoggingTest.java
index 160d3c8976..9e2b45f1d9 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/MultiThreadedAuditLoggingTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/MultiThreadedAuditLoggingTest.java
@@ -31,20 +31,23 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
+import org.apache.activemq.artemis.logs.AssertionLoggerHandler.LogLevel;
+import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.spi.core.security.ActiveMQBasicSecurityManager;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
-@Ignore("Needs updated to account for logging impl changes") //TODO: reinstate
public class MultiThreadedAuditLoggingTest extends ActiveMQTestBase {
protected ActiveMQServer server;
private static final int MESSAGE_COUNT = 10;
+ private static final String MESSAGE_AUDIT_LOGGER_NAME = AuditLogger.MESSAGE_LOGGER.getLogger().getName();
+
+ private static LogLevel previousLevel = null;
@Override
@Before
@@ -63,19 +66,19 @@ public class MultiThreadedAuditLoggingTest extends ActiveMQTestBase {
server.getActiveMQServerControl().addUser("queue2", "queue2", "queue2", true);
}
- //TODO: private static final Logger logManager = Logger.getLogger("org.apache.activemq.audit.message");
- //TODO: private static java.util.logging.Level previousLevel = logManager.getLevel();
-
@BeforeClass
public static void prepareLogger() {
- //TODO: logManager.setLevel(Level.INFO);
+ previousLevel = AssertionLoggerHandler.setLevel(MESSAGE_AUDIT_LOGGER_NAME, LogLevel.INFO);
AssertionLoggerHandler.startCapture();
}
@AfterClass
public static void clearLogger() {
- AssertionLoggerHandler.stopCapture();
- //TODO: logManager.setLevel(previousLevel);
+ try {
+ AssertionLoggerHandler.stopCapture();
+ } finally {
+ AssertionLoggerHandler.setLevel(MESSAGE_AUDIT_LOGGER_NAME, previousLevel);
+ }
}
class SomeConsumer extends Thread {