5
5
6
6
import java .util .logging .Logger ;
7
7
8
- import org .junit .jupiter .api .BeforeEach ;
9
8
import org .junit .jupiter .api .Test ;
10
9
11
10
class CapturingLogHandlerTest {
12
- private final CapturingLogHandler capturingLogHandler = new CapturingLogHandler ();
13
-
14
- @ BeforeEach
15
- void beforeEach () {
16
- Logger .getLogger ("com.exasol" ).addHandler (this .capturingLogHandler );
17
- this .capturingLogHandler .reset ();
18
- }
19
11
20
12
@ Test
21
13
void testCapturingLogMessage () {
22
14
final String messageToBeCaptured = "Capture this!" ;
23
- Logger .getLogger ("com.exasol" ).info (messageToBeCaptured );
24
- assertThat (this .capturingLogHandler .getCapturedData (), equalTo (messageToBeCaptured ));
15
+ final Logger logger = Logger .getLogger ("com.exasol" );
16
+ final CapturingLogHandler capturingLogHandler = new CapturingLogHandler ();
17
+ Logger .getLogger ("com.exasol" ).addHandler (capturingLogHandler );
18
+ logger .info (messageToBeCaptured );
19
+ assertThat (capturingLogHandler .getCapturedData (), equalTo (messageToBeCaptured ));
25
20
}
26
21
27
22
@ Test
28
- void testReset () {
23
+ void testClose () {
29
24
final String messageToBeIngored = "Ignore this!" ;
30
25
final String messageToBeCaptured = "Capture that!" ;
31
26
final Logger logger = Logger .getLogger ("com.exasol" );
27
+ final CapturingLogHandler capturingLogHandler = new CapturingLogHandler ();
28
+ Logger .getLogger ("com.exasol" ).addHandler (capturingLogHandler );
32
29
logger .info (messageToBeIngored );
33
- this . capturingLogHandler .reset ();
30
+ capturingLogHandler .close ();
34
31
logger .info (messageToBeCaptured );
35
- assertThat (this . capturingLogHandler .getCapturedData (), equalTo (messageToBeCaptured ));
32
+ assertThat (capturingLogHandler .getCapturedData (), equalTo (messageToBeCaptured ));
36
33
}
37
34
}
0 commit comments