15
15
*/
16
16
package org .springframework .cloud .logging ;
17
17
18
- import static org .junit .Assert .assertFalse ;
19
- import static org .junit .Assert .assertTrue ;
20
-
21
18
import java .util .Collections ;
22
19
23
20
import org .junit .After ;
27
24
import org .springframework .boot .logging .LogLevel ;
28
25
import org .springframework .boot .logging .LoggingSystem ;
29
26
import org .springframework .boot .test .EnvironmentTestUtils ;
30
- import org .springframework .core .env .StandardEnvironment ;
31
27
import org .springframework .cloud .context .environment .EnvironmentChangeEvent ;
28
+ import org .springframework .core .env .StandardEnvironment ;
29
+
30
+ import static org .junit .Assert .assertFalse ;
31
+ import static org .junit .Assert .assertTrue ;
32
32
33
33
/**
34
34
* @author Dave Syer
@@ -38,20 +38,35 @@ public class LoggingRebinderTests {
38
38
39
39
private LoggingRebinder rebinder = new LoggingRebinder ();
40
40
private Logger logger = LoggerFactory .getLogger ("org.springframework.web" );
41
-
41
+
42
42
@ After
43
43
public void reset () {
44
- LoggingSystem .get (getClass ().getClassLoader ()).setLogLevel ("org.springframework.web" , LogLevel .INFO );
44
+ LoggingSystem .get (getClass ().getClassLoader ())
45
+ .setLogLevel ("org.springframework.web" , LogLevel .INFO );
45
46
}
46
47
47
48
@ Test
48
49
public void logLevelsChanged () {
49
- assertFalse (logger .isTraceEnabled ());
50
+ assertFalse (this .logger .isTraceEnabled ());
51
+ StandardEnvironment environment = new StandardEnvironment ();
52
+ EnvironmentTestUtils .addEnvironment (environment ,
53
+ "logging.level.org.springframework.web=TRACE" );
54
+ this .rebinder .setEnvironment (environment );
55
+ this .rebinder .onApplicationEvent (new EnvironmentChangeEvent (
56
+ Collections .singleton ("logging.level.org.springframework.web" )));
57
+ assertTrue (this .logger .isTraceEnabled ());
58
+ }
59
+
60
+ @ Test
61
+ public void logLevelsLowerCase () {
62
+ assertFalse (this .logger .isTraceEnabled ());
50
63
StandardEnvironment environment = new StandardEnvironment ();
51
- EnvironmentTestUtils .addEnvironment (environment , "logging.level.org.springframework.web=TRACE" );
52
- rebinder .setEnvironment (environment );
53
- rebinder .onApplicationEvent (new EnvironmentChangeEvent (Collections .singleton ("logging.level.org.springframework.web" )));
54
- assertTrue (logger .isTraceEnabled ());
64
+ EnvironmentTestUtils .addEnvironment (environment ,
65
+ "logging.level.org.springframework.web=trace" );
66
+ this .rebinder .setEnvironment (environment );
67
+ this .rebinder .onApplicationEvent (new EnvironmentChangeEvent (
68
+ Collections .singleton ("logging.level.org.springframework.web" )));
69
+ assertTrue (this .logger .isTraceEnabled ());
55
70
}
56
71
57
72
}
0 commit comments