|
17 | 17 | package org.apache.logging.log4j.core.config; |
18 | 18 |
|
19 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 20 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
20 | 21 | import static org.junit.jupiter.api.Assertions.assertNotSame; |
21 | 22 | import static org.junit.jupiter.api.Assertions.assertNull; |
22 | 23 | import static org.junit.jupiter.api.Assertions.assertSame; |
| 24 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
23 | 25 | import static org.mockito.ArgumentMatchers.any; |
24 | 26 | import static org.mockito.Mockito.mock; |
25 | 27 | import static org.mockito.Mockito.times; |
|
32 | 34 | import org.apache.logging.log4j.Level; |
33 | 35 | import org.apache.logging.log4j.core.Appender; |
34 | 36 | import org.apache.logging.log4j.core.Filter; |
| 37 | +import org.apache.logging.log4j.core.config.properties.PropertiesConfiguration; |
35 | 38 | import org.apache.logging.log4j.core.impl.Log4jLogEvent.Builder; |
36 | 39 | import org.apache.logging.log4j.message.SimpleMessage; |
37 | 40 | import org.junit.jupiter.api.Test; |
@@ -137,4 +140,18 @@ void testSingleFilterInvocation() { |
137 | 140 | verify(appender, times(1)).append(any()); |
138 | 141 | verify(filter, times(1)).filter(any()); |
139 | 142 | } |
| 143 | + |
| 144 | + @Test |
| 145 | + void testLevelAndRefsWithoutAppenderRef() { |
| 146 | + final Configuration configuration = mock(PropertiesConfiguration.class); |
| 147 | + final LoggerConfig.Builder builder = LoggerConfig.newBuilder() |
| 148 | + .withLoggerName(FQCN) |
| 149 | + .withConfig(configuration) |
| 150 | + .withLevelAndRefs(Level.INFO.name()); |
| 151 | + |
| 152 | + final LoggerConfig loggerConfig = builder.build(); |
| 153 | + |
| 154 | + assertNotNull(loggerConfig.getAppenderRefs()); |
| 155 | + assertTrue(loggerConfig.getAppenderRefs().isEmpty()); |
| 156 | + } |
140 | 157 | } |
0 commit comments