jboss-logging/0003-Drop-TestCase-that-depend-on-retired-package.patch
2023-07-10 07:31:25 +01:00

190 lines
6.5 KiB
Diff

From 2be504ac3daf3cb0e46ef57b61fe9b2967fd50e4 Mon Sep 17 00:00:00 2001
From: Chris Kelley <ckelley@redhat.com>
Date: Wed, 14 Jun 2023 11:12:00 +0100
Subject: [PATCH 3/3] Drop *TestCase that depend on retired package
The ch.qos.logback* packages are no longer packaged in Fedora so we need
to remove this test.
---
.../jboss/logging/Slf4jClassPathTestCase.java | 30 ----
.../jboss/logging/Slf4jProviderTestCase.java | 130 ------------------
2 files changed, 160 deletions(-)
delete mode 100644 src/test/java/org/jboss/logging/Slf4jClassPathTestCase.java
delete mode 100644 src/test/java/org/jboss/logging/Slf4jProviderTestCase.java
diff --git a/src/test/java/org/jboss/logging/Slf4jClassPathTestCase.java b/src/test/java/org/jboss/logging/Slf4jClassPathTestCase.java
deleted file mode 100644
index acc1df1..0000000
--- a/src/test/java/org/jboss/logging/Slf4jClassPathTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 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;
- }
-}
diff --git a/src/test/java/org/jboss/logging/Slf4jProviderTestCase.java b/src/test/java/org/jboss/logging/Slf4jProviderTestCase.java
deleted file mode 100644
index 7e07033..0000000
--- a/src/test/java/org/jboss/logging/Slf4jProviderTestCase.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 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.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;
-
-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;
-
-/**
- * @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);
- }
- }
-}
--
2.40.1