-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ceki Gulcu <[email protected]>
- Loading branch information
Showing
87 changed files
with
836 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-parent</artifactId> | ||
<version>1.4.2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>logback-classic-blackbox</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Logback Classic Blackbox Testing</name> | ||
<description>Logback Classic Blackbox Testing Module</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>jakarta.servlet</groupId> | ||
<artifactId>jakarta.servlet-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>jakarta.mail</groupId> | ||
<artifactId>jakarta.mail-api</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.codehaus.janino</groupId> | ||
<artifactId>janino</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default-test</id> | ||
<configuration> | ||
|
||
<argLine> | ||
</argLine> | ||
<parallel>classes</parallel> | ||
<threadCount>8</threadCount> | ||
<!--<useUnlimitedThreads>false</useUnlimitedThreads>--> | ||
<forkCount>1C</forkCount> | ||
<reuseForks>true</reuseForks> | ||
<reportFormat>plain</reportFormat> | ||
<trimStackTrace>false</trimStackTrace> | ||
<!-- See https://issues.apache.org/jira/browse/SUREFIRE-1265 --> | ||
<!--<childDelegation>true</childDelegation>--> | ||
<useModulePath>true</useModulePath> | ||
|
||
<excludes> | ||
<!--- temporary --> | ||
<exclude>**/JaninoEventEvaluatorTest.java</exclude> | ||
<exclude>**/ConditionalTest.java</exclude> | ||
</excludes> | ||
</configuration> | ||
</execution> | ||
|
||
<execution> | ||
<id>singleJVM</id> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<forkCount>4</forkCount> | ||
<reuseForks>false</reuseForks> | ||
<includes> | ||
</includes> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
</project> |
29 changes: 29 additions & 0 deletions
29
logback-classic-blackbox/src/test/blackboxInput/joran/callerData.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE configuration> | ||
|
||
<configuration> | ||
|
||
<evaluator name="helloEval"> | ||
<Expression>m.matches(message)</Expression> | ||
<matcher> | ||
<name>m</name> | ||
<regex>^hello.*</regex> | ||
<CaseSensitive>false</CaseSensitive> | ||
</matcher> | ||
</evaluator> | ||
|
||
<appender name="STR_LIST" | ||
class="ch.qos.logback.core.testUtil.StringListAppender"> | ||
<layout> | ||
<Pattern>%caller{4, helloEval}%d %level - %m%n</Pattern> | ||
</layout> | ||
</appender> | ||
|
||
<root> | ||
<level value="DEBUG" /> | ||
<appender-ref ref="STR_LIST" /> | ||
</root> | ||
|
||
|
||
|
||
</configuration> |
22 changes: 22 additions & 0 deletions
22
...-blackbox/src/test/java/ch/qos/logback/classic/blackbox/BlackboxClassicTestConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/"; | ||
} |
64 changes: 64 additions & 0 deletions
64
...ox/src/test/java/ch/qos/logback/classic/blackbox/joran/BlackboxJoranConfiguratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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.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.testUtil.RandomUtil; | ||
import ch.qos.logback.core.testUtil.StringListAppender; | ||
import org.junit.jupiter.api.Disabled; | ||
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.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<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")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextConcurrentResetTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.