|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2017 the original author or authors. |
| 2 | + * Copyright 2012-2018 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
35 | 35 | import org.junit.Before;
|
36 | 36 | import org.junit.Rule;
|
37 | 37 | import org.junit.Test;
|
| 38 | +import org.junit.runner.RunWith; |
38 | 39 | import org.slf4j.ILoggerFactory;
|
39 | 40 | import org.slf4j.bridge.SLF4JBridgeHandler;
|
40 | 41 | import org.slf4j.impl.StaticLoggerBinder;
|
41 | 42 |
|
| 43 | +import org.springframework.boot.junit.runner.classpath.ClassPathExclusions; |
| 44 | +import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner; |
42 | 45 | import org.springframework.boot.logging.AbstractLoggingSystemTests;
|
43 | 46 | import org.springframework.boot.logging.LogFile;
|
44 | 47 | import org.springframework.boot.logging.LogLevel;
|
|
67 | 70 | * @author Ben Hale
|
68 | 71 | * @author Madhura Bhave
|
69 | 72 | */
|
| 73 | +@RunWith(ModifiedClassPathRunner.class) |
| 74 | +@ClassPathExclusions("log4j-*.jar") |
70 | 75 | public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
|
71 | 76 |
|
72 | 77 | @Rule
|
@@ -132,13 +137,15 @@ public void testBasicConfigLocation() throws Exception {
|
132 | 137 | }
|
133 | 138 |
|
134 | 139 | @Test
|
135 |
| - public void testNonDefaultConfigLocation() throws Exception { |
| 140 | + public void testNonDefaultConfigLocation() { |
| 141 | + int existingOutputLength = this.output.toString().length(); |
136 | 142 | this.loggingSystem.beforeInitialize();
|
137 | 143 | this.loggingSystem.initialize(this.initializationContext,
|
138 | 144 | "classpath:logback-nondefault.xml",
|
139 | 145 | getLogFile(tmpDir() + "/tmp.log", null));
|
140 | 146 | this.logger.info("Hello world");
|
141 | 147 | String output = this.output.toString().trim();
|
| 148 | + assertThat(output.substring(existingOutputLength)).doesNotContain("DEBUG"); |
142 | 149 | assertThat(output).contains("Hello world").contains(tmpDir() + "/tmp.log");
|
143 | 150 | assertThat(output).endsWith("BOOTBOOT");
|
144 | 151 | assertThat(new File(tmpDir() + "/tmp.log").exists()).isFalse();
|
|
0 commit comments