source: josm/trunk/test/unit/org/openstreetmap/josm/testutils/annotations/LayerManager.java@ 18649

Last change on this file since 18649 was 18649, checked in by taylor.smock, 3 years ago

Fix #22712: ignore list doesn't work

This occurred due to OsmValidator#save modifying the list, and expecting
all error codes to be positive.

TestErrorTest now checks one of the tests known to have a negative hashcode.

This also adds some additional JUnit 5 annotations. The additional
annotations are:

  • @LayerManager (cleans up layers after each test run)
    • This is automatically registered for all tests
  • @Projection (sets up the ProjectionRegistry for each test)
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.testutils.annotations;
3
4import java.lang.annotation.ElementType;
5import java.lang.annotation.Retention;
6import java.lang.annotation.RetentionPolicy;
7import java.lang.annotation.Target;
8
9import org.junit.jupiter.api.extension.AfterEachCallback;
10import org.junit.jupiter.api.extension.BeforeEachCallback;
11import org.junit.jupiter.api.extension.ExtendWith;
12import org.junit.jupiter.api.extension.ExtensionContext;
13import 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)
26public @interface LayerManager {
27 class LayerManagerExtension implements BeforeEachCallback, AfterEachCallback {
28 @Override
29 public void afterEach(ExtensionContext context) {
30 JOSMTestRules.cleanLayerEnvironment();
31 }
32
33 @Override
34 public void beforeEach(ExtensionContext context) {
35 this.afterEach(context);
36 }
37 }
38}
Note: See TracBrowser for help on using the repository browser.