Skip to content

Commit

Permalink
re-enabling temporarily disabled tests by virtue of their move to log…
Browse files Browse the repository at this point in the history
…back-classic-blackbox

Signed-off-by: Ceki Gulcu <[email protected]>
  • Loading branch information
ceki committed Oct 2, 2022
1 parent c336307 commit c3d75b2
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@

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 org.junit.jupiter.api.Disabled;
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 {
Expand Down Expand Up @@ -61,4 +64,82 @@ public void eval() throws JoranException {
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<ILoggingEvent> listAppender = (ListAppender<ILoggingEvent>) 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<ILoggingEvent> listAppender = (ListAppender<ILoggingEvent>) 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<ILoggingEvent> listThen = (ListAppender<ILoggingEvent>) root.getAppender("LIST_THEN");
assertNotNull(listThen);

ListAppender<ILoggingEvent> listElse = (ListAppender<ILoggingEvent>) 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<ILoggingEvent> listThen = (ListAppender<ILoggingEvent>) root.getAppender("LIST_THEN");
assertNull(listThen);

ListAppender<ILoggingEvent> listElse = (ListAppender<ILoggingEvent>) 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);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -205,27 +205,6 @@ public void contextRename() throws JoranException {
assertEquals("wombat", loggerContext.getName());
}

// DISABLED TEMPORARILY 2022-09-30
@Disabled
@Test
public void eval() throws JoranException {
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "callerData.xml");
String msg = "hello world";
logger.debug("toto");
logger.debug(msg);

StringListAppender<ILoggingEvent> slAppender = (StringListAppender<ILoggingEvent>) 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 missingConfigurationElement() throws JoranException {
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "ossfuzz/noConfig.xml");
Expand Down Expand Up @@ -299,45 +278,7 @@ public void testLevelFilter() throws JoranException {
assertEquals("hello", back.getMessage());
}

// DISABLED TEMPORARILY 2022-09-30
@Disabled
@Test
public void testEvaluatorFilter() throws JoranException {
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "evaluatorFilter.xml");

// StatusPrinter.print(loggerContext);

logger.warn("hello");
logger.error("to be ignored");

ListAppender<ILoggingEvent> listAppender = (ListAppender<ILoggingEvent>) 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());
}

// DISABLED TEMPORARILY 2022-09-30
@Disabled
@Test
public void testEvaluatorFilterWithImports() throws JoranException {
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "evaluatorFilterWithImports.xml");

// StatusPrinter.print(loggerContext);

logger.warn("hello");
logger.error("to be ignored");

ListAppender<ILoggingEvent> listAppender = (ListAppender<ILoggingEvent>) 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 testTurboDynamicThreshold() throws JoranException {
Expand Down Expand Up @@ -477,8 +418,8 @@ public void levelChangePropagator1() throws JoranException, IOException, Interru
verifyJULLevel(Logger.ROOT_LOGGER_NAME, Level.TRACE);
}

@Disabled // because slow
@Test
@Disabled
public void onConsoleRetro() throws JoranException, IOException, InterruptedException {
String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "/onConsoleRetro.xml";
configure(configFileAsStr);
Expand Down Expand Up @@ -582,54 +523,6 @@ public void shutdownHookTest() throws JoranException {
assertNotNull(thread);
}

// DISABLED TEMPORARILY 2022-09-30
@Disabled
@Test
public void conditional1673() throws JoranException {
loggerContext.putProperty("EXTRA", "true");
String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "issues/logback_1673.xml";
configure(configFileAsStr);
}

// DISABLED TEMPORARILY 2022-09-30
@Disabled
@Test
public void conditional1673bisWithActiveThen() throws JoranException {
loggerContext.putProperty("EXTRA", "true");
String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "issues/logback_1673bis.xml";
configure(configFileAsStr);
Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
ListAppender<ILoggingEvent> listThen = (ListAppender<ILoggingEvent>) root.getAppender("LIST_THEN");
assertNotNull(listThen);

ListAppender<ILoggingEvent> listElse = (ListAppender<ILoggingEvent>) root.getAppender("LIST_ELSE");
assertNull(listElse);
}

// DISABLED TEMPORARILY 2022-09-30
@Disabled
@Test
public void conditional1673bisWithActiveElse() throws JoranException {
String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "issues/logback_1673bis.xml";
configure(configFileAsStr);
Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
ListAppender<ILoggingEvent> listThen = (ListAppender<ILoggingEvent>) root.getAppender("LIST_THEN");
assertNull(listThen);

ListAppender<ILoggingEvent> listElse = (ListAppender<ILoggingEvent>) root.getAppender("LIST_ELSE");
assertNotNull(listElse);
}

// DISABLED TEMPORARILY 2022-09-30
@Disabled
@Test
public void nestedIf() throws JoranException {
loggerContext.putProperty("EXTRA", "true");
String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "issues/logback_1678.xml";
configure(configFileAsStr);
StatusPrinter.print(loggerContext);

}

@Test
public void nestedAppendersDisallowed() throws JoranException {
Expand Down
5 changes: 3 additions & 2 deletions logback-core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
requires static transitive java.xml;
requires static transitive jakarta.mail;
//requires static jakarta.activation;

requires static transitive jakarta.servlet;

// jakarta.servlet 5.0 is not modular
requires static jakarta.servlet;
requires static janino;
requires static commons.compiler;

Expand Down

0 comments on commit c3d75b2

Please sign in to comment.