| 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.Retention;
|
|---|
| 6 | import java.lang.annotation.RetentionPolicy;
|
|---|
| 7 | import java.lang.annotation.Target;
|
|---|
| 8 |
|
|---|
| 9 | import org.junit.jupiter.api.extension.AfterEachCallback;
|
|---|
| 10 | import org.junit.jupiter.api.extension.BeforeEachCallback;
|
|---|
| 11 | import org.junit.jupiter.api.extension.ExtendWith;
|
|---|
| 12 | import org.junit.jupiter.api.extension.ExtensionContext;
|
|---|
| 13 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
|---|
| 14 |
|
|---|
| 15 | /**
|
|---|
| 16 | * Clear the main {@link org.openstreetmap.josm.gui.layer.LayerManager} between tests.
|
|---|
| 17 | * <br />
|
|---|
| 18 | * You shouldn't have to register this -- it should be run automatically by the JUnit 5 test environment.
|
|---|
| 19 | * See <a href="https://junit.org/junit5/docs/current/user-guide/#extensions-registration-automatic">
|
|---|
| 20 | * Automatic Extension Registration
|
|---|
| 21 | * </a> for more information.
|
|---|
| 22 | */
|
|---|
| 23 | @Target({ElementType.TYPE, ElementType.METHOD})
|
|---|
| 24 | @Retention(RetentionPolicy.RUNTIME)
|
|---|
| 25 | @ExtendWith(LayerManager.LayerManagerExtension.class)
|
|---|
| 26 | public @interface LayerManager {
|
|---|
| 27 | /**
|
|---|
| 28 | * Clean the layer environment
|
|---|
| 29 | */
|
|---|
| 30 | class LayerManagerExtension implements BeforeEachCallback, AfterEachCallback {
|
|---|
| 31 | @Override
|
|---|
| 32 | public void afterEach(ExtensionContext context) {
|
|---|
| 33 | JOSMTestRules.cleanLayerEnvironment();
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | @Override
|
|---|
| 37 | public void beforeEach(ExtensionContext context) {
|
|---|
| 38 | this.afterEach(context);
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|