55
66import java .util .logging .Logger ;
77
8- import org .junit .jupiter .api .BeforeEach ;
98import org .junit .jupiter .api .Test ;
109
1110class 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- }
1911
2012 @ Test
2113 void testCapturingLogMessage () {
2214 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 ));
2520 }
2621
2722 @ Test
28- void testReset () {
23+ void testClose () {
2924 final String messageToBeIngored = "Ignore this!" ;
3025 final String messageToBeCaptured = "Capture that!" ;
3126 final Logger logger = Logger .getLogger ("com.exasol" );
27+ final CapturingLogHandler capturingLogHandler = new CapturingLogHandler ();
28+ Logger .getLogger ("com.exasol" ).addHandler (capturingLogHandler );
3229 logger .info (messageToBeIngored );
33- this . capturingLogHandler .reset ();
30+ capturingLogHandler .close ();
3431 logger .info (messageToBeCaptured );
35- assertThat (this . capturingLogHandler .getCapturedData (), equalTo (messageToBeCaptured ));
32+ assertThat (capturingLogHandler .getCapturedData (), equalTo (messageToBeCaptured ));
3633 }
3734}
0 commit comments