Skip to content

Commit 259fdb8

Browse files
committed
#280: Testing close() function.
Task-Url: exasol/virtual-schemas#280
1 parent fb79ccc commit 259fdb8

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/test/java/com/exasol/logging/CapturingLogHandlerTest.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,30 @@
55

66
import java.util.logging.Logger;
77

8-
import org.junit.jupiter.api.BeforeEach;
98
import org.junit.jupiter.api.Test;
109

1110
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-
}
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

Comments
 (0)