Skip to content

Commit c336307

Browse files
committed
started black box testing
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
1 parent f22db3f commit c336307

File tree

87 files changed

+836
-185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+836
-185
lines changed

logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import ch.qos.logback.core.read.ListAppender;
2222
import ch.qos.logback.core.testUtil.CoreTestConstants;
2323
import ch.qos.logback.core.testUtil.RandomUtil;
24-
import ch.qos.logback.core.testUtil.StatusChecker;
24+
import ch.qos.logback.core.status.testUtil.StatusChecker;
2525
import org.junit.jupiter.api.BeforeEach;
2626
import org.junit.jupiter.api.Disabled;
2727
import org.junit.jupiter.api.Test;

logback-access/src/test/java/ch/qos/logback/access/tomcat/LogbackValveTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import ch.qos.logback.access.AccessTestConstants;
1717
import ch.qos.logback.core.status.Status;
18-
import ch.qos.logback.core.testUtil.StatusChecker;
18+
import ch.qos.logback.core.status.testUtil.StatusChecker;
1919
import org.apache.catalina.LifecycleException;
2020
import org.apache.catalina.core.ContainerBase;
2121
import org.junit.jupiter.api.AfterEach;

logback-classic-blackbox/pom.xml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<parent>
9+
<groupId>ch.qos.logback</groupId>
10+
<artifactId>logback-parent</artifactId>
11+
<version>1.4.2-SNAPSHOT</version>
12+
</parent>
13+
14+
<artifactId>logback-classic-blackbox</artifactId>
15+
<packaging>jar</packaging>
16+
<name>Logback Classic Blackbox Testing</name>
17+
<description>Logback Classic Blackbox Testing Module</description>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>ch.qos.logback</groupId>
22+
<artifactId>logback-classic</artifactId>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>jakarta.servlet</groupId>
27+
<artifactId>jakarta.servlet-api</artifactId>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>jakarta.mail</groupId>
32+
<artifactId>jakarta.mail-api</artifactId>
33+
<scope>compile</scope>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>org.codehaus.janino</groupId>
38+
<artifactId>janino</artifactId>
39+
<scope>compile</scope>
40+
</dependency>
41+
42+
</dependencies>
43+
44+
<build>
45+
<plugins>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-surefire-plugin</artifactId>
49+
<executions>
50+
<execution>
51+
<id>default-test</id>
52+
<configuration>
53+
54+
<argLine>
55+
</argLine>
56+
<parallel>classes</parallel>
57+
<threadCount>8</threadCount>
58+
<!--<useUnlimitedThreads>false</useUnlimitedThreads>-->
59+
<forkCount>1C</forkCount>
60+
<reuseForks>true</reuseForks>
61+
<reportFormat>plain</reportFormat>
62+
<trimStackTrace>false</trimStackTrace>
63+
<!-- See https://issues.apache.org/jira/browse/SUREFIRE-1265 -->
64+
<!--<childDelegation>true</childDelegation>-->
65+
<useModulePath>true</useModulePath>
66+
67+
<excludes>
68+
<!--- temporary -->
69+
<exclude>**/JaninoEventEvaluatorTest.java</exclude>
70+
<exclude>**/ConditionalTest.java</exclude>
71+
</excludes>
72+
</configuration>
73+
</execution>
74+
75+
<execution>
76+
<id>singleJVM</id>
77+
<goals>
78+
<goal>test</goal>
79+
</goals>
80+
<configuration>
81+
<forkCount>4</forkCount>
82+
<reuseForks>false</reuseForks>
83+
<includes>
84+
</includes>
85+
</configuration>
86+
</execution>
87+
</executions>
88+
</plugin>
89+
90+
<plugin>
91+
<groupId>org.apache.maven.plugins</groupId>
92+
<artifactId>maven-deploy-plugin</artifactId>
93+
<configuration>
94+
<skip>true</skip>
95+
</configuration>
96+
</plugin>
97+
98+
</plugins>
99+
</build>
100+
</project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE configuration>
3+
4+
<configuration>
5+
6+
<evaluator name="helloEval">
7+
<Expression>m.matches(message)</Expression>
8+
<matcher>
9+
<name>m</name>
10+
<regex>^hello.*</regex>
11+
<CaseSensitive>false</CaseSensitive>
12+
</matcher>
13+
</evaluator>
14+
15+
<appender name="STR_LIST"
16+
class="ch.qos.logback.core.testUtil.StringListAppender">
17+
<layout>
18+
<Pattern>%caller{4, helloEval}%d %level - %m%n</Pattern>
19+
</layout>
20+
</appender>
21+
22+
<root>
23+
<level value="DEBUG" />
24+
<appender-ref ref="STR_LIST" />
25+
</root>
26+
27+
28+
29+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Logback: the reliable, generic, fast and flexible logging framework.
3+
* Copyright (C) 1999-2022, QOS.ch. All rights reserved.
4+
*
5+
* This program and the accompanying materials are dual-licensed under
6+
* either the terms of the Eclipse Public License v1.0 as published by
7+
* the Eclipse Foundation
8+
*
9+
* or (per the licensee's choosing)
10+
*
11+
* under the terms of the GNU Lesser General Public License version 2.1
12+
* as published by the Free Software Foundation.
13+
*/
14+
15+
package ch.qos.logback.classic.blackbox;
16+
17+
public class BlackboxClassicTestConstants {
18+
19+
public static final String TEST_SRC_PREFIX = "src/test/";
20+
public static final String TEST_INPUT_PREFIX = TEST_SRC_PREFIX + "blackboxInput/";
21+
public static final String JORAN_INPUT_PREFIX = TEST_INPUT_PREFIX + "joran/";
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Logback: the reliable, generic, fast and flexible logging framework.
3+
* Copyright (C) 1999-2022, QOS.ch. All rights reserved.
4+
*
5+
* This program and the accompanying materials are dual-licensed under
6+
* either the terms of the Eclipse Public License v1.0 as published by
7+
* the Eclipse Foundation
8+
*
9+
* or (per the licensee's choosing)
10+
*
11+
* under the terms of the GNU Lesser General Public License version 2.1
12+
* as published by the Free Software Foundation.
13+
*/
14+
15+
package ch.qos.logback.classic.blackbox.joran;
16+
17+
import ch.qos.logback.classic.Logger;
18+
import ch.qos.logback.classic.LoggerContext;
19+
import ch.qos.logback.classic.blackbox.BlackboxClassicTestConstants;
20+
import ch.qos.logback.classic.joran.JoranConfigurator;
21+
import ch.qos.logback.classic.spi.ILoggingEvent;
22+
import ch.qos.logback.core.joran.spi.JoranException;
23+
import ch.qos.logback.core.testUtil.RandomUtil;
24+
import ch.qos.logback.core.testUtil.StringListAppender;
25+
import org.junit.jupiter.api.Disabled;
26+
import org.junit.jupiter.api.Test;
27+
28+
import static org.junit.jupiter.api.Assertions.assertEquals;
29+
import static org.junit.jupiter.api.Assertions.assertNotNull;
30+
import static org.junit.jupiter.api.Assertions.assertTrue;
31+
32+
public class BlackboxJoranConfiguratorTest {
33+
LoggerContext loggerContext = new LoggerContext();
34+
Logger logger = loggerContext.getLogger(this.getClass().getName());
35+
Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
36+
//StatusChecker checker = new StatusChecker(loggerContext);
37+
int diff = RandomUtil.getPositiveInt();
38+
39+
void configure(String file) throws JoranException {
40+
JoranConfigurator jc = new JoranConfigurator();
41+
jc.setContext(loggerContext);
42+
loggerContext.putProperty("diff", "" + diff);
43+
jc.doConfigure(file);
44+
45+
}
46+
47+
@Test
48+
public void eval() throws JoranException {
49+
configure(BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "callerData.xml");
50+
String msg = "hello world";
51+
logger.debug("toto");
52+
logger.debug(msg);
53+
54+
StringListAppender<ILoggingEvent> slAppender = (StringListAppender<ILoggingEvent>) loggerContext
55+
.getLogger("root").getAppender("STR_LIST");
56+
assertNotNull(slAppender);
57+
assertEquals(2, slAppender.strList.size());
58+
assertTrue(slAppender.strList.get(0).contains(" DEBUG - toto"));
59+
60+
String str1 = slAppender.strList.get(1);
61+
assertTrue(str1.contains("Caller+0"));
62+
assertTrue(str1.contains(" DEBUG - hello world"));
63+
}
64+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module logback.classic.blackbox {
2+
requires ch.qos.logback.core;
3+
requires ch.qos.logback.classic;
4+
requires jakarta.mail;
5+
requires janino;
6+
7+
requires org.junit.jupiter.api;
8+
requires org.junit.jupiter.engine;
9+
10+
exports ch.qos.logback.classic.blackbox.joran;
11+
}

logback-classic/pom.xml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -375,42 +375,4 @@
375375
</pluginManagement>
376376
</build>
377377

378-
<profiles>
379-
380-
<profile>
381-
<!-- Integration tests require the host-orion profile -->
382-
<id>host-orion</id>
383-
<dependencies>
384-
<!-- locally installed artifact -->
385-
<dependency>
386-
<groupId>com.microsoft.sqlserver</groupId>
387-
<artifactId>sqljdbc4</artifactId>
388-
<version>2.0</version>
389-
<scope>test</scope>
390-
</dependency>
391-
<!-- locally installed artifact -->
392-
<dependency>
393-
<groupId>com.oracle</groupId>
394-
<artifactId>ojdbc14</artifactId>
395-
<version>10.2.0.1</version>
396-
<scope>test</scope>
397-
</dependency>
398-
</dependencies>
399-
</profile>
400-
401-
<profile>
402-
<!-- Integration tests require the host-hora profile -->
403-
<id>host-hora</id>
404-
<dependencies>
405-
<!-- locally installed artifact -->
406-
<dependency>
407-
<groupId>com.oracle</groupId>
408-
<artifactId>ojdbc14</artifactId>
409-
<version>10.2.0.1</version>
410-
<scope>test</scope>
411-
</dependency>
412-
</dependencies>
413-
</profile>
414-
</profiles>
415-
416378
</project>

logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegateTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter
2828
import ch.qos.logback.classic.Level
2929
import ch.qos.logback.core.testUtil.CoreTestConstants
3030
import ch.qos.logback.core.testUtil.RandomUtil
31-
import ch.qos.logback.core.testUtil.StatusChecker
31+
import ch.qos.logback.core.status.testUtil.StatusChecker
3232
import ch.qos.logback.classic.Logger
3333
import ch.qos.logback.core.Appender
3434
import ch.qos.logback.core.helpers.NOPAppender

logback-classic/src/test/input/fqcn.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ ch.qos.logback.core.joran.action.ext.TouchAction
880880
ch.qos.logback.core.joran.action.IncludeActionTest
881881
ch.qos.logback.core.joran.action.PropertyActionTest
882882
ch.qos.logback.core.joran.action.TopElementAction
883-
ch.qos.logback.core.joran.conditional.PropertyEvalScriptBuilderTest
883+
ch.qos.logback.core.blackbox.joran.conditional.PropertyEvalScriptBuilderTest
884884
ch.qos.logback.core.joran.event.SaxEventRecorderTest
885885
ch.qos.logback.core.joran.event.stax.StaxEventRecorderTest
886886
ch.qos.logback.core.joran.implicitAction.Cake
@@ -1008,7 +1008,7 @@ ch.qos.logback.core.testUtil.FileTestUtil
10081008
ch.qos.logback.core.testUtil.FileToBufferUtil
10091009
ch.qos.logback.core.testUtil.NPEAppender
10101010
ch.qos.logback.core.testUtil.RandomUtil
1011-
ch.qos.logback.core.testUtil.StatusChecker
1011+
ch.qos.logback.core.status.testUtil.StatusChecker
10121012
ch.qos.logback.core.testUtil.StringListAppender
10131013
ch.qos.logback.core.testUtil.TeeOutputStream
10141014
ch.qos.logback.core.testUtil.TrivialStatusListener

logback-classic/src/test/input/joran/callerData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</evaluator>
1414

1515
<appender name="STR_LIST"
16-
class="ch.qos.logback.core.testUtil.StringListAppender">
16+
class="ch.qos.logback.core.testUtil.StringListAppender">
1717
<layout>
1818
<Pattern>%caller{4, helloEval}%d %level - %m%n</Pattern>
1919
</layout>

logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextConcurrentResetTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package ch.qos.logback.classic;
22

33
import java.util.concurrent.CyclicBarrier;
4-
import java.util.concurrent.TimeUnit;
54

65
import org.junit.jupiter.api.Disabled;
76
import org.junit.jupiter.api.Test;
87

98
import ch.qos.logback.core.contention.AbstractMultiThreadedHarness;
109
import ch.qos.logback.core.contention.RunnableWithCounterAndDone;
11-
import ch.qos.logback.core.testUtil.StatusChecker;
10+
import ch.qos.logback.core.status.testUtil.StatusChecker;
1211
import org.junit.jupiter.api.Timeout;
1312

1413
@Disabled

logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import ch.qos.logback.core.spi.ScanException;
2727
import ch.qos.logback.core.testUtil.StringListAppender;
2828
import ch.qos.logback.core.util.OptionHelper;
29-
import ch.qos.logback.core.util.StatusPrinter;
3029
import org.junit.jupiter.api.BeforeEach;
3130
import org.junit.jupiter.api.Test;
3231
import org.slf4j.MDC;

logback-classic/src/test/java/ch/qos/logback/classic/RecursiveLBAppender.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.slf4j.Logger;
2020
import org.slf4j.LoggerFactory;
2121

22-
import ch.qos.logback.classic.PatternLayout;
2322
import ch.qos.logback.classic.spi.ILoggingEvent;
2423
import ch.qos.logback.core.AppenderBase;
2524
import ch.qos.logback.core.testUtil.RandomUtil;

logback-classic/src/test/java/ch/qos/logback/classic/boolex/GEventEvaluatorTest.DISABLEDjava

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
2020
import ch.qos.logback.classic.spi.LoggingEvent;
2121
import ch.qos.logback.core.CoreConstants;
2222
import ch.qos.logback.core.boolex.EvaluationException;
23-
import ch.qos.logback.core.testUtil.StatusChecker;
23+
import ch.qos.logback.core.status.testUtil.StatusChecker;
2424
import ch.qos.logback.core.util.ContextUtil;
2525
import ch.qos.logback.core.util.StatusPrinter;
2626
import org.junit.Before;

logback-classic/src/test/java/ch/qos/logback/classic/encoder/LayoutInsteadOfEncoderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import ch.qos.logback.core.encoder.LayoutWrappingEncoder;
3030
import ch.qos.logback.core.joran.spi.JoranException;
3131
import ch.qos.logback.core.status.Status;
32-
import ch.qos.logback.core.testUtil.StatusChecker;
32+
import ch.qos.logback.core.status.testUtil.StatusChecker;
3333
import ch.qos.logback.core.util.StatusPrinter;
3434

3535
public class LayoutInsteadOfEncoderTest {

logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import ch.qos.logback.core.spi.ScanException;
5454
import ch.qos.logback.core.status.Status;
5555
import ch.qos.logback.core.testUtil.RandomUtil;
56-
import ch.qos.logback.core.testUtil.StatusChecker;
56+
import ch.qos.logback.core.status.testUtil.StatusChecker;
5757
import ch.qos.logback.core.testUtil.StringListAppender;
5858
import ch.qos.logback.core.util.CachingDateFormatter;
5959
import ch.qos.logback.core.util.StatusPrinter;

logback-classic/src/test/java/ch/qos/logback/classic/joran/ReconfigureOnChangeTaskTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
import ch.qos.logback.core.testUtil.CoreTestConstants;
5555
import ch.qos.logback.core.testUtil.FileTestUtil;
5656
import ch.qos.logback.core.testUtil.RandomUtil;
57-
import ch.qos.logback.core.testUtil.StatusChecker;
57+
import ch.qos.logback.core.status.testUtil.StatusChecker;
5858
import ch.qos.logback.core.util.StatusPrinter;
5959
import org.junit.jupiter.api.Timeout;
6060

0 commit comments

Comments
 (0)