Last change
on this file since 18972 was 18972, checked in by taylor.smock, 3 months ago |
See #23465: Add additional javadoc comments
This also fixes some sonarlint issues
|
File size:
1.3 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.testutils.annotations;
|
---|
3 |
|
---|
4 | import java.lang.annotation.ElementType;
|
---|
5 | import java.lang.annotation.Target;
|
---|
6 | import java.util.logging.Handler;
|
---|
7 |
|
---|
8 | import org.junit.jupiter.api.extension.BeforeEachCallback;
|
---|
9 | import org.junit.jupiter.api.extension.ExtensionContext;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Reset logging for each test
|
---|
13 | */
|
---|
14 | @Target({ElementType.TYPE, ElementType.METHOD})
|
---|
15 | public @interface Logging {
|
---|
16 | /**
|
---|
17 | * Set up loggers for testing
|
---|
18 | */
|
---|
19 | class LoggingExtension implements BeforeEachCallback {
|
---|
20 |
|
---|
21 | @Override
|
---|
22 | public void beforeEach(ExtensionContext context) throws Exception {
|
---|
23 | // Force log handlers to reacquire reference to (junit's fake) stdout/stderr
|
---|
24 | for (Handler handler : org.openstreetmap.josm.tools.Logging.getLogger().getHandlers()) {
|
---|
25 | if (handler instanceof org.openstreetmap.josm.tools.Logging.ReacquiringConsoleHandler) {
|
---|
26 | handler.flush();
|
---|
27 | ((org.openstreetmap.josm.tools.Logging.ReacquiringConsoleHandler) handler).reacquireOutputStream();
|
---|
28 | }
|
---|
29 | }
|
---|
30 | // Set log level to info
|
---|
31 | org.openstreetmap.josm.tools.Logging.setLogLevel(org.openstreetmap.josm.tools.Logging.LEVEL_INFO);
|
---|
32 | }
|
---|
33 | }
|
---|
34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.