16
16
*/
17
17
package org .apache .logging .log4j .taglib ;
18
18
19
- import static org .junit .Assert .assertEquals ;
19
+ import static org .junit .jupiter . api . Assertions .assertEquals ;
20
20
21
21
import javax .servlet .jsp .tagext .Tag ;
22
22
import org .apache .logging .log4j .Level ;
23
23
import org .apache .logging .log4j .Logger ;
24
24
import org .apache .logging .log4j .MarkerManager ;
25
- import org .apache .logging .log4j .core .test . junit . LoggerContextRule ;
26
- import org .junit .Before ;
27
- import org .junit .ClassRule ;
28
- import org .junit .Test ;
25
+ import org .apache .logging .log4j .core .LoggerContext ;
26
+ import org .apache . logging . log4j . core . test . junit .LoggerContextSource ;
27
+ import org .junit .jupiter . api . BeforeEach ;
28
+ import org .junit .jupiter . api . Test ;
29
29
import org .springframework .mock .web .MockPageContext ;
30
30
31
31
/**
32
32
*
33
33
*/
34
+ @ LoggerContextSource ("log4j-test1.xml" )
34
35
public class IfEnabledTagTest {
35
- private static final String CONFIG = "log4j-test1.xml" ;
36
36
37
- @ ClassRule
38
- public static LoggerContextRule context = new LoggerContextRule (CONFIG );
39
-
40
- private final Logger logger = context .getLogger ("IfEnabledTagTest" );
37
+ private final Logger logger ;
41
38
private IfEnabledTag tag ;
42
39
43
- @ Before
40
+ public IfEnabledTagTest (final LoggerContext context ) {
41
+ this .logger = context .getLogger ("IfEnabledTagTest" );
42
+ }
43
+
44
+ @ BeforeEach
44
45
public void setUp () {
45
46
this .tag = new IfEnabledTag ();
46
47
this .tag .setPageContext (new MockPageContext ());
@@ -51,59 +52,59 @@ public void setUp() {
51
52
public void testDoStartTagEnabledString () throws Exception {
52
53
this .tag .setLevel ("warn" );
53
54
54
- assertEquals ("The return value is not correct." , Tag . EVAL_BODY_INCLUDE , this . tag . doStartTag () );
55
+ assertEquals (Tag . EVAL_BODY_INCLUDE , this . tag . doStartTag (), "The return value is not correct." );
55
56
}
56
57
57
58
@ Test
58
59
public void testDoStartTagEnabledLevel () throws Exception {
59
60
this .tag .setLevel (Level .WARN );
60
61
61
- assertEquals ("The return value is not correct." , Tag . EVAL_BODY_INCLUDE , this . tag . doStartTag () );
62
+ assertEquals (Tag . EVAL_BODY_INCLUDE , this . tag . doStartTag (), "The return value is not correct." );
62
63
}
63
64
64
65
@ Test
65
66
public void testDoStartTagEnabledStringMarker () throws Exception {
66
67
this .tag .setMarker (MarkerManager .getMarker ("E01" ));
67
68
this .tag .setLevel ("error" );
68
69
69
- assertEquals ("The return value is not correct." , Tag . EVAL_BODY_INCLUDE , this . tag . doStartTag () );
70
+ assertEquals (Tag . EVAL_BODY_INCLUDE , this . tag . doStartTag (), "The return value is not correct." );
70
71
}
71
72
72
73
@ Test
73
74
public void testDoStartTagEnabledLevelMarker () throws Exception {
74
75
this .tag .setMarker (MarkerManager .getMarker ("F02" ));
75
76
this .tag .setLevel (Level .ERROR );
76
77
77
- assertEquals ("The return value is not correct." , Tag . EVAL_BODY_INCLUDE , this . tag . doStartTag () );
78
+ assertEquals (Tag . EVAL_BODY_INCLUDE , this . tag . doStartTag (), "The return value is not correct." );
78
79
}
79
80
80
81
@ Test
81
82
public void testDoStartTagDisabledString () throws Exception {
82
83
this .tag .setLevel ("info" );
83
84
84
- assertEquals ("The return value is not correct." , Tag . SKIP_BODY , this . tag . doStartTag () );
85
+ assertEquals (Tag . SKIP_BODY , this . tag . doStartTag (), "The return value is not correct." );
85
86
}
86
87
87
88
@ Test
88
89
public void testDoStartTagDisabledLevel () throws Exception {
89
90
this .tag .setLevel (Level .INFO );
90
91
91
- assertEquals ("The return value is not correct." , Tag . SKIP_BODY , this . tag . doStartTag () );
92
+ assertEquals (Tag . SKIP_BODY , this . tag . doStartTag (), "The return value is not correct." );
92
93
}
93
94
94
95
@ Test
95
96
public void testDoStartTagDisabledStringMarker () throws Exception {
96
97
this .tag .setMarker (MarkerManager .getMarker ("E01" ));
97
98
this .tag .setLevel ("trace" );
98
99
99
- assertEquals ("The return value is not correct." , Tag . SKIP_BODY , this . tag . doStartTag () );
100
+ assertEquals (Tag . SKIP_BODY , this . tag . doStartTag (), "The return value is not correct." );
100
101
}
101
102
102
103
@ Test
103
104
public void testDoStartTagDisabledLevelMarker () throws Exception {
104
105
this .tag .setMarker (MarkerManager .getMarker ("F02" ));
105
106
this .tag .setLevel (Level .TRACE );
106
107
107
- assertEquals ("The return value is not correct." , Tag . SKIP_BODY , this . tag . doStartTag () );
108
+ assertEquals (Tag . SKIP_BODY , this . tag . doStartTag (), "The return value is not correct." );
108
109
}
109
110
}
0 commit comments