30
30
import ch .qos .logback .core .testUtil .CoreTestConstants ;
31
31
import ch .qos .logback .core .testUtil .RandomUtil ;
32
32
import ch .qos .logback .core .util .StatusPrinter ;
33
+ import ch .qos .logback .core .util .StatusPrinter2 ;
33
34
import org .junit .jupiter .api .AfterEach ;
34
35
import org .junit .jupiter .api .BeforeEach ;
35
36
import org .junit .jupiter .api .Test ;
@@ -51,6 +52,7 @@ public class ConditionalTest {
51
52
Logger root = loggerContext .getLogger (Logger .ROOT_LOGGER_NAME );
52
53
53
54
Logger logger = loggerContext .getLogger (this .getClass ().getName ());
55
+ StatusPrinter2 statusPrinter2 = new StatusPrinter2 ();
54
56
55
57
StatusUtil checker = new StatusUtil (loggerContext );
56
58
int diff = RandomUtil .getPositiveInt ();
@@ -132,7 +134,7 @@ public void conditionalInclusionWithExistingFile() throws JoranException, IOExce
132
134
String configFileAsStr = BlackboxClassicTestConstants .JORAN_INPUT_PREFIX
133
135
+ "conditional/conditionalIncludeExistingFile.xml" ;
134
136
configure (configFileAsStr );
135
- StatusPrinter .print (loggerContext );
137
+ //statusPrinter2 .print(loggerContext);
136
138
137
139
ConsoleAppender <ILoggingEvent > consoleAppender = (ConsoleAppender <ILoggingEvent >) root .getAppender ("CON" );
138
140
assertNotNull (consoleAppender );
@@ -152,6 +154,22 @@ public void conditionalInclusionWithInexistentFile() throws JoranException, IOEx
152
154
assertTrue (checker .isErrorFree (0 ));
153
155
}
154
156
157
+ // https://jira.qos.ch/browse/LOGBACK-1732
158
+ @ Test
159
+ public void conditionalInclusionWithVariableDefinition () throws JoranException , IOException , InterruptedException {
160
+
161
+ String configFileAsStr = BlackboxClassicTestConstants .JORAN_INPUT_PREFIX
162
+ + "conditional/includeWithVariableAndConditional.xml" ;
163
+ configure (configFileAsStr );
164
+
165
+ statusPrinter2 .print (loggerContext );
166
+
167
+ ConsoleAppender <ILoggingEvent > consoleAppender = (ConsoleAppender <ILoggingEvent >) root .getAppender ("CON" );
168
+ assertNotNull (consoleAppender );
169
+ assertTrue (checker .isErrorFree (0 ));
170
+ }
171
+
172
+
155
173
private AppenderTracker <ILoggingEvent > getAppenderTracker () {
156
174
SiftingAppender ha = (SiftingAppender ) root .getAppender ("SIFT" );
157
175
return ha .getAppenderTracker ();
@@ -161,7 +179,7 @@ private AppenderTracker<ILoggingEvent> getAppenderTracker() {
161
179
@ Test
162
180
public void nestedWithinIfThen () throws JoranException {
163
181
configure (BlackboxClassicTestConstants .JORAN_INPUT_PREFIX + "conditional/siftNestedWithinIfThen.xml" );
164
- StatusPrinter .print (loggerContext );
182
+ //statusPrinter2 .print(loggerContext);
165
183
String msg = "nestedWithinIfThen" ;
166
184
logger .debug (msg );
167
185
Appender <ILoggingEvent > appender = getAppenderTracker ().find ("ifThenDefault" );
@@ -172,4 +190,6 @@ public void nestedWithinIfThen() throws JoranException {
172
190
assertEquals (msg , eventList .get (0 ).getMessage ());
173
191
checker .isWarningOrErrorFree (0 );
174
192
}
193
+
194
+
175
195
}
0 commit comments