From 74a44b922168d86363b6bbc3322543ed66ae5d39 Mon Sep 17 00:00:00 2001 From: Ceki Gulcu Date: Sun, 2 Oct 2022 18:46:55 +0200 Subject: [PATCH] move disabled tests to logback-classic-blackbox --- logback-access-blackbox/pom.xml | 92 +++++++++++ .../test/blackboxInput/joran/callerData.xml | 29 ++++ .../blackboxInput/joran/evaluatorFilter.xml | 19 +++ .../joran/evaluatorFilterWithImports.xml | 21 +++ .../joran/issues/logback_1673.xml | 23 +++ .../joran/issues/logback_1673bis.xml | 22 +++ .../joran/issues/logback_1678.xml | 21 +++ .../BlackboxClassicTestConstants.java | 22 +++ .../joran/BlackboxJoranConfiguratorTest.java | 145 ++++++++++++++++++ .../src/test/java/module-info.java | 11 ++ logback-classic-blackbox/pom.xml | 2 +- .../conditional/conditionalConsoleApp.xml | 0 .../conditionalConsoleApp_ELSE.xml | 0 .../conditionalIncludeExistingFile.xml | 32 ++++ .../conditionalIncludeInexistentFile.xml | 0 .../joran/conditional/includedFile.xml | 0 .../BlackboxJaninoEventEvaluatorTest.java | 14 +- .../joran/conditional/ConditionalTest.java | 53 +++---- .../src/test/java/module-info.java | 3 + logback-classic/src/test/input/fqcn.txt | 2 +- .../conditionalIncludeExistingFile.xml | 18 --- 21 files changed, 474 insertions(+), 55 deletions(-) create mode 100644 logback-access-blackbox/pom.xml create mode 100644 logback-access-blackbox/src/test/blackboxInput/joran/callerData.xml create mode 100644 logback-access-blackbox/src/test/blackboxInput/joran/evaluatorFilter.xml create mode 100644 logback-access-blackbox/src/test/blackboxInput/joran/evaluatorFilterWithImports.xml create mode 100644 logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1673.xml create mode 100644 logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1673bis.xml create mode 100644 logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1678.xml create mode 100644 logback-access-blackbox/src/test/java/ch/qos/logback/classic/blackbox/BlackboxClassicTestConstants.java create mode 100644 logback-access-blackbox/src/test/java/ch/qos/logback/classic/blackbox/joran/BlackboxJoranConfiguratorTest.java create mode 100644 logback-access-blackbox/src/test/java/module-info.java rename {logback-classic/src/test/input => logback-classic-blackbox/src/test/blackboxInput}/joran/conditional/conditionalConsoleApp.xml (100%) rename {logback-classic/src/test/input => logback-classic-blackbox/src/test/blackboxInput}/joran/conditional/conditionalConsoleApp_ELSE.xml (100%) create mode 100644 logback-classic-blackbox/src/test/blackboxInput/joran/conditional/conditionalIncludeExistingFile.xml rename {logback-classic/src/test/input => logback-classic-blackbox/src/test/blackboxInput}/joran/conditional/conditionalIncludeInexistentFile.xml (100%) rename {logback-classic/src/test/input => logback-classic-blackbox/src/test/blackboxInput}/joran/conditional/includedFile.xml (100%) rename logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java => logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/boolex/BlackboxJaninoEventEvaluatorTest.java (95%) rename {logback-classic/src/test/java/ch/qos/logback/classic => logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox}/joran/conditional/ConditionalTest.java (79%) mode change 100755 => 100644 delete mode 100644 logback-classic/src/test/input/joran/conditional/conditionalIncludeExistingFile.xml diff --git a/logback-access-blackbox/pom.xml b/logback-access-blackbox/pom.xml new file mode 100644 index 0000000000..0747bd63b6 --- /dev/null +++ b/logback-access-blackbox/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + + ch.qos.logback + logback-parent + 1.4.2-SNAPSHOT + + + logback-access-blackbox + jar + Logback Access Blackbox Testing + Logback Access Blackbox Testing Module + + + + ch.qos.logback + logback-access + + + + jakarta.servlet + jakarta.servlet-api + + + + jakarta.mail + jakarta.mail-api + compile + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + default-test + + + + + classes + 8 + + 1C + true + plain + false + + + true + + + + + + + + singleJVM + + test + + + 4 + false + + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + diff --git a/logback-access-blackbox/src/test/blackboxInput/joran/callerData.xml b/logback-access-blackbox/src/test/blackboxInput/joran/callerData.xml new file mode 100644 index 0000000000..560c5f4b94 --- /dev/null +++ b/logback-access-blackbox/src/test/blackboxInput/joran/callerData.xml @@ -0,0 +1,29 @@ + + + + + + + m.matches(message) + + m + ^hello.* + false + + + + + + %caller{4, helloEval}%d %level - %m%n + + + + + + + + + + + diff --git a/logback-access-blackbox/src/test/blackboxInput/joran/evaluatorFilter.xml b/logback-access-blackbox/src/test/blackboxInput/joran/evaluatorFilter.xml new file mode 100644 index 0000000000..e0823f73ec --- /dev/null +++ b/logback-access-blackbox/src/test/blackboxInput/joran/evaluatorFilter.xml @@ -0,0 +1,19 @@ + + + + + + myFilter + DENY + + mdcEvaluator + "to be ignored".equals(message) + + + + + + + + \ No newline at end of file diff --git a/logback-access-blackbox/src/test/blackboxInput/joran/evaluatorFilterWithImports.xml b/logback-access-blackbox/src/test/blackboxInput/joran/evaluatorFilterWithImports.xml new file mode 100644 index 0000000000..f532f9bf07 --- /dev/null +++ b/logback-access-blackbox/src/test/blackboxInput/joran/evaluatorFilterWithImports.xml @@ -0,0 +1,21 @@ + + + + + + + + + myFilter + DENY + + mdcEvaluator + "to be ignored".equals(message) + + + + + + + + \ No newline at end of file diff --git a/logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1673.xml b/logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1673.xml new file mode 100644 index 0000000000..118a40eb96 --- /dev/null +++ b/logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1673.xml @@ -0,0 +1,23 @@ + + + + + + + + + + ... + + + + + + + + + + + + + \ No newline at end of file diff --git a/logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1673bis.xml b/logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1673bis.xml new file mode 100644 index 0000000000..cda9bc0d8f --- /dev/null +++ b/logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1673bis.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1678.xml b/logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1678.xml new file mode 100644 index 0000000000..3401eb0119 --- /dev/null +++ b/logback-access-blackbox/src/test/blackboxInput/joran/issues/logback_1678.xml @@ -0,0 +1,21 @@ + + + + + + ... + + + + ... + + + + + + + + + + + diff --git a/logback-access-blackbox/src/test/java/ch/qos/logback/classic/blackbox/BlackboxClassicTestConstants.java b/logback-access-blackbox/src/test/java/ch/qos/logback/classic/blackbox/BlackboxClassicTestConstants.java new file mode 100644 index 0000000000..d0f3a47a45 --- /dev/null +++ b/logback-access-blackbox/src/test/java/ch/qos/logback/classic/blackbox/BlackboxClassicTestConstants.java @@ -0,0 +1,22 @@ +/* + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2022, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ + +package ch.qos.logback.classic.blackbox; + +public class BlackboxClassicTestConstants { + + public static final String TEST_SRC_PREFIX = "src/test/"; + public static final String TEST_INPUT_PREFIX = TEST_SRC_PREFIX + "blackboxInput/"; + public static final String JORAN_INPUT_PREFIX = TEST_INPUT_PREFIX + "joran/"; +} diff --git a/logback-access-blackbox/src/test/java/ch/qos/logback/classic/blackbox/joran/BlackboxJoranConfiguratorTest.java b/logback-access-blackbox/src/test/java/ch/qos/logback/classic/blackbox/joran/BlackboxJoranConfiguratorTest.java new file mode 100644 index 0000000000..4dd4a8d69f --- /dev/null +++ b/logback-access-blackbox/src/test/java/ch/qos/logback/classic/blackbox/joran/BlackboxJoranConfiguratorTest.java @@ -0,0 +1,145 @@ +/* + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2022, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ + +package ch.qos.logback.classic.blackbox.joran; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.blackbox.BlackboxClassicTestConstants; +import ch.qos.logback.classic.joran.JoranConfigurator; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.read.ListAppender; +import ch.qos.logback.core.testUtil.RandomUtil; +import ch.qos.logback.core.testUtil.StringListAppender; +import ch.qos.logback.core.util.StatusPrinter; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class BlackboxJoranConfiguratorTest { + LoggerContext loggerContext = new LoggerContext(); + Logger logger = loggerContext.getLogger(this.getClass().getName()); + Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); + //StatusChecker checker = new StatusChecker(loggerContext); + int diff = RandomUtil.getPositiveInt(); + + void configure(String file) throws JoranException { + JoranConfigurator jc = new JoranConfigurator(); + jc.setContext(loggerContext); + loggerContext.putProperty("diff", "" + diff); + jc.doConfigure(file); + + } + + @Test + public void eval() throws JoranException { + configure(BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "callerData.xml"); + String msg = "hello world"; + logger.debug("toto"); + logger.debug(msg); + + StringListAppender slAppender = (StringListAppender) loggerContext + .getLogger("root").getAppender("STR_LIST"); + assertNotNull(slAppender); + assertEquals(2, slAppender.strList.size()); + assertTrue(slAppender.strList.get(0).contains(" DEBUG - toto")); + + String str1 = slAppender.strList.get(1); + assertTrue(str1.contains("Caller+0")); + assertTrue(str1.contains(" DEBUG - hello world")); + } + + @Test + public void testEvaluatorFilter() throws JoranException { + configure(BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "evaluatorFilter.xml"); + + // StatusPrinter.print(loggerContext); + + logger.warn("hello"); + logger.error("to be ignored"); + + ListAppender listAppender = (ListAppender) root.getAppender("LIST"); + + assertNotNull(listAppender); + assertEquals(1, listAppender.list.size()); + ILoggingEvent back = listAppender.list.get(0); + assertEquals(Level.WARN, back.getLevel()); + assertEquals("hello", back.getMessage()); + } + + @Test + public void testEvaluatorFilterWithImports() throws JoranException { + configure(BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "evaluatorFilterWithImports.xml"); + + // StatusPrinter.print(loggerContext); + + logger.warn("hello"); + logger.error("to be ignored"); + + ListAppender listAppender = (ListAppender) root.getAppender("LIST"); + + assertNotNull(listAppender); + assertEquals(1, listAppender.list.size()); + ILoggingEvent back = listAppender.list.get(0); + assertEquals(Level.WARN, back.getLevel()); + assertEquals("hello", back.getMessage()); + } + + @Test + public void conditional1673() throws JoranException { + loggerContext.putProperty("EXTRA", "true"); + String configFileAsStr = BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "issues/logback_1673.xml"; + configure(configFileAsStr); + } + + @Test + public void conditional1673bisWithActiveThen() throws JoranException { + loggerContext.putProperty("EXTRA", "true"); + String configFileAsStr = BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "issues/logback_1673bis.xml"; + configure(configFileAsStr); + Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); + ListAppender listThen = (ListAppender) root.getAppender("LIST_THEN"); + assertNotNull(listThen); + + ListAppender listElse = (ListAppender) root.getAppender("LIST_ELSE"); + assertNull(listElse); + } + + @Test + public void conditional1673bisWithActiveElse() throws JoranException { + String configFileAsStr = BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "issues/logback_1673bis.xml"; + configure(configFileAsStr); + Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); + ListAppender listThen = (ListAppender) root.getAppender("LIST_THEN"); + assertNull(listThen); + + ListAppender listElse = (ListAppender) root.getAppender("LIST_ELSE"); + assertNotNull(listElse); + } + + @Test + public void nestedIf() throws JoranException { + loggerContext.putProperty("EXTRA", "true"); + String configFileAsStr = BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "issues/logback_1678.xml"; + configure(configFileAsStr); + StatusPrinter.print(loggerContext); + + } + +} diff --git a/logback-access-blackbox/src/test/java/module-info.java b/logback-access-blackbox/src/test/java/module-info.java new file mode 100644 index 0000000000..e60320bfa4 --- /dev/null +++ b/logback-access-blackbox/src/test/java/module-info.java @@ -0,0 +1,11 @@ +module logback.classic.blackbox { + requires ch.qos.logback.core; + requires ch.qos.logback.classic; + requires jakarta.mail; + requires janino; + + requires org.junit.jupiter.api; + requires org.junit.jupiter.engine; + + exports ch.qos.logback.classic.blackbox.joran; +} \ No newline at end of file diff --git a/logback-classic-blackbox/pom.xml b/logback-classic-blackbox/pom.xml index 41d6095eb7..0024d27cab 100644 --- a/logback-classic-blackbox/pom.xml +++ b/logback-classic-blackbox/pom.xml @@ -66,7 +66,7 @@ - **/JaninoEventEvaluatorTest.java + **/ConditionalTest.java diff --git a/logback-classic/src/test/input/joran/conditional/conditionalConsoleApp.xml b/logback-classic-blackbox/src/test/blackboxInput/joran/conditional/conditionalConsoleApp.xml similarity index 100% rename from logback-classic/src/test/input/joran/conditional/conditionalConsoleApp.xml rename to logback-classic-blackbox/src/test/blackboxInput/joran/conditional/conditionalConsoleApp.xml diff --git a/logback-classic/src/test/input/joran/conditional/conditionalConsoleApp_ELSE.xml b/logback-classic-blackbox/src/test/blackboxInput/joran/conditional/conditionalConsoleApp_ELSE.xml similarity index 100% rename from logback-classic/src/test/input/joran/conditional/conditionalConsoleApp_ELSE.xml rename to logback-classic-blackbox/src/test/blackboxInput/joran/conditional/conditionalConsoleApp_ELSE.xml diff --git a/logback-classic-blackbox/src/test/blackboxInput/joran/conditional/conditionalIncludeExistingFile.xml b/logback-classic-blackbox/src/test/blackboxInput/joran/conditional/conditionalIncludeExistingFile.xml new file mode 100644 index 0000000000..195574c924 --- /dev/null +++ b/logback-classic-blackbox/src/test/blackboxInput/joran/conditional/conditionalIncludeExistingFile.xml @@ -0,0 +1,32 @@ + + + + + + + + + + src/test/blackboxInput/joran/conditional/includedFile.xml + + + + + + + + \ No newline at end of file diff --git a/logback-classic/src/test/input/joran/conditional/conditionalIncludeInexistentFile.xml b/logback-classic-blackbox/src/test/blackboxInput/joran/conditional/conditionalIncludeInexistentFile.xml similarity index 100% rename from logback-classic/src/test/input/joran/conditional/conditionalIncludeInexistentFile.xml rename to logback-classic-blackbox/src/test/blackboxInput/joran/conditional/conditionalIncludeInexistentFile.xml diff --git a/logback-classic/src/test/input/joran/conditional/includedFile.xml b/logback-classic-blackbox/src/test/blackboxInput/joran/conditional/includedFile.xml similarity index 100% rename from logback-classic/src/test/input/joran/conditional/includedFile.xml rename to logback-classic-blackbox/src/test/blackboxInput/joran/conditional/includedFile.xml diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java b/logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/boolex/BlackboxJaninoEventEvaluatorTest.java similarity index 95% rename from logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java rename to logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/boolex/BlackboxJaninoEventEvaluatorTest.java index b84d9861c7..c3396ccaf5 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java +++ b/logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/boolex/BlackboxJaninoEventEvaluatorTest.java @@ -1,6 +1,6 @@ -/** +/* * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. + * Copyright (C) 1999-2022, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,10 +11,11 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ -package ch.qos.logback.classic.boolex; +package ch.qos.logback.classic.blackbox.boolex; import java.io.IOException; +import ch.qos.logback.classic.boolex.JaninoEventEvaluator; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.slf4j.MDC; @@ -23,7 +24,6 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.pattern.ConverterTest; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.LoggingEvent; import ch.qos.logback.core.boolex.EvaluationException; @@ -39,10 +39,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -public class JaninoEventEvaluatorTest { +public class BlackboxJaninoEventEvaluatorTest { LoggerContext loggerContext = new LoggerContext(); - Logger logger = loggerContext.getLogger(ConverterTest.class); + Logger logger = loggerContext.getLogger(BlackboxJaninoEventEvaluatorTest.class); Matcher matcherX = new Matcher(); @@ -50,7 +50,7 @@ public class JaninoEventEvaluatorTest { int diff = RandomUtil.getPositiveInt(); - public JaninoEventEvaluatorTest() { + public BlackboxJaninoEventEvaluatorTest() { jee.setContext(loggerContext); matcherX.setName("x"); diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java b/logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/joran/conditional/ConditionalTest.java old mode 100755 new mode 100644 similarity index 79% rename from logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java rename to logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/joran/conditional/ConditionalTest.java index 1c417d91f4..42c57844a5 --- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java +++ b/logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/joran/conditional/ConditionalTest.java @@ -1,6 +1,6 @@ -/** +/* * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, QOS.ch. All rights reserved. + * Copyright (C) 1999-2022, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,38 +11,39 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ -package ch.qos.logback.classic.joran.conditional; +package ch.qos.logback.classic.blackbox.joran.conditional; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import ch.qos.logback.classic.ClassicTestConstants; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.blackbox.BlackboxClassicTestConstants; import ch.qos.logback.classic.joran.JoranConfigurator; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.ConsoleAppender; import ch.qos.logback.core.FileAppender; import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.read.ListAppender; +import ch.qos.logback.core.status.StatusUtil; import ch.qos.logback.core.testUtil.CoreTestConstants; import ch.qos.logback.core.testUtil.RandomUtil; -import ch.qos.logback.core.status.testUtil.StatusChecker; import ch.qos.logback.core.util.StatusPrinter; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ConditionalTest { LoggerContext context = new LoggerContext(); Logger root = context.getLogger(Logger.ROOT_LOGGER_NAME); + StatusUtil checker = new StatusUtil(context); int diff = RandomUtil.getPositiveInt(); String randomOutputDir = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "/"; @@ -71,37 +72,35 @@ public void conditionalConsoleApp_IF_THEN_True() throws JoranException, IOExcept + localhost.getCanonicalHostName() + "] and hostNmae=\"" + localhost.getHostName() + "\""); context.putProperty("aHost", localhost.getHostName()); - String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "conditional/conditionalConsoleApp.xml"; + String configFileAsStr = BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "conditional/conditionalConsoleApp.xml"; configure(configFileAsStr); FileAppender fileAppender = (FileAppender) root.getAppender("FILE"); assertNotNull(fileAppender); ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON"); assertNotNull(consoleAppender); - StatusChecker checker = new StatusChecker(context); - checker.assertIsErrorFree(); + assertTrue(checker.isErrorFree(0)); } @SuppressWarnings("rawtypes") @Test public void conditionalConsoleApp_IF_THEN_False() throws JoranException, IOException, InterruptedException { - String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "conditional/conditionalConsoleApp.xml"; + String configFileAsStr = BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "conditional/conditionalConsoleApp.xml"; configure(configFileAsStr); FileAppender fileAppender = (FileAppender) root.getAppender("FILE"); assertNotNull(fileAppender); ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON"); assertNull(consoleAppender); - StatusChecker checker = new StatusChecker(context); - checker.assertIsErrorFree(); + assertTrue(checker.isErrorFree(0)); } @SuppressWarnings("rawtypes") @Test public void conditionalConsoleApp_IF_THEN_ELSE() throws JoranException, IOException, InterruptedException { - String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "conditional/conditionalConsoleApp_ELSE.xml"; + String configFileAsStr = BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "conditional/conditionalConsoleApp_ELSE.xml"; configure(configFileAsStr); FileAppender fileAppender = (FileAppender) root.getAppender("FILE"); @@ -114,35 +113,33 @@ public void conditionalConsoleApp_IF_THEN_ELSE() throws JoranException, IOExcept assertNotNull(listAppender); // StatusPrinter.printIfErrorsOccured(context); - StatusChecker checker = new StatusChecker(context); - checker.assertIsErrorFree(); + assertTrue(checker.isErrorFree(0)); } @Test public void conditionalInclusionWithExistingFile() throws JoranException, IOException, InterruptedException { - String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + String configFileAsStr = BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "conditional/conditionalIncludeExistingFile.xml"; configure(configFileAsStr); StatusPrinter.print(context); ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON"); assertNotNull(consoleAppender); - StatusChecker checker = new StatusChecker(context); - checker.assertIsErrorFree(); + + assertTrue(checker.isErrorFree(0)); } @Test public void conditionalInclusionWithInexistentFile() throws JoranException, IOException, InterruptedException { - String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + String configFileAsStr = BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "conditional/conditionalIncludeInexistentFile.xml"; configure(configFileAsStr); ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON"); assertNull(consoleAppender); - StatusChecker checker = new StatusChecker(context); - checker.assertIsErrorFree(); + assertTrue(checker.isErrorFree(0)); } } diff --git a/logback-classic-blackbox/src/test/java/module-info.java b/logback-classic-blackbox/src/test/java/module-info.java index e60320bfa4..92320936ff 100644 --- a/logback-classic-blackbox/src/test/java/module-info.java +++ b/logback-classic-blackbox/src/test/java/module-info.java @@ -6,6 +6,9 @@ requires org.junit.jupiter.api; requires org.junit.jupiter.engine; + requires org.slf4j; + exports ch.qos.logback.classic.blackbox.boolex; exports ch.qos.logback.classic.blackbox.joran; + exports ch.qos.logback.classic.blackbox.joran.conditional; } \ No newline at end of file diff --git a/logback-classic/src/test/input/fqcn.txt b/logback-classic/src/test/input/fqcn.txt index 080c817c32..4a8b5f429d 100644 --- a/logback-classic/src/test/input/fqcn.txt +++ b/logback-classic/src/test/input/fqcn.txt @@ -350,7 +350,7 @@ ch.qos.logback.classic.issue.logback_1162.Main ch.qos.logback.classic.issue.logback_1277.Main ch.qos.logback.classic.issue.logback_1361.Main ch.qos.logback.classic.jmx.JMXConfiguratorTest -ch.qos.logback.classic.joran.conditional.ConditionalTest +ch.qos.logback.classic.blackbox.joran.conditional.ConditionalTest ch.qos.logback.classic.joran.EvaluatorJoranTest ch.qos.logback.classic.joran.JoranConfiguratorTest ch.qos.logback.classic.joran.ReconfigureOnChangeTaskTest diff --git a/logback-classic/src/test/input/joran/conditional/conditionalIncludeExistingFile.xml b/logback-classic/src/test/input/joran/conditional/conditionalIncludeExistingFile.xml deleted file mode 100644 index e9e746e3a9..0000000000 --- a/logback-classic/src/test/input/joran/conditional/conditionalIncludeExistingFile.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - src/test/input/joran/conditional/includedFile.xml - - - - - - - - \ No newline at end of file