File skipTests.patch of Package jboss-logging
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/AbstractClassPathTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/AbstractClassPathTestCase.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-abstract class AbstractClassPathTestCase {
-
- @Test
- public void testLogger() {
- final Logger logger = Logger.getLogger(getClass());
- Assertions.assertEquals(getLoggerClass(), logger.getClass());
- }
-
- abstract Class<? extends Logger> getLoggerClass();
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/AbstractLoggerTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/AbstractLoggerTestCase.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-abstract class AbstractLoggerTestCase {
-
- @AfterAll
- public static void clearProviderProperty() {
- System.clearProperty("org.jboss.logging.provider");
- }
-
- @AfterEach
- public void clearDiagnostics() {
- MDC.clear();
- NDC.clear();
- }
-
- @Test
- public void testLogger() {
- Assertions.assertEquals(getLoggerClass(), getLogger().getClass());
- }
-
- @Test
- public void testLog() {
- for (Logger.Level level : Logger.Level.values()) {
- testLog(level);
- }
- }
-
- @Test
- public void testTrace() {
- getLogger().trace("Test log level TRACE");
- testLog("Test log level TRACE", Logger.Level.TRACE);
- }
-
- @Test
- public void testDebug() {
- getLogger().debug("Test log level DEBUG");
- testLog("Test log level DEBUG", Logger.Level.DEBUG);
- }
-
- @Test
- public void testInfo() {
- getLogger().info("Test log level INFO");
- testLog("Test log level INFO", Logger.Level.INFO);
- }
-
- @Test
- public void testWarn() {
- getLogger().warn("Test log level WARN");
- testLog("Test log level WARN", Logger.Level.WARN);
- }
-
- @Test
- public void testError() {
- getLogger().error("Test log level ERROR");
- testLog("Test log level ERROR", Logger.Level.ERROR);
- }
-
- @Test
- public void testFatal() {
- getLogger().fatal("Test log level FATAL");
- testLog("Test log level FATAL", Logger.Level.FATAL);
- }
-
- abstract void testLog(Logger.Level level);
-
- abstract void testLog(String msg, Logger.Level level);
-
- abstract Logger getLogger();
-
- abstract Class<? extends Logger> getLoggerClass();
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/CustomProviderTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/CustomProviderTestCase.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class CustomProviderTestCase {
-
- @Test
- public void testLogger() {
- final Logger logger = Logger.getLogger(CustomProviderTestCase.class);
- Assertions.assertEquals(TestLogger.class, logger.getClass());
- }
-
- public static class TestProvider extends AbstractMdcLoggerProvider implements LoggerProvider {
-
- @Override
- public Logger getLogger(final String name) {
- return new TestLogger(name);
- }
- }
-
- static class TestLogger extends Logger {
-
- /**
- * Construct a new instance.
- *
- * @param name the logger category name
- */
- protected TestLogger(final String name) {
- super(name);
- }
-
- @Override
- protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) {
-
- }
-
- @Override
- protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters, final Throwable thrown) {
-
- }
-
- @Override
- public boolean isEnabled(final Level level) {
- return true;
- }
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/JBossLogManagerClassPathTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/JBossLogManagerClassPathTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class JBossLogManagerClassPathTestCase extends AbstractClassPathTestCase {
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return JBossLogManagerLogger.class;
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/JBossLogManagerProviderTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/JBossLogManagerProviderTestCase.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-import org.jboss.logmanager.LogContext;
-import org.jboss.logmanager.LogContextSelector;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class JBossLogManagerProviderTestCase extends AbstractLoggerTestCase {
- private static final LogContextSelector DEFAULT_SELECTOR = LogContext.getLogContextSelector();
- private static final AtomicBoolean SET_LOG_MANAGER = new AtomicBoolean(true);
-
- private LogContext logContext;
- private TestHandler handler;
- private Logger logger;
-
- @BeforeAll
- public static void setup() {
- SET_LOG_MANAGER.set(System.getProperty("java.util.logging.manager") == null);
- if (SET_LOG_MANAGER.get()) {
- System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
- }
- System.setProperty("org.jboss.logging.provider", "jboss");
- }
-
- @AfterAll
- public static void tearDown() {
- if (SET_LOG_MANAGER.get()) {
- System.clearProperty("java.util.logging.manager");
- }
- }
-
- @BeforeEach
- public void setupLogContext() {
- logContext = LogContext.create();
- LogContext.setLogContextSelector(() -> logContext);
- logger = Logger.getLogger(getClass());
- handler = createHandler(logContext, logger.getName());
- }
-
- @AfterEach
- public void closeLogContext() throws Exception {
- logContext.close();
- LogContext.setLogContextSelector(DEFAULT_SELECTOR);
- }
-
- @Test
- public void testMdc() {
- MDC.put("test.key", "value");
- Assertions.assertEquals("value", MDC.get("test.key"));
- Assertions.assertEquals("value", org.jboss.logmanager.MDC.get("test.key"));
- }
-
- @Test
- public void testNdc() {
- NDC.push("value1");
- NDC.push("value2");
- final String expectedValue = "value1.value2";
- Assertions.assertEquals(expectedValue, NDC.peek());
- Assertions.assertEquals(expectedValue, NDC.get());
- Assertions.assertEquals(2, NDC.getDepth());
-
- // Test the log manager values
- Assertions.assertEquals(expectedValue, org.jboss.logmanager.NDC.get());
- Assertions.assertEquals(2, org.jboss.logmanager.NDC.getDepth());
-
- // Pop the stack
- Assertions.assertEquals("value2", NDC.pop());
- Assertions.assertEquals(1, NDC.getDepth());
- Assertions.assertEquals("value1", NDC.get());
- Assertions.assertEquals("value1", org.jboss.logmanager.NDC.get());
- Assertions.assertEquals(1, org.jboss.logmanager.NDC.getDepth());
- }
-
- @Override
- void testLog(final Logger.Level level) {
- final String msg = String.format("Test log message at %s", level);
- logger.log(level, msg);
-
- Assertions.assertTrue(logger.isEnabled(level), String.format("Logger not enabled for level %s", level));
- testLog(msg, level);
- }
-
- @Override
- void testLog(final String msg, final Logger.Level level) {
- final LogRecord logRecord = handler.queue.poll();
- Assertions.assertNotNull(logRecord, String.format("No record found for %s", level));
- Assertions.assertEquals(level.name(), logRecord.getLevel().getName());
- Assertions.assertEquals(msg, logRecord.getMessage());
- }
-
- @Override
- Logger getLogger() {
- return logger;
- }
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return JBossLogManagerLogger.class;
- }
-
- private static TestHandler createHandler(final LogContext logContext, final String loggerName) {
- final TestHandler handler = new TestHandler();
- final java.util.logging.Logger julLogger = logContext.getLogger(loggerName);
- julLogger.addHandler(handler);
- julLogger.setLevel(Level.ALL);
- return handler;
- }
-
- private static class TestHandler extends Handler {
- final BlockingQueue<LogRecord> queue = new LinkedBlockingQueue<>();
-
- @Override
- public void publish(final LogRecord record) {
- queue.add(record);
- }
-
- @Override
- public void flush() {
- }
-
- @Override
- public void close() throws SecurityException {
- queue.clear();
- }
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/JulClassPathTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/JulClassPathTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class JulClassPathTestCase extends AbstractClassPathTestCase {
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return JDKLogger.class;
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/JulProviderTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/JulProviderTestCase.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class JulProviderTestCase extends AbstractLoggerTestCase {
- private TestHandler handler;
- private Logger logger;
-
- @BeforeAll
- public static void setup() {
- System.setProperty("org.jboss.logging.provider", "jdk");
- }
-
- @BeforeEach
- public void setupLogContext() {
- logger = Logger.getLogger(getClass());
- handler = createHandler(logger.getName());
- }
-
- @AfterEach
- public void removeHandler() {
- java.util.logging.Logger.getLogger(logger.getName()).removeHandler(handler);
- handler.close();
- }
-
- @Test
- public void testMdc() {
- MDC.put("test.key", "value");
- Assertions.assertEquals("value", MDC.get("test.key"));
- }
-
- @Test
- public void testNdc() {
- NDC.push("value1");
- NDC.push("value2");
- Assertions.assertEquals("value2", NDC.peek());
- Assertions.assertEquals("value1 value2", NDC.get());
- Assertions.assertEquals(2, NDC.getDepth());
-
- // Pop the stack
- Assertions.assertEquals("value2", NDC.pop());
- Assertions.assertEquals(1, NDC.getDepth());
- Assertions.assertEquals("value1", NDC.get());
- }
-
- @Override
- void testLog(final Logger.Level level) {
- final String msg = String.format("Test log message at %s", level);
- logger.log(level, msg);
-
- Assertions.assertTrue(logger.isEnabled(level), String.format("Logger not enabled for level %s", level));
- testLog(msg, level);
- }
-
- @Override
- void testLog(final String msg, final Logger.Level level) {
- final LogRecord logRecord = handler.queue.poll();
- Assertions.assertNotNull(logRecord, String.format("No record found for %s", level));
- Assertions.assertEquals(level.name(), logRecord.getLevel().getName());
- Assertions.assertEquals(msg, logRecord.getMessage());
- }
-
- @Override
- Logger getLogger() {
- return logger;
- }
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return JDKLogger.class;
- }
-
- private static TestHandler createHandler(final String loggerName) {
- final TestHandler handler = new TestHandler();
- final java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(loggerName);
- julLogger.addHandler(handler);
- julLogger.setLevel(Level.ALL);
- return handler;
- }
-
- private static class TestHandler extends Handler {
- final BlockingQueue<LogRecord> queue = new LinkedBlockingQueue<>();
-
- @Override
- public void publish(final LogRecord record) {
- queue.add(record);
- }
-
- @Override
- public void flush() {
- }
-
- @Override
- public void close() throws SecurityException {
- queue.clear();
- }
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/Log4j2ClassPathTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/Log4j2ClassPathTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Log4j2ClassPathTestCase extends AbstractClassPathTestCase {
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Log4j2Logger.class;
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/Log4j2ProviderTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/Log4j2ProviderTestCase.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import java.io.Serializable;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.ThreadContext;
-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.LoggerContext;
-import org.apache.logging.log4j.core.appender.AbstractAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Log4j2ProviderTestCase extends AbstractLoggerTestCase {
- private TestAppender appender;
- private Logger logger;
-
- @BeforeAll
- public static void setup() {
- System.setProperty("org.jboss.logging.provider", "log4j2");
- }
-
- @BeforeEach
- public void setupLogContext() {
- logger = Logger.getLogger(getClass());
- final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
- final Configuration config = ctx.getConfiguration();
- appender = (TestAppender) config.getAppenders().get("TestAppender");
- }
-
- @Test
- public void testMdc() {
- MDC.put("test.key", "value");
- Assertions.assertEquals("value", MDC.get("test.key"));
- Assertions.assertEquals("value", ThreadContext.get("test.key"));
- }
-
- @Test
- public void testNdc() {
- NDC.push("value1");
- NDC.push("value2");
- Assertions.assertEquals("value2", NDC.peek());
- // TODO (jrp) This is a weird case we should validate. NDC.get() does ThreadContext.peek() which doesn't seem
- // TODO (jrp) correct. The method should likely do ThreadContext.getImmutableStack().toString(). At least that
- // TODO (jrp) is what the NdcPatternConverter does.
- //Assertions.assertEquals("[value1, value2]", NDC.get());
- Assertions.assertEquals(2, NDC.getDepth());
-
- // Test the log manager values
- Assertions.assertEquals("[value1, value2]", ThreadContext.getImmutableStack().toString());
- Assertions.assertEquals(2, ThreadContext.getDepth());
-
- // Pop the stack
- Assertions.assertEquals("value2", NDC.pop());
- Assertions.assertEquals(1, NDC.getDepth());
- Assertions.assertEquals("value1", NDC.get());
- Assertions.assertEquals("value1", ThreadContext.peek());
- Assertions.assertEquals(1, ThreadContext.getDepth());
- }
-
- @Override
- void testLog(final Logger.Level level) {
- final String msg = String.format("Test log message at %s", level);
- logger.log(level, msg);
-
- Assertions.assertTrue(logger.isEnabled(level), String.format("Logger not enabled for level %s", level));
- testLog(msg, level);
- }
-
- @Override
- void testLog(final String msg, final Logger.Level level) {
- final LogEvent event = appender.queue.poll();
- Assertions.assertNotNull(event, String.format("No record found for %s", level));
- Assertions.assertEquals(level.name(), event.getLevel().toString());
- Assertions.assertEquals(msg, event.getMessage().getFormattedMessage());
- }
-
- @Override
- Logger getLogger() {
- return logger;
- }
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Log4j2Logger.class;
- }
-
- @SuppressWarnings("unused")
- @Plugin(name = "TestAppender", category = "Core", elementType = "appender", printObject = true)
- public static class TestAppender extends AbstractAppender {
- final BlockingQueue<LogEvent> queue = new LinkedBlockingQueue<>();
-
- protected TestAppender(String name, Filter filter, Layout<? extends Serializable> layout) {
- super(name, filter, layout, false, null);
- }
-
- @Override
- public void append(final LogEvent event) {
- queue.add(event.toImmutable());
- }
-
- @Override
- public void stop() {
- queue.clear();
- super.stop();
- }
-
- @PluginFactory
- public static TestAppender createAppender(@PluginAttribute("name") String name,
- @PluginElement("Layout") Layout<? extends Serializable> layout,
- @PluginElement("Filter") final Filter filter,
- @PluginAttribute("otherAttribute") String otherAttribute) {
- if (name == null) {
- LOGGER.error("No name provided for TestAppender");
- return null;
- }
- if (layout == null) {
- layout = PatternLayout.createDefaultLayout();
- }
- return new TestAppender(name, filter, layout);
- }
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/Log4jClassPathTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/Log4jClassPathTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Log4jClassPathTestCase extends AbstractClassPathTestCase {
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Log4jLogger.class;
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/Log4jProviderTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/Log4jProviderTestCase.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.Level;
-import org.apache.log4j.spi.LoggingEvent;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Log4jProviderTestCase extends AbstractLoggerTestCase {
- private TestAppender appender;
- private Logger logger;
-
- @BeforeAll
- public static void setup() {
- System.setProperty("org.jboss.logging.provider", "log4j");
- }
-
- @BeforeEach
- public void setupLogContext() {
- logger = Logger.getLogger(getClass());
- appender = createAppender(logger.getName());
- }
-
- @AfterEach
- public void removeAppender() {
- org.apache.log4j.Logger.getLogger(logger.getName()).removeAppender(appender);
- appender.close();
- }
-
- @Test
- public void testMdc() {
- MDC.put("test.key", "value");
- Assertions.assertEquals("value", MDC.get("test.key"));
- Assertions.assertEquals("value", org.apache.log4j.MDC.get("test.key"));
- }
-
- @Test
- public void testNdc() {
- NDC.push("value1");
- NDC.push("value2");
- Assertions.assertEquals("value2", NDC.peek());
- Assertions.assertEquals("value1 value2", NDC.get());
- Assertions.assertEquals(2, NDC.getDepth());
-
- // Test the log manager values
- Assertions.assertEquals("value1 value2", org.apache.log4j.NDC.get());
- Assertions.assertEquals(2, org.apache.log4j.NDC.getDepth());
-
- // Pop the stack
- Assertions.assertEquals("value2", NDC.pop());
- Assertions.assertEquals(1, NDC.getDepth());
- Assertions.assertEquals("value1", NDC.get());
- Assertions.assertEquals("value1", org.apache.log4j.NDC.get());
- Assertions.assertEquals(1, org.apache.log4j.NDC.getDepth());
- }
-
- @Override
- void testLog(final Logger.Level level) {
- final String msg = String.format("Test log message at %s", level);
- logger.log(level, msg);
-
- Assertions.assertTrue(logger.isEnabled(level), String.format("Logger not enabled for level %s", level));
- testLog(msg, level);
- }
-
- @Override
- void testLog(final String msg, final Logger.Level level) {
- final LoggingEvent event = appender.queue.poll();
- Assertions.assertNotNull(event, String.format("No record found for %s", level));
- Assertions.assertEquals(level.name(), event.getLevel().toString());
- Assertions.assertEquals(msg, event.getMessage());
- }
-
- @Override
- Logger getLogger() {
- return logger;
- }
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Log4jLogger.class;
- }
-
- private static TestAppender createAppender(final String loggerName) {
- final TestAppender appender = new TestAppender();
- final org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(loggerName);
- log4jLogger.addAppender(appender);
- log4jLogger.setLevel(Level.ALL);
- return appender;
- }
-
- private static class TestAppender extends AppenderSkeleton {
- final BlockingQueue<LoggingEvent> queue = new LinkedBlockingQueue<>();
-
- @Override
- protected void append(final LoggingEvent loggingEvent) {
- queue.add(loggingEvent);
- }
-
- @Override
- public void close() throws SecurityException {
- queue.clear();
- }
-
- @Override
- public boolean requiresLayout() {
- return false;
- }
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/Slf4jClassPathTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/Slf4jClassPathTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Slf4jClassPathTestCase extends AbstractClassPathTestCase {
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Slf4jLocationAwareLogger.class;
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/java/org/jboss/logging/Slf4jProviderTestCase.java
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/java/org/jboss/logging/Slf4jProviderTestCase.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2020 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.AppenderBase;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Slf4jProviderTestCase extends AbstractLoggerTestCase {
- private TestAppender appender;
- private Logger logger;
-
- @BeforeAll
- public static void setup() {
- System.setProperty("org.jboss.logging.provider", "slf4j");
- }
-
- @BeforeEach
- public void setupLogContext() {
- logger = Logger.getLogger(getClass());
- appender = createHandler(logger.getName());
- }
-
- @AfterEach
- public void removeAppender() {
- ch.qos.logback.classic.Logger lbLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(logger.getName());
- lbLogger.detachAppender(appender);
- appender.stop();
- }
-
- @Test
- public void testMdc() {
- MDC.put("test.key", "value");
- Assertions.assertEquals("value", MDC.get("test.key"));
- Assertions.assertEquals("value", org.slf4j.MDC.get("test.key"));
- }
-
- @Test
- public void testNdc() {
- NDC.push("value1");
- NDC.push("value2");
- Assertions.assertEquals("value2", NDC.peek());
- Assertions.assertEquals("value1 value2", NDC.get());
- Assertions.assertEquals(2, NDC.getDepth());
-
- // Pop the stack
- Assertions.assertEquals("value2", NDC.pop());
- Assertions.assertEquals(1, NDC.getDepth());
- Assertions.assertEquals("value1", NDC.get());
- }
-
- @Override
- void testLog(final Logger.Level level) {
- final String msg = String.format("Test log message at %s", level);
- logger.log(level, msg);
-
- Assertions.assertTrue(logger.isEnabled(level), String.format("Logger not enabled for level %s", level));
- testLog(msg, level);
- }
-
- @Override
- void testLog(final String msg, final Logger.Level level) {
- final ILoggingEvent event = appender.queue.poll();
- Assertions.assertNotNull(event, String.format("No record found for %s", level));
- final Logger.Level translatedLevel = level == Logger.Level.FATAL ? Logger.Level.ERROR : level;
- Assertions.assertEquals(translatedLevel.name(), event.getLevel().toString());
- Assertions.assertEquals(msg, event.getFormattedMessage());
- }
-
- @Override
- Logger getLogger() {
- return logger;
- }
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Slf4jLocationAwareLogger.class;
- }
-
- private static TestAppender createHandler(final String loggerName) {
- final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- final TestAppender appender = new TestAppender();
- appender.setContext(context);
- appender.start();
-
- ch.qos.logback.classic.Logger lbLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(loggerName);
- lbLogger.addAppender(appender);
- lbLogger.setLevel(Level.ALL);
- return appender;
- }
-
- public static class TestAppender extends AppenderBase<ILoggingEvent> {
- final BlockingQueue<ILoggingEvent> queue = new LinkedBlockingQueue<>();
-
- @Override
- protected void append(final ILoggingEvent event) {
- queue.add(event);
- }
- }
-}
Index: jboss-logging-3.5.0.Final/src/test/resources/META-INF/services/org.jboss.logging.LoggerProvider
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/resources/META-INF/services/org.jboss.logging.LoggerProvider
+++ /dev/null
@@ -1 +0,0 @@
-org.jboss.logging.CustomProviderTestCase$TestProvider
\ No newline at end of file
Index: jboss-logging-3.5.0.Final/src/test/resources/log4j2-test.xml
===================================================================
--- jboss-logging-3.5.0.Final.orig/src/test/resources/log4j2-test.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ JBoss, Home of Professional Open Source.
- ~
- ~ Copyright 2020 Red Hat, Inc.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<Configuration status="WARN" packages="org.jboss.logging">
- <Appenders>
- <TestAppender name="TestAppender">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </TestAppender>
- </Appenders>
- <Loggers>
- <Logger name="org.jboss.logging.Log4j2ProviderTestCase" level="All">
- <AppenderRef ref="TestAppender" level="All"/>
- </Logger>
- </Loggers>
-</Configuration>
\ No newline at end of file