-
diff --git a/ivy.xml b/ivy.xml
index d6fa0b3232..30a8d98a4b 100644
|
a
|
b
|
|
| 60 | 60 | <dependency conf="test->default" org="com.github.tomakehurst" name="wiremock" rev="2.27.2"/> |
| 61 | 61 | <dependency conf="test->default" org="io.github.classgraph" name="classgraph" rev="4.8.110"/> |
| 62 | 62 | <dependency conf="test->default" org="org.junit.platform" name="junit-platform-launcher" rev="1.7.2"/> |
| | 63 | <dependency conf="test->default" org="org.junit.platform" name="junit-platform-suite-api" rev="1.7.2"/> |
| 63 | 64 | <dependency conf="test->default" org="org.junit.vintage" name="junit-vintage-engine" rev="5.7.2"/> |
| 64 | 65 | <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-params" rev="5.7.2"/> |
| 65 | 66 | <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-api" rev="5.7.2"/> |
-
diff --git a/test/functional/org/openstreetmap/josm/data/BoundariesTestIT.java b/test/functional/org/openstreetmap/josm/data/BoundariesTestIT.java
index d4734744a8..c3ffd340e0 100644
|
a
|
b
|
import org.openstreetmap.josm.io.OsmReader;
|
| 19 | 19 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 20 | 20 | |
| 21 | 21 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 22 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * Test of boundaries OSM file. |
| 25 | 26 | */ |
| | 27 | @IntegrationTest |
| 26 | 28 | class BoundariesTestIT { |
| 27 | 29 | |
| 28 | 30 | private static final List<String> RETIRED_ISO3166_1_CODES = Arrays.asList( |
-
diff --git a/test/functional/org/openstreetmap/josm/data/imagery/ImageryCompareTestIT.java b/test/functional/org/openstreetmap/josm/data/imagery/ImageryCompareTestIT.java
index 60ca4fbcee..ea2467d52e 100644
|
a
|
b
|
import static org.junit.jupiter.api.Assertions.fail;
|
| 6 | 6 | import java.net.URL; |
| 7 | 7 | |
| 8 | 8 | import org.junit.jupiter.api.Test; |
| 9 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| | 9 | import org.junit.jupiter.api.Timeout; |
| 10 | 10 | import org.openstreetmap.josm.spi.preferences.Config; |
| 11 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 11 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 12 | import org.openstreetmap.josm.testutils.annotations.HTTP; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 12 | 14 | import org.openstreetmap.josm.tools.HttpClient; |
| 13 | 15 | |
| 14 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 15 | | |
| 16 | 16 | /** |
| 17 | 17 | * Automatic test of imagery synchronization between JOSM and ELI. |
| 18 | 18 | * See <a href="https://josm.openstreetmap.de/wiki/ImageryCompare">JOSM wiki</a> |
| 19 | 19 | */ |
| | 20 | @IntegrationTest |
| | 21 | @Timeout(20) |
| | 22 | @HTTP |
| | 23 | @BasicPreferences |
| 20 | 24 | class ImageryCompareTestIT { |
| 21 | 25 | |
| 22 | 26 | private static final String BLACK_PREFIX = "<pre style=\"margin:3px;color:black\">"; |
| 23 | 27 | private static final String RED_PREFIX = "<pre style=\"margin:3px;color:red\">"; |
| 24 | 28 | |
| 25 | | /** |
| 26 | | * Setup test. |
| 27 | | */ |
| 28 | | @RegisterExtension |
| 29 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 30 | | public JOSMTestRules test = new JOSMTestRules().preferences().timeout(60000); |
| 31 | | |
| 32 | 29 | /** |
| 33 | 30 | * Test of imagery entries. |
| 34 | 31 | * @throws Exception if an error occurs |
-
diff --git a/test/functional/org/openstreetmap/josm/data/osm/TaginfoTestIT.java b/test/functional/org/openstreetmap/josm/data/osm/TaginfoTestIT.java
index d153334831..2c97e062dd 100644
|
a
|
b
|
import javax.json.JsonReader;
|
| 15 | 15 | import javax.json.JsonValue; |
| 16 | 16 | |
| 17 | 17 | import org.junit.jupiter.api.Test; |
| 18 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| | 18 | import org.junit.jupiter.api.Timeout; |
| 19 | 19 | import org.openstreetmap.josm.data.coor.LatLon; |
| 20 | 20 | import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; |
| 21 | 21 | import org.openstreetmap.josm.data.validation.tests.TagChecker; |
| 22 | 22 | import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException; |
| 23 | 23 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; |
| 24 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 24 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 25 | import org.openstreetmap.josm.testutils.annotations.HTTP; |
| | 26 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 25 | 27 | import org.openstreetmap.josm.tools.HttpClient; |
| 26 | 28 | import org.xml.sax.SAXException; |
| 27 | 29 | |
| 28 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 29 | | |
| 30 | 30 | /** |
| 31 | 31 | * Various integration tests with Taginfo. |
| 32 | 32 | */ |
| | 33 | @Timeout(value = 20) |
| | 34 | @BasicPreferences |
| | 35 | @HTTP |
| | 36 | @IntegrationTest |
| 33 | 37 | class TaginfoTestIT { |
| 34 | | |
| 35 | | /** |
| 36 | | * Setup test. |
| 37 | | */ |
| 38 | | @RegisterExtension |
| 39 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 40 | | public JOSMTestRules test = new JOSMTestRules().preferences().timeout(20000); |
| 41 | | |
| 42 | 38 | /** |
| 43 | 39 | * Checks that popular tags are known (i.e included in internal presets, or deprecated, or explicitely ignored) |
| 44 | 40 | * @throws SAXException if any XML parsing error occurs |
-
diff --git a/test/functional/org/openstreetmap/josm/gui/GettingStartedTest.java b/test/functional/org/openstreetmap/josm/gui/GettingStartedTest.java
index 6c7a9ed0db..ddf273d32e 100644
|
a
|
b
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
| 5 | 5 | |
| 6 | 6 | import java.io.IOException; |
| 7 | 7 | |
| 8 | | import org.junit.jupiter.api.Test; |
| 9 | | import org.junit.jupiter.api.BeforeAll; |
| 10 | 8 | import org.junit.jupiter.api.Disabled; |
| 11 | | import org.openstreetmap.josm.JOSMFixture; |
| | 9 | import org.junit.jupiter.api.Test; |
| | 10 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 11 | import org.openstreetmap.josm.testutils.annotations.HTTP; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Tests the {@link GettingStarted} class. |
| 15 | 15 | */ |
| | 16 | @BasicPreferences |
| | 17 | @HTTP |
| 16 | 18 | class GettingStartedTest { |
| 17 | 19 | |
| 18 | | /** |
| 19 | | * Setup test. |
| 20 | | */ |
| 21 | | @BeforeAll |
| 22 | | public static void init() { |
| 23 | | JOSMFixture.createFunctionalTestFixture().init(); |
| 24 | | } |
| 25 | | |
| 26 | 20 | /** |
| 27 | 21 | * Tests that image links are replaced. |
| 28 | 22 | * |
-
diff --git a/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java b/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java
index 97afd4d5b9..da4507b0be 100644
|
a
|
b
|
public class MapCSSRendererTest {
|
| 64 | 64 | */ |
| 65 | 65 | @RegisterExtension |
| 66 | 66 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 67 | | public JOSMTestRules test = new JOSMTestRules().preferences().projection(); |
| | 67 | public JOSMTestRules test = new JOSMTestRules().projection(); |
| 68 | 68 | |
| 69 | 69 | // development flag - set to true in order to update all reference images |
| 70 | 70 | private static final boolean UPDATE_ALL = false; |
-
diff --git a/test/functional/org/openstreetmap/josm/gui/mappaint/StyleCacheTest.java b/test/functional/org/openstreetmap/josm/gui/mappaint/StyleCacheTest.java
index 6bd117d1dc..59dc91df17 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
| 28 | 28 | import org.openstreetmap.josm.io.Compression; |
| 29 | 29 | import org.openstreetmap.josm.io.OsmReader; |
| 30 | 30 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 31 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 31 | 32 | import org.openstreetmap.josm.tools.Pair; |
| 32 | 33 | |
| 33 | 34 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 35 | 36 | /** |
| 36 | 37 | * Test {@link StyleCache}. |
| 37 | 38 | */ |
| | 39 | @BasicPreferences |
| 38 | 40 | class StyleCacheTest { |
| 39 | 41 | |
| 40 | 42 | private static final int IMG_WIDTH = 1400; |
| … |
… |
class StyleCacheTest {
|
| 51 | 53 | */ |
| 52 | 54 | @RegisterExtension |
| 53 | 55 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 54 | | public JOSMTestRules test = new JOSMTestRules().main().preferences().projection().mapStyles().timeout(60000); |
| | 56 | public JOSMTestRules test = new JOSMTestRules().main().projection().mapStyles().timeout(60000); |
| 55 | 57 | |
| 56 | 58 | /** |
| 57 | 59 | * Load the test data that is required. |
-
diff --git a/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java b/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
index f5ac350e3d..f8f9045f95 100644
|
a
|
b
|
import org.junit.jupiter.api.BeforeAll;
|
| 29 | 29 | import org.junit.jupiter.api.BeforeEach; |
| 30 | 30 | import org.junit.jupiter.api.Test; |
| 31 | 31 | import org.junit.jupiter.api.Timeout; |
| 32 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| 33 | | import org.openstreetmap.josm.JOSMFixture; |
| 34 | 32 | import org.openstreetmap.josm.TestUtils; |
| 35 | 33 | import org.openstreetmap.josm.data.coor.LatLon; |
| 36 | 34 | import org.openstreetmap.josm.data.osm.Changeset; |
| … |
… |
import org.openstreetmap.josm.data.osm.RelationMember;
|
| 43 | 41 | import org.openstreetmap.josm.data.osm.Way; |
| 44 | 42 | import org.openstreetmap.josm.gui.progress.NullProgressMonitor; |
| 45 | 43 | import org.openstreetmap.josm.spi.preferences.Config; |
| 46 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 44 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 45 | import org.openstreetmap.josm.testutils.annotations.Main; |
| | 46 | import org.openstreetmap.josm.testutils.annotations.OsmApiType; |
| 47 | 47 | |
| 48 | 48 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 49 | 49 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 52 | 52 | */ |
| 53 | 53 | @SuppressFBWarnings(value = "CRLF_INJECTION_LOGS") |
| 54 | 54 | @Timeout(value = 60, unit = TimeUnit.SECONDS) |
| | 55 | @BasicPreferences |
| | 56 | @OsmApiType(OsmApiType.APIType.DEV) |
| | 57 | @Main |
| 55 | 58 | class MultiFetchServerObjectReaderTest { |
| 56 | 59 | private static final Logger logger = Logger.getLogger(MultiFetchServerObjectReader.class.getName()); |
| 57 | 60 | |
| 58 | | /** |
| 59 | | * Setup test. |
| 60 | | */ |
| 61 | | @RegisterExtension |
| 62 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 63 | | public JOSMTestRules test = new JOSMTestRules().preferences(); |
| 64 | | |
| 65 | 61 | /** |
| 66 | 62 | * builds a large data set to be used later for testing MULTI FETCH on the server |
| 67 | 63 | * |
| … |
… |
class MultiFetchServerObjectReaderTest {
|
| 163 | 159 | return; |
| 164 | 160 | } |
| 165 | 161 | logger.info("initializing ..."); |
| 166 | | JOSMFixture.createFunctionalTestFixture().init(); |
| 167 | 162 | |
| 168 | 163 | Config.getPref().put("osm-server.auth-method", "basic"); |
| 169 | 164 | |
-
diff --git a/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java b/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
index 15cca85efe..39227ad8e3 100644
|
a
|
b
|
import java.util.logging.Logger;
|
| 25 | 25 | import org.junit.jupiter.api.BeforeAll; |
| 26 | 26 | import org.junit.jupiter.api.BeforeEach; |
| 27 | 27 | import org.junit.jupiter.api.Test; |
| 28 | | import org.openstreetmap.josm.JOSMFixture; |
| 29 | 28 | import org.openstreetmap.josm.TestUtils; |
| 30 | 29 | import org.openstreetmap.josm.data.APIDataSet; |
| 31 | 30 | import org.openstreetmap.josm.data.coor.LatLon; |
| … |
… |
import org.openstreetmap.josm.data.projection.ProjectionRegistry;
|
| 42 | 41 | import org.openstreetmap.josm.data.projection.Projections; |
| 43 | 42 | import org.openstreetmap.josm.gui.progress.NullProgressMonitor; |
| 44 | 43 | import org.openstreetmap.josm.spi.preferences.Config; |
| | 44 | import org.openstreetmap.josm.testutils.annotations.FullPreferences; |
| | 45 | import org.openstreetmap.josm.testutils.annotations.OsmApiType; |
| 45 | 46 | import org.openstreetmap.josm.tools.Logging; |
| 46 | 47 | |
| 47 | 48 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 51 | 52 | * @since 1806 |
| 52 | 53 | */ |
| 53 | 54 | @SuppressFBWarnings(value = "CRLF_INJECTION_LOGS") |
| | 55 | @FullPreferences |
| | 56 | @OsmApiType(OsmApiType.APIType.DEV) |
| 54 | 57 | class OsmServerBackreferenceReaderTest { |
| 55 | 58 | private static final Logger logger = Logger.getLogger(OsmServerBackreferenceReader.class.getName()); |
| 56 | 59 | |
| … |
… |
class OsmServerBackreferenceReaderTest {
|
| 165 | 168 | } |
| 166 | 169 | logger.info("initializing ..."); |
| 167 | 170 | |
| 168 | | JOSMFixture.createFunctionalTestFixture().init(); |
| 169 | | |
| 170 | 171 | Config.getPref().put("osm-server.auth-method", "basic"); |
| 171 | 172 | |
| 172 | 173 | // don't use atomic upload, the test API server can't cope with large diff uploads |
-
diff --git a/test/functional/org/openstreetmap/josm/tools/ImageProviderTestIT.java b/test/functional/org/openstreetmap/josm/tools/ImageProviderTestIT.java
index 16be1d91c9..9904953772 100644
|
a
|
b
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
| 8 | 8 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 9 | 9 | |
| 10 | 10 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 11 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * Integration tests of {@link ImageProvider} class. |
| 14 | 15 | */ |
| | 16 | @IntegrationTest |
| 15 | 17 | class ImageProviderTestIT { |
| 16 | 18 | |
| 17 | 19 | /** |
-
diff --git a/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java b/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java
index fe040014b8..5cb6a2bdb8 100644
|
a
|
b
|
import org.openstreetmap.josm.io.Compression;
|
| 26 | 26 | import org.openstreetmap.josm.io.OsmReader; |
| 27 | 27 | |
| 28 | 28 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 29 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 29 | 30 | |
| 30 | 31 | /** |
| 31 | 32 | * Abstract superclass of {@code StyledMapRendererPerformanceTest} and {@code WireframeMapRendererPerformanceTest}. |
| 32 | 33 | */ |
| 33 | | @Timeout(value = 15*60, unit = TimeUnit.SECONDS) |
| | 34 | @Timeout(value = 15, unit = TimeUnit.MINUTES) |
| | 35 | @BasicPreferences |
| 34 | 36 | abstract class AbstractMapRendererPerformanceTestParent { |
| 35 | 37 | |
| 36 | 38 | private static final int IMG_WIDTH = 1400; |
-
diff --git a/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java b/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java
index ded650f02e..f95fc24e6f 100644
|
a
|
b
|
import org.junit.jupiter.api.BeforeAll;
|
| 11 | 11 | import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; |
| 12 | 12 | |
| 13 | 13 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 14 | import org.openstreetmap.josm.testutils.annotations.FullPreferences; |
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * Performance test of {@code StyledMapRenderer}. |
| 17 | 18 | */ |
| | 19 | @FullPreferences |
| 18 | 20 | class StyledMapRendererPerformanceTest extends AbstractMapRendererPerformanceTestParent { |
| 19 | 21 | |
| 20 | 22 | @BeforeAll |
-
diff --git a/test/performance/org/openstreetmap/josm/data/validation/ValidationTaskPerformanceTest.java b/test/performance/org/openstreetmap/josm/data/validation/ValidationTaskPerformanceTest.java
index 25d9295d12..d4311a6ba0 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.data.validation; |
| 3 | 3 | |
| | 4 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| | 5 | |
| | 6 | import java.util.Collection; |
| | 7 | import java.util.List; |
| | 8 | import java.util.stream.Collectors; |
| | 9 | |
| 4 | 10 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 5 | 11 | import org.junit.jupiter.api.BeforeEach; |
| 6 | 12 | import org.junit.jupiter.api.Test; |
| … |
… |
import org.openstreetmap.josm.gui.MainApplication;
|
| 13 | 19 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 14 | 20 | import org.openstreetmap.josm.gui.progress.NullProgressMonitor; |
| 15 | 21 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 16 | | |
| 17 | | import java.util.Collection; |
| 18 | | import java.util.List; |
| 19 | | import java.util.stream.Collectors; |
| 20 | | |
| 21 | | import static org.junit.jupiter.api.Assertions.assertTrue; |
| | 22 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * Performance test of {@code ValidationTask}. |
| 25 | 26 | */ |
| | 27 | @BasicPreferences |
| 26 | 28 | class ValidationTaskPerformanceTest { |
| 27 | 29 | |
| 28 | 30 | private List<org.openstreetmap.josm.data.validation.Test> tests; |
| … |
… |
class ValidationTaskPerformanceTest {
|
| 32 | 34 | */ |
| 33 | 35 | @RegisterExtension |
| 34 | 36 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 35 | | public JOSMTestRules test = new JOSMTestRules().projection().territories().preferences(); |
| | 37 | public JOSMTestRules test = new JOSMTestRules().projection().territories(); |
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * Setup test. |
-
diff --git a/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java b/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java
index 430740e618..2171d88aa3 100644
|
a
|
b
|
import java.util.EnumMap;
|
| 16 | 16 | import java.util.List; |
| 17 | 17 | import java.util.Locale; |
| 18 | 18 | import java.util.Map; |
| | 19 | import java.util.concurrent.TimeUnit; |
| 19 | 20 | import java.util.stream.Collectors; |
| 20 | 21 | |
| 21 | 22 | import javax.imageio.ImageIO; |
| 22 | 23 | |
| | 24 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 23 | 25 | import org.junit.Assert; |
| 24 | 26 | import org.junit.jupiter.api.AfterAll; |
| 25 | 27 | import org.junit.jupiter.api.BeforeAll; |
| 26 | 28 | import org.junit.jupiter.api.Test; |
| | 29 | import org.junit.jupiter.api.Timeout; |
| 27 | 30 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 28 | | import org.openstreetmap.josm.JOSMFixture; |
| 29 | 31 | import org.openstreetmap.josm.PerformanceTestUtils; |
| 30 | 32 | import org.openstreetmap.josm.TestUtils; |
| 31 | 33 | import org.openstreetmap.josm.data.Bounds; |
| … |
… |
import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
|
| 43 | 45 | import org.openstreetmap.josm.gui.mappaint.mapcss.Selector; |
| 44 | 46 | import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement; |
| 45 | 47 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 46 | | |
| 47 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 48 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 48 | 49 | |
| 49 | 50 | /** |
| 50 | 51 | * Performance test of map renderer. |
| 51 | 52 | */ |
| | 53 | @Timeout(value = 15, unit = TimeUnit.MINUTES) |
| | 54 | @BasicPreferences |
| 52 | 55 | public class MapRendererPerformanceTest { |
| 53 | 56 | |
| 54 | 57 | private static final boolean DUMP_IMAGE = false; // dump images to file for debugging purpose |
| … |
… |
public class MapRendererPerformanceTest {
|
| 84 | 87 | */ |
| 85 | 88 | @RegisterExtension |
| 86 | 89 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 87 | | public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection().preferences().timeout(15 * 60 * 1000); |
| | 90 | public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection(); |
| 88 | 91 | |
| 89 | 92 | /** |
| 90 | 93 | * Initializes test environment. |
| … |
… |
public class MapRendererPerformanceTest {
|
| 92 | 95 | */ |
| 93 | 96 | @BeforeAll |
| 94 | 97 | public static void load() throws Exception { |
| 95 | | JOSMFixture.createPerformanceTestFixture().init(true); |
| 96 | | |
| 97 | 98 | img = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_INT_ARGB); |
| 98 | 99 | g = (Graphics2D) img.getGraphics(); |
| 99 | 100 | g.setClip(0, 0, IMG_WIDTH, IMG_HEIGHT); |
-
diff --git a/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.java b/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.java
index 504daea82d..1b79dc4de3 100644
|
a
|
b
|
import java.io.IOException;
|
| 10 | 10 | import java.util.Collection; |
| 11 | 11 | |
| 12 | 12 | import org.junit.jupiter.api.Test; |
| 13 | | import org.junit.jupiter.api.BeforeAll; |
| 14 | | import org.openstreetmap.josm.JOSMFixture; |
| 15 | 13 | import org.openstreetmap.josm.PerformanceTestUtils; |
| 16 | 14 | import org.openstreetmap.josm.data.Bounds; |
| 17 | 15 | import org.openstreetmap.josm.data.osm.DataSet; |
| … |
… |
import org.openstreetmap.josm.data.preferences.sources.SourceType;
|
| 21 | 19 | import org.openstreetmap.josm.gui.NavigatableComponent; |
| 22 | 20 | import org.openstreetmap.josm.gui.mappaint.MapRendererPerformanceTest; |
| 23 | 21 | import org.openstreetmap.josm.io.IllegalDataException; |
| | 22 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 24 | 23 | |
| 25 | 24 | /** |
| 26 | 25 | * This performance test measures the time for a full run of MapPaintVisitor.visitAll() |
| 27 | 26 | * against a test data set using a test style. |
| 28 | 27 | * |
| 29 | 28 | */ |
| | 29 | @BasicPreferences |
| 30 | 30 | class MapCSSPerformanceTest { |
| 31 | 31 | |
| 32 | 32 | /* ------------------------ configuration section ---------------------------- */ |
| … |
… |
class MapCSSPerformanceTest {
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | | /** |
| 51 | | * Setup test. |
| 52 | | */ |
| 53 | | @BeforeAll |
| 54 | | public static void createJOSMFixture() { |
| 55 | | JOSMFixture.createPerformanceTestFixture().init(true); |
| 56 | | } |
| 57 | | |
| 58 | 50 | long timed(Runnable callable) { |
| 59 | 51 | long before = System.currentTimeMillis(); |
| 60 | 52 | callable.run(); |
-
diff --git a/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterTest.java b/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterTest.java
index 21241668dd..073d720f06 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.mappaint.mapcss;
|
| 3 | 3 | |
| 4 | 4 | import java.util.concurrent.TimeUnit; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | 7 | import org.junit.jupiter.api.Timeout; |
| 9 | | import org.openstreetmap.josm.JOSMFixture; |
| 10 | 8 | import org.openstreetmap.josm.PerformanceTestUtils; |
| 11 | 9 | import org.openstreetmap.josm.PerformanceTestUtils.PerformanceTestTimer; |
| 12 | 10 | import org.openstreetmap.josm.data.osm.OsmDataGenerator; |
| 13 | 11 | import org.openstreetmap.josm.data.osm.OsmDataGenerator.KeyValueDataGenerator; |
| 14 | 12 | import org.openstreetmap.josm.gui.mappaint.MultiCascade; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 15 | 14 | |
| 16 | 15 | /** |
| 17 | 16 | * Tests how fast {@link MapCSSStyleSource} finds the right style candidates for one object. |
| 18 | 17 | * @author Michael Zangl |
| 19 | 18 | */ |
| 20 | | @Timeout(value = 15*60, unit = TimeUnit.SECONDS) |
| | 19 | @Timeout(value = 15, unit = TimeUnit.MINUTES) |
| | 20 | @BasicPreferences |
| 21 | 21 | class MapCSSStyleSourceFilterTest { |
| 22 | 22 | |
| 23 | 23 | private static final int TEST_RULE_COUNT = 10000; |
| … |
… |
class MapCSSStyleSourceFilterTest {
|
| 80 | 80 | |
| 81 | 81 | private static final int APPLY_CALLS = 100000; |
| 82 | 82 | |
| 83 | | /** |
| 84 | | * Prepare the test. |
| 85 | | */ |
| 86 | | @BeforeAll |
| 87 | | public static void createJOSMFixture() { |
| 88 | | JOSMFixture.createPerformanceTestFixture().init(true); |
| 89 | | } |
| 90 | | |
| 91 | 83 | /** |
| 92 | 84 | * Time how long it takes to evaluate [key=value] rules |
| 93 | 85 | */ |
-
diff --git a/test/performance/org/openstreetmap/josm/io/OsmReaderPerformanceTest.java b/test/performance/org/openstreetmap/josm/io/OsmReaderPerformanceTest.java
index e9a1a1c78f..542c88f275 100644
|
a
|
b
|
import java.io.IOException;
|
| 11 | 11 | import java.io.InputStream; |
| 12 | 12 | import java.util.concurrent.TimeUnit; |
| 13 | 13 | |
| 14 | | import org.junit.jupiter.api.BeforeAll; |
| 15 | 14 | import org.junit.jupiter.api.Test; |
| 16 | 15 | import org.junit.jupiter.api.Timeout; |
| 17 | | import org.openstreetmap.josm.JOSMFixture; |
| 18 | 16 | import org.openstreetmap.josm.PerformanceTestUtils; |
| 19 | 17 | import org.openstreetmap.josm.PerformanceTestUtils.PerformanceTestTimer; |
| 20 | 18 | import org.openstreetmap.josm.data.osm.DataSet; |
| | 19 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 21 | 20 | |
| 22 | 21 | /** |
| 23 | 22 | * This test tests how fast we are at reading an OSM file. |
| … |
… |
import org.openstreetmap.josm.data.osm.DataSet;
|
| 26 | 25 | * |
| 27 | 26 | * @author Michael Zangl |
| 28 | 27 | */ |
| 29 | | @Timeout(value = 15*60, unit = TimeUnit.SECONDS) |
| | 28 | @Timeout(value = 15, unit = TimeUnit.MINUTES) |
| | 29 | @BasicPreferences |
| 30 | 30 | class OsmReaderPerformanceTest { |
| 31 | 31 | private static final int TIMES = 4; |
| 32 | 32 | |
| 33 | | /** |
| 34 | | * Prepare the test. |
| 35 | | */ |
| 36 | | @BeforeAll |
| 37 | | public static void createJOSMFixture() { |
| 38 | | JOSMFixture.createPerformanceTestFixture().init(true); |
| 39 | | } |
| 40 | | |
| 41 | 33 | /** |
| 42 | 34 | * Simulates a plain read of a .osm.bz2 file (from memory) |
| 43 | 35 | * @throws Exception if an error occurs |
-
diff --git a/test/performance/org/openstreetmap/josm/io/OsmWriterPerformanceTest.java b/test/performance/org/openstreetmap/josm/io/OsmWriterPerformanceTest.java
index 8835650fe8..975a7a416e 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.io; |
| 3 | 3 | |
| 4 | | import org.junit.jupiter.api.BeforeAll; |
| | 4 | import java.io.PrintWriter; |
| | 5 | import java.io.StringWriter; |
| | 6 | import java.util.concurrent.TimeUnit; |
| | 7 | |
| 5 | 8 | import org.junit.jupiter.api.BeforeEach; |
| 6 | 9 | import org.junit.jupiter.api.Test; |
| 7 | 10 | import org.junit.jupiter.api.Timeout; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 11 | import org.openstreetmap.josm.PerformanceTestUtils; |
| 10 | 12 | import org.openstreetmap.josm.PerformanceTestUtils.PerformanceTestTimer; |
| 11 | 13 | import org.openstreetmap.josm.data.osm.DataSet; |
| 12 | | |
| 13 | | import java.io.PrintWriter; |
| 14 | | import java.io.StringWriter; |
| 15 | | import java.util.concurrent.TimeUnit; |
| | 14 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 16 | 15 | |
| 17 | 16 | /** |
| 18 | 17 | * This test tests how fast we are at writing an OSM file. |
| 19 | 18 | * <p> |
| 20 | 19 | * For this, we use the neubrandenburg-file, which is a good real world example of an OSM file. |
| 21 | 20 | */ |
| 22 | | @Timeout(value = 15*60, unit = TimeUnit.SECONDS) |
| | 21 | @Timeout(value = 15, unit = TimeUnit.MINUTES) |
| | 22 | @BasicPreferences |
| 23 | 23 | class OsmWriterPerformanceTest { |
| 24 | 24 | private static final int TIMES = 4; |
| 25 | 25 | private DataSet neubrandenburgDataSet; |
| 26 | 26 | |
| 27 | | /** |
| 28 | | * Prepare the test. |
| 29 | | */ |
| 30 | | @BeforeAll |
| 31 | | public static void createJOSMFixture() { |
| 32 | | JOSMFixture.createPerformanceTestFixture().init(true); |
| 33 | | } |
| 34 | | |
| 35 | 27 | /** |
| 36 | 28 | * Setup test |
| 37 | 29 | * @throws Exception if an error occurs |
-
diff --git a/test/unit/org/openstreetmap/josm/TestUtils.java b/test/unit/org/openstreetmap/josm/TestUtils.java
index c30e05388d..266ebe22f8 100644
|
a
|
b
|
import java.io.IOException;
|
| 16 | 16 | import java.io.InputStream; |
| 17 | 17 | import java.lang.reflect.Field; |
| 18 | 18 | import java.lang.reflect.Method; |
| | 19 | import java.net.Authenticator; |
| | 20 | import java.net.PasswordAuthentication; |
| 19 | 21 | import java.security.AccessController; |
| 20 | 22 | import java.security.PrivilegedAction; |
| 21 | 23 | import java.time.Instant; |
| … |
… |
import org.openstreetmap.josm.gui.progress.ProgressMonitor;
|
| 53 | 55 | import org.openstreetmap.josm.gui.progress.ProgressTaskId; |
| 54 | 56 | import org.openstreetmap.josm.gui.util.GuiHelper; |
| 55 | 57 | import org.openstreetmap.josm.io.Compression; |
| | 58 | import org.openstreetmap.josm.io.OsmApi; |
| | 59 | import org.openstreetmap.josm.io.auth.CredentialsAgentException; |
| | 60 | import org.openstreetmap.josm.io.auth.JosmPreferencesCredentialAgent; |
| 56 | 61 | import org.openstreetmap.josm.testutils.FakeGraphics; |
| 57 | 62 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 58 | 63 | import org.openstreetmap.josm.testutils.mockers.WindowMocker; |
| 59 | 64 | import org.openstreetmap.josm.tools.JosmRuntimeException; |
| | 65 | import org.openstreetmap.josm.tools.Logging; |
| 60 | 66 | import org.openstreetmap.josm.tools.ReflectionUtils; |
| 61 | 67 | import org.openstreetmap.josm.tools.Utils; |
| 62 | 68 | import org.openstreetmap.josm.tools.WikiReader; |
| 63 | 69 | |
| 64 | 70 | import com.github.tomakehurst.wiremock.WireMockServer; |
| 65 | 71 | import com.github.tomakehurst.wiremock.core.WireMockConfiguration; |
| 66 | | |
| 67 | 72 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 68 | 73 | import io.github.classgraph.ClassGraph; |
| 69 | 74 | import io.github.classgraph.ClassInfoList; |
| … |
… |
public final class TestUtils {
|
| 646 | 651 | * @return {@code true} if {@code osm.username} and {@code osm.password} have been defined on the command line |
| 647 | 652 | */ |
| 648 | 653 | public static boolean areCredentialsProvided() { |
| 649 | | return Utils.getSystemProperty("osm.username") != null && Utils.getSystemProperty("osm.password") != null; |
| | 654 | final String username = Utils.getSystemProperty("osm.username"); |
| | 655 | final String password = Utils.getSystemProperty("osm.password"); |
| | 656 | if (username != null && password != null) { |
| | 657 | try { |
| | 658 | new JosmPreferencesCredentialAgent().store(Authenticator.RequestorType.SERVER, |
| | 659 | OsmApi.getOsmApi().getHost(), new PasswordAuthentication(username, password.toCharArray())); |
| | 660 | return true; |
| | 661 | } catch (CredentialsAgentException e) { |
| | 662 | Logging.error("Credentials could not be stored"); |
| | 663 | } |
| | 664 | } |
| | 665 | return false; |
| 650 | 666 | } |
| 651 | 667 | |
| 652 | 668 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/AboutActionTest.java b/test/unit/org/openstreetmap/josm/actions/AboutActionTest.java
index 51a4535692..dd6da352e1 100644
|
a
|
b
|
import org.junit.jupiter.api.Test;
|
| 8 | 8 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 9 | 9 | |
| 10 | 10 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 11 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * Unit tests for class {@link AboutAction}. |
| 14 | 15 | */ |
| | 16 | @BasicPreferences |
| 15 | 17 | final class AboutActionTest { |
| 16 | 18 | |
| 17 | 19 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java b/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java
index 77f2149805..b907ca891a 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.Node;
|
| 18 | 18 | import org.openstreetmap.josm.data.osm.Way; |
| 19 | 19 | import org.openstreetmap.josm.gui.MainApplication; |
| 20 | 20 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 21 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 21 | 22 | |
| 22 | 23 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 23 | 24 | |
| 24 | 25 | /** |
| 25 | 26 | * Unit tests for class {@link AlignInLineAction}. |
| 26 | 27 | */ |
| | 28 | @BasicPreferences |
| 27 | 29 | final class AlignInLineActionTest { |
| 28 | 30 | |
| 29 | 31 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java b/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java
index 495fec7007..03b3b516a5 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.Layer;
|
| 30 | 30 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 31 | 31 | import org.openstreetmap.josm.io.OsmReader; |
| 32 | 32 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 33 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 34 | import org.openstreetmap.josm.testutils.annotations.HTTP; |
| | 35 | import org.openstreetmap.josm.testutils.annotations.Territories; |
| 33 | 36 | import org.openstreetmap.josm.tools.Pair; |
| 34 | 37 | import org.openstreetmap.josm.tools.SubclassFilteredCollection; |
| 35 | 38 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 38 | 41 | /** |
| 39 | 42 | * Unit test of {@link CreateMultipolygonAction} |
| 40 | 43 | */ |
| | 44 | @BasicPreferences |
| | 45 | @HTTP |
| | 46 | @Territories(Territories.Initialize.ALL) |
| 41 | 47 | class CreateMultipolygonActionTest { |
| 42 | 48 | |
| 43 | 49 | /** |
| … |
… |
class CreateMultipolygonActionTest {
|
| 45 | 51 | */ |
| 46 | 52 | @RegisterExtension |
| 47 | 53 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 48 | | public JOSMTestRules test = new JOSMTestRules().projection().main().preferences().mapStyles(); |
| | 54 | public JOSMTestRules test = new JOSMTestRules().projection().main().mapStyles(); |
| 49 | 55 | |
| 50 | 56 | private static Map<String, String> getRefToRoleMap(Relation relation) { |
| 51 | 57 | Map<String, String> refToRole = new TreeMap<>(); |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java b/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java
index c6c4780728..a60d33ea24 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.MainApplication;
|
| 13 | 13 | import org.openstreetmap.josm.gui.io.SaveLayersDialog; |
| 14 | 14 | import org.openstreetmap.josm.gui.progress.swing.ProgressMonitorExecutor; |
| 15 | 15 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 16 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 16 | 17 | import org.openstreetmap.josm.tools.ImageProvider; |
| 17 | 18 | |
| 18 | 19 | import com.ginsberg.junit.exit.ExpectSystemExitWithStatus; |
| … |
… |
import mockit.MockUp;
|
| 25 | 26 | /** |
| 26 | 27 | * Unit tests for class {@link ExitAction}. |
| 27 | 28 | */ |
| | 29 | @BasicPreferences |
| 28 | 30 | final class ExitActionTest { |
| 29 | 31 | |
| 30 | 32 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/FullscreenToggleActionTest.java b/test/unit/org/openstreetmap/josm/actions/FullscreenToggleActionTest.java
index e03f5a4cc7..1d62fbd117 100644
|
a
|
b
|
import org.junit.jupiter.api.Test;
|
| 6 | 6 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 7 | 7 | |
| 8 | 8 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 9 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 9 | 10 | |
| 10 | 11 | /** |
| 11 | 12 | * Test {@link FullscreenToggleAction} |
| 12 | 13 | */ |
| | 14 | @BasicPreferences |
| 13 | 15 | class FullscreenToggleActionTest { |
| 14 | 16 | /** |
| 15 | 17 | * Setup test. |
| … |
… |
class FullscreenToggleActionTest {
|
| 29 | 31 | action.actionPerformed(null); |
| 30 | 32 | } |
| 31 | 33 | } |
| | 34 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java b/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java
index a6630f2861..6b095ebda6 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
| 35 | 35 | import org.openstreetmap.josm.io.IllegalDataException; |
| 36 | 36 | import org.openstreetmap.josm.io.OsmReader; |
| 37 | 37 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 38 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 39 | import org.openstreetmap.josm.testutils.annotations.HTTP; |
| | 40 | import org.openstreetmap.josm.testutils.annotations.Territories; |
| 38 | 41 | import org.openstreetmap.josm.tools.MultiMap; |
| 39 | 42 | import org.openstreetmap.josm.tools.Utils; |
| 40 | 43 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 43 | 46 | /** |
| 44 | 47 | * Unit tests of {@link JoinAreasAction} class. |
| 45 | 48 | */ |
| | 49 | @BasicPreferences |
| | 50 | @HTTP |
| | 51 | @Territories(Territories.Initialize.ALL) |
| 46 | 52 | class JoinAreasActionTest { |
| 47 | 53 | |
| 48 | 54 | /** |
| … |
… |
class JoinAreasActionTest {
|
| 50 | 56 | */ |
| 51 | 57 | @RegisterExtension |
| 52 | 58 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 53 | | public JOSMTestRules test = new JOSMTestRules().main().projection().preferences(); |
| | 59 | public JOSMTestRules test = new JOSMTestRules().main().projection().territories(); |
| 54 | 60 | |
| 55 | 61 | /** |
| 56 | 62 | * Non-regression test for bug #9599. |
| … |
… |
class JoinAreasActionTest {
|
| 270 | 276 | return n1.hasEqualSemanticAttributes(n2); |
| 271 | 277 | } |
| 272 | 278 | } |
| | 279 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/JoinNodeWayActionTest.java b/test/unit/org/openstreetmap/josm/actions/JoinNodeWayActionTest.java
index 680ffad9ce..148f033e3b 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.Layer;
|
| 27 | 27 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 28 | 28 | import org.openstreetmap.josm.io.OsmReader; |
| 29 | 29 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 30 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 31 | import org.openstreetmap.josm.testutils.annotations.HTTP; |
| | 32 | import org.openstreetmap.josm.testutils.annotations.Territories; |
| 30 | 33 | import org.openstreetmap.josm.tools.Geometry; |
| 31 | 34 | |
| 32 | 35 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 34 | 37 | /** |
| 35 | 38 | * Unit tests for class {@link JoinNodeWayAction}. |
| 36 | 39 | */ |
| | 40 | @BasicPreferences |
| | 41 | @HTTP |
| | 42 | @Territories(Territories.Initialize.ALL) |
| 37 | 43 | final class JoinNodeWayActionTest { |
| 38 | 44 | /** |
| 39 | 45 | * Setup test. |
| 40 | 46 | */ |
| 41 | 47 | @RegisterExtension |
| 42 | 48 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 43 | | public JOSMTestRules test = new JOSMTestRules().projection().main().preferences(); |
| | 49 | public JOSMTestRules test = new JOSMTestRules().projection().main(); |
| 44 | 50 | |
| 45 | 51 | private void setupMapView(DataSet ds) { |
| 46 | 52 | // setup a reasonable size for the edit window |
| … |
… |
final class JoinNodeWayActionTest {
|
| 243 | 249 | } |
| 244 | 250 | |
| 245 | 251 | } |
| | 252 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/MergeLayerActionTest.java b/test/unit/org/openstreetmap/josm/actions/MergeLayerActionTest.java
index f29c869887..acec378b36 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer;
|
| 20 | 20 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 21 | 21 | import org.openstreetmap.josm.gui.widgets.JosmComboBox; |
| 22 | 22 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 23 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 23 | 24 | import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; |
| 24 | 25 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 25 | 26 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 28 | 29 | /** |
| 29 | 30 | * Unit tests for class {@link MergeLayerAction}. |
| 30 | 31 | */ |
| | 32 | @BasicPreferences |
| 31 | 33 | public class MergeLayerActionTest { |
| 32 | 34 | |
| 33 | 35 | /** |
| … |
… |
public class MergeLayerActionTest {
|
| 123 | 125 | assertEquals("Select target layer", invocationLogEntry[2]); |
| 124 | 126 | } |
| 125 | 127 | } |
| | 128 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/PurgeActionTest.java b/test/unit/org/openstreetmap/josm/actions/PurgeActionTest.java
index a201b227b8..f9e0278aaf 100644
|
a
|
b
|
import org.openstreetmap.josm.io.OsmReader;
|
| 20 | 20 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 21 | 21 | |
| 22 | 22 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 23 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 24 | import org.openstreetmap.josm.testutils.annotations.HTTP; |
| | 25 | import org.openstreetmap.josm.testutils.annotations.Territories; |
| 23 | 26 | |
| 24 | 27 | /** |
| 25 | 28 | * Unit tests for class {@link PurgeAction}. |
| 26 | 29 | */ |
| | 30 | @BasicPreferences |
| | 31 | @HTTP |
| | 32 | @Territories(Territories.Initialize.ALL) |
| 27 | 33 | class PurgeActionTest { |
| 28 | 34 | |
| 29 | 35 | /** |
| … |
… |
class PurgeActionTest {
|
| 31 | 37 | */ |
| 32 | 38 | @RegisterExtension |
| 33 | 39 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 34 | | public JOSMTestRules test = new JOSMTestRules().main(); |
| | 40 | public JOSMTestRules test = new JOSMTestRules().main().projection(); |
| 35 | 41 | |
| 36 | 42 | /** |
| 37 | 43 | * Non-regression test for ticket #12038. |
| … |
… |
class PurgeActionTest {
|
| 65 | 71 | } |
| 66 | 72 | } |
| 67 | 73 | } |
| | 74 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/SelectAllActionTest.java b/test/unit/org/openstreetmap/josm/actions/SelectAllActionTest.java
index 73508d5c86..dcd9fd9072 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.MainApplication;
|
| 10 | 10 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 11 | 11 | |
| 12 | 12 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 13 | 14 | |
| 14 | 15 | /** |
| 15 | 16 | * Unit tests for class {@link SelectAllAction}. |
| 16 | 17 | */ |
| | 18 | @BasicPreferences |
| 17 | 19 | final class SelectAllActionTest { |
| 18 | 20 | |
| 19 | 21 | /** |
| … |
… |
final class SelectAllActionTest {
|
| 21 | 23 | */ |
| 22 | 24 | @RegisterExtension |
| 23 | 25 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 24 | | public JOSMTestRules rules = new JOSMTestRules().preferences().projection().main(); |
| | 26 | public JOSMTestRules rules = new JOSMTestRules().projection().main(); |
| 25 | 27 | |
| 26 | 28 | /** |
| 27 | 29 | * Unit test of {@link SelectAllAction#actionPerformed} method. |
| … |
… |
final class SelectAllActionTest {
|
| 36 | 38 | assertEquals(6, ds.getSelected().size()); |
| 37 | 39 | } |
| 38 | 40 | } |
| | 41 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/SelectByInternalPointActionTest.java b/test/unit/org/openstreetmap/josm/actions/SelectByInternalPointActionTest.java
index c3e709b7fe..d24eed62f5 100644
|
a
|
b
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
| 21 | 21 | |
| 22 | 22 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 23 | 23 | import net.trajano.commons.testing.UtilityClassTestUtil; |
| | 24 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 24 | 25 | |
| 25 | 26 | /** |
| 26 | 27 | * Unit tests for class {@link SelectByInternalPointAction}. |
| 27 | 28 | */ |
| | 29 | @BasicPreferences |
| 28 | 30 | final class SelectByInternalPointActionTest { |
| 29 | 31 | |
| 30 | 32 | /** |
| … |
… |
final class SelectByInternalPointActionTest {
|
| 32 | 34 | */ |
| 33 | 35 | @RegisterExtension |
| 34 | 36 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 35 | | public JOSMTestRules rules = new JOSMTestRules().preferences().projection().main(); |
| | 37 | public JOSMTestRules rules = new JOSMTestRules().projection().main(); |
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * Tests that {@code SelectByInternalPointAction} satisfies utility class criteria. |
| … |
… |
final class SelectByInternalPointActionTest {
|
| 126 | 128 | assertEquals(4, ds.getSelected().size()); |
| 127 | 129 | } |
| 128 | 130 | } |
| | 131 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/SessionLoadActionTest.java b/test/unit/org/openstreetmap/josm/actions/SessionLoadActionTest.java
index a224244dba..7551f874c7 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.TMSLayer;
|
| 11 | 11 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 12 | 12 | |
| 13 | 13 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 14 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * Unit tests for class {@link SessionLoadAction}. |
| 17 | 18 | */ |
| | 19 | @BasicPreferences |
| 18 | 20 | class SessionLoadActionTest { |
| 19 | 21 | |
| 20 | 22 | /** |
| … |
… |
class SessionLoadActionTest {
|
| 35 | 37 | ImageryType.TMS.getTypeString(), null, null)))); |
| 36 | 38 | } |
| 37 | 39 | } |
| | 40 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/SimplifyWayActionTest.java b/test/unit/org/openstreetmap/josm/actions/SimplifyWayActionTest.java
index 65842499e7..1fccfbc3de 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.MainApplication;
|
| 29 | 29 | import org.openstreetmap.josm.io.IllegalDataException; |
| 30 | 30 | import org.openstreetmap.josm.io.OsmReader; |
| 31 | 31 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 32 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 32 | 33 | import org.openstreetmap.josm.tools.Utils; |
| 33 | 34 | |
| 34 | 35 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 36 | 37 | /** |
| 37 | 38 | * Unit tests for class {@link SimplifyWayAction}. |
| 38 | 39 | */ |
| | 40 | @BasicPreferences |
| 39 | 41 | final class SimplifyWayActionTest { |
| 40 | 42 | |
| 41 | 43 | /** Class under test. */ |
| … |
… |
final class SimplifyWayActionTest {
|
| 107 | 109 | assertEquals(Collections.singleton(n1), deleteCommands.iterator().next().getParticipatingPrimitives()); |
| 108 | 110 | } |
| 109 | 111 | } |
| | 112 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java b/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
index c7941c5707..31d43cdb87 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.Way;
|
| 20 | 20 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 21 | 21 | |
| 22 | 22 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 23 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 23 | 24 | |
| 24 | 25 | /** |
| 25 | 26 | * Unit tests for class {@link SplitWayAction}. |
| 26 | 27 | */ |
| | 28 | @BasicPreferences |
| 27 | 29 | final class SplitWayActionTest { |
| 28 | 30 | |
| 29 | 31 | /** |
| … |
… |
final class SplitWayActionTest {
|
| 132 | 134 | assertSame(4, dataSet.getWays().size(), String.format("Found %d ways after split action instead of 4.", dataSet.getWays().size())); |
| 133 | 135 | } |
| 134 | 136 | } |
| | 137 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/UnGlueActionTest.java b/test/unit/org/openstreetmap/josm/actions/UnGlueActionTest.java
index de2f9cb541..739f99606f 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 16 | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 17 | 17 | |
| 18 | 18 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 19 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Unit tests for class {@link UnGlueAction}. |
| 22 | 23 | */ |
| | 24 | @BasicPreferences |
| 23 | 25 | final class UnGlueActionTest { |
| 24 | 26 | |
| 25 | 27 | /** Class under test. */ |
| … |
… |
final class UnGlueActionTest {
|
| 30 | 32 | */ |
| 31 | 33 | @RegisterExtension |
| 32 | 34 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 33 | | public JOSMTestRules test = new JOSMTestRules().main().projection().preferences(); |
| | 35 | public JOSMTestRules test = new JOSMTestRules().main().projection(); |
| 34 | 36 | |
| 35 | 37 | /** |
| 36 | 38 | * Setup test. |
| … |
… |
final class UnGlueActionTest {
|
| 142 | 144 | } |
| 143 | 145 | } |
| 144 | 146 | } |
| | 147 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskTest.java b/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskTest.java
index d5c514c34a..0876596848 100644
|
a
|
b
|
import java.util.concurrent.ExecutionException;
|
| 10 | 10 | import org.junit.jupiter.api.Test; |
| 11 | 11 | import org.openstreetmap.josm.data.osm.DataSet; |
| 12 | 12 | import org.openstreetmap.josm.testutils.annotations.BasicWiremock; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 13 | 14 | |
| 14 | 15 | /** |
| 15 | 16 | * Unit tests for class {@link DownloadOsmTask}. |
| 16 | 17 | */ |
| 17 | 18 | @BasicWiremock |
| | 19 | @BasicPreferences |
| 18 | 20 | class DownloadOsmTaskTest extends AbstractDownloadTaskTestParent { |
| 19 | 21 | |
| 20 | 22 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskListTest.java b/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskListTest.java
index 21d4f7bf55..db00f25610 100644
|
a
|
b
|
import java.awt.geom.Area;
|
| 8 | 8 | import java.util.Collections; |
| 9 | 9 | |
| 10 | 10 | import org.junit.jupiter.api.Test; |
| 11 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| 12 | 11 | import org.openstreetmap.josm.data.Bounds; |
| 13 | 12 | import org.openstreetmap.josm.gui.progress.NullProgressMonitor; |
| 14 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 15 | 13 | |
| 16 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 14 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 17 | 15 | |
| 18 | 16 | /** |
| 19 | 17 | * Unit tests for class {@link DownloadTaskList}. |
| 20 | 18 | */ |
| | 19 | @BasicPreferences |
| 21 | 20 | class DownloadTaskListTest { |
| 22 | | |
| 23 | | /** |
| 24 | | * Setup test. |
| 25 | | */ |
| 26 | | @RegisterExtension |
| 27 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 28 | | public JOSMTestRules test = new JOSMTestRules(); |
| 29 | | |
| 30 | 21 | /** |
| 31 | 22 | * Unit test of {@code DownloadTaskList#DownloadTaskList}. |
| 32 | 23 | */ |
| … |
… |
class DownloadTaskListTest {
|
| 53 | 44 | assertTrue(list.getDownloadedPrimitives().isEmpty()); |
| 54 | 45 | } |
| 55 | 46 | } |
| | 47 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/AddNoteActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/AddNoteActionTest.java
index 397e2526f8..145dc0defb 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 14 | 14 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 15 | 15 | |
| 16 | 16 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 17 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Unit tests for class {@link AddNoteAction}. |
| 20 | 21 | */ |
| | 22 | @BasicPreferences |
| 21 | 23 | class AddNoteActionTest { |
| 22 | 24 | |
| 23 | 25 | /** |
| … |
… |
class AddNoteActionTest {
|
| 46 | 48 | } |
| 47 | 49 | } |
| 48 | 50 | } |
| | 51 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/DeleteActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/DeleteActionTest.java
index 5573a73f23..7be9d47520 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 15 | 15 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 16 | 16 | |
| 17 | 17 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 18 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Unit tests for class {@link DeleteAction}. |
| 21 | 22 | */ |
| | 23 | @BasicPreferences |
| 22 | 24 | class DeleteActionTest { |
| 23 | 25 | |
| 24 | 26 | /** |
| … |
… |
class DeleteActionTest {
|
| 55 | 57 | TestUtils.superficialEnumCodeCoverage(DeleteMode.class); |
| 56 | 58 | } |
| 57 | 59 | } |
| | 60 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/DrawActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/DrawActionTest.java
index 1907155524..5ad0f10f64 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 28 | 28 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 29 | 29 | |
| 30 | 30 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 31 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 31 | 32 | |
| 32 | 33 | /** |
| 33 | 34 | * Unit tests for class {@link DrawAction}. |
| 34 | 35 | */ |
| | 36 | @BasicPreferences |
| 35 | 37 | class DrawActionTest { |
| 36 | 38 | |
| 37 | 39 | /** |
| … |
… |
class DrawActionTest {
|
| 103 | 105 | } |
| 104 | 106 | } |
| 105 | 107 | } |
| | 108 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/ExtrudeActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/ExtrudeActionTest.java
index fbc4dec9ef..2452a1ca85 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 15 | 15 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 16 | 16 | |
| 17 | 17 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 18 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Unit tests for class {@link ExtrudeAction}. |
| 21 | 22 | */ |
| | 23 | @BasicPreferences |
| 22 | 24 | class ExtrudeActionTest { |
| 23 | 25 | |
| 24 | 26 | /** |
| … |
… |
class ExtrudeActionTest {
|
| 55 | 57 | TestUtils.superficialEnumCodeCoverage(Mode.class); |
| 56 | 58 | } |
| 57 | 59 | } |
| | 60 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyActionTest.java
index a31055d93c..0ab7735024 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 15 | 15 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 16 | 16 | |
| 17 | 17 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 18 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Unit tests for class {@link ImproveWayAccuracyAction}. |
| 21 | 22 | */ |
| | 23 | @BasicPreferences |
| 22 | 24 | class ImproveWayAccuracyActionTest { |
| 23 | 25 | |
| 24 | 26 | /** |
| … |
… |
class ImproveWayAccuracyActionTest {
|
| 55 | 57 | TestUtils.superficialEnumCodeCoverage(State.class); |
| 56 | 58 | } |
| 57 | 59 | } |
| | 60 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java
index 0087a928ac..ea54d3fe85 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 16 | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 17 | 17 | |
| 18 | 18 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 19 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Unit tests for class {@link ParallelWayAction}. |
| 22 | 23 | */ |
| | 24 | @BasicPreferences |
| 23 | 25 | class ParallelWayActionTest { |
| 24 | 26 | |
| 25 | 27 | /** |
| … |
… |
class ParallelWayActionTest {
|
| 64 | 66 | TestUtils.superficialEnumCodeCoverage(Modifier.class); |
| 65 | 67 | } |
| 66 | 68 | } |
| | 69 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/PlayHeadDragModeTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/PlayHeadDragModeTest.java
index 23fa6922f3..836471a8a4 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker;
|
| 14 | 14 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 15 | 15 | |
| 16 | 16 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 17 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Unit tests for class {@link PlayHeadDragMode}. |
| 20 | 21 | */ |
| | 22 | @BasicPreferences |
| 21 | 23 | class PlayHeadDragModeTest { |
| 22 | 24 | |
| 23 | 25 | /** |
| … |
… |
class PlayHeadDragModeTest {
|
| 46 | 48 | } |
| 47 | 49 | } |
| 48 | 50 | } |
| | 51 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
index 046ba5d151..cb111aa958 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.MainLayerManager;
|
| 26 | 26 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 27 | 27 | import org.openstreetmap.josm.spi.preferences.Config; |
| 28 | 28 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 29 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 29 | 30 | import org.openstreetmap.josm.tools.ReflectionUtils; |
| 30 | 31 | |
| 31 | 32 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 33 | 34 | /** |
| 34 | 35 | * Unit tests for class {@link SelectAction}. |
| 35 | 36 | */ |
| | 37 | @BasicPreferences |
| 36 | 38 | class SelectActionTest { |
| 37 | 39 | |
| 38 | 40 | boolean nodesMerged; |
| … |
… |
class SelectActionTest {
|
| 161 | 163 | TestUtils.superficialEnumCodeCoverage(SelectActionCursor.class); |
| 162 | 164 | } |
| 163 | 165 | } |
| | 166 | |
-
diff --git a/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java b/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java
index a60e8211fa..a8c3cf9327 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.Way;
|
| 22 | 22 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 23 | 23 | |
| 24 | 24 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 25 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 25 | 26 | |
| 26 | 27 | /** |
| 27 | 28 | * Unit tests for class {@link FixDataHook}. |
| 28 | 29 | */ |
| | 30 | @BasicPreferences |
| 29 | 31 | class FixDataHookTest { |
| 30 | 32 | |
| 31 | 33 | /** |
| … |
… |
class FixDataHookTest {
|
| 127 | 129 | assertTrue(r2.hasKey("space_both")); |
| 128 | 130 | } |
| 129 | 131 | } |
| | 132 | |
-
diff --git a/test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java b/test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java
index 6e724d8ec4..1dd480cb86 100644
|
a
|
b
|
import org.openstreetmap.josm.io.OsmReader;
|
| 31 | 31 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 32 | 32 | |
| 33 | 33 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 34 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 34 | 35 | |
| 35 | 36 | /** |
| 36 | 37 | * Unit tests for class {@link SplitWayCommand}. |
| 37 | 38 | */ |
| | 39 | @BasicPreferences |
| 38 | 40 | final class SplitWayCommandTest { |
| 39 | 41 | |
| 40 | 42 | /** |
| … |
… |
final class SplitWayCommandTest {
|
| 42 | 44 | */ |
| 43 | 45 | @RegisterExtension |
| 44 | 46 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 45 | | public JOSMTestRules test = new JOSMTestRules().main().projection().preferences(); |
| | 47 | public JOSMTestRules test = new JOSMTestRules().main().projection(); |
| 46 | 48 | |
| 47 | 49 | /** |
| 48 | 50 | * Unit test of {@link SplitWayCommand#findVias}. |
| … |
… |
final class SplitWayCommandTest {
|
| 434 | 436 | } |
| 435 | 437 | |
| 436 | 438 | } |
| | 439 | |
-
diff --git a/test/unit/org/openstreetmap/josm/data/osm/NodeDataTest.java b/test/unit/org/openstreetmap/josm/data/osm/NodeDataTest.java
index 88c3300f6e..0760332e44 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.data.osm; |
| 3 | 3 | |
| | 4 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | 5 | import static org.junit.jupiter.api.Assertions.assertNull; |
| 5 | 6 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| 6 | 7 | |
| … |
… |
import java.io.IOException;
|
| 10 | 11 | import java.io.ObjectInputStream; |
| 11 | 12 | import java.io.ObjectOutputStream; |
| 12 | 13 | |
| 13 | | import org.junit.Assert; |
| 14 | 14 | import org.junit.jupiter.api.Test; |
| 15 | 15 | import org.openstreetmap.josm.data.coor.LatLon; |
| | 16 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 16 | 17 | |
| 17 | 18 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 18 | 19 | |
| | 20 | @BasicPreferences |
| 19 | 21 | class NodeDataTest { |
| 20 | 22 | |
| 21 | 23 | @SuppressFBWarnings(value = "OBJECT_DESERIALIZATION") |
| … |
… |
class NodeDataTest {
|
| 37 | 39 | data.setVersion(14); |
| 38 | 40 | data.setChangesetId(314159); |
| 39 | 41 | final NodeData readData = serializeUnserialize(data); |
| 40 | | Assert.assertEquals(data.toString(), readData.toString()); |
| | 42 | assertEquals(data.toString(), readData.toString()); |
| 41 | 43 | } |
| 42 | 44 | |
| 43 | 45 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java b/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java
index 74b6876655..16c24a685a 100644
|
a
|
b
|
import java.util.regex.Pattern;
|
| 49 | 49 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 50 | 50 | import org.junit.jupiter.api.Test; |
| 51 | 51 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 52 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 52 | 53 | import org.openstreetmap.josm.tools.Logging; |
| 53 | 54 | |
| 54 | 55 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 58 | 59 | * |
| 59 | 60 | * @version $Revision: 1723861 $ |
| 60 | 61 | */ |
| | 62 | @IntegrationTest |
| 61 | 63 | class DomainValidatorTestIT { |
| 62 | 64 | |
| 63 | 65 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java
index 30f5e8f8d4..5fdce35a12 100644
|
a
|
b
|
import org.openstreetmap.josm.data.validation.tests.CrossingWays.SelfCrossing;
|
| 25 | 25 | import org.openstreetmap.josm.data.validation.tests.CrossingWays.Ways; |
| 26 | 26 | import org.openstreetmap.josm.io.OsmReader; |
| 27 | 27 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 28 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 28 | 29 | |
| 29 | 30 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 30 | 31 | |
| 31 | 32 | /** |
| 32 | 33 | * Unit test of {@link CrossingWays}. |
| 33 | 34 | */ |
| | 35 | @BasicPreferences |
| 34 | 36 | class CrossingWaysTest { |
| 35 | 37 | |
| 36 | 38 | /** |
| … |
… |
class CrossingWaysTest {
|
| 38 | 40 | */ |
| 39 | 41 | @RegisterExtension |
| 40 | 42 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 41 | | public JOSMTestRules rule = new JOSMTestRules().preferences().projection(); |
| | 43 | public JOSMTestRules rule = new JOSMTestRules().projection(); |
| 42 | 44 | |
| 43 | 45 | private static Way newUsableWay(String tags) { |
| 44 | 46 | return TestUtils.newWay(tags, new Node(LatLon.NORTH_POLE), new Node(LatLon.ZERO)); |
-
diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
index 102f5f3118..46f2ca0f91 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
|
| 42 | 42 | import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException; |
| 43 | 43 | import org.openstreetmap.josm.io.OsmReader; |
| 44 | 44 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 45 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 45 | 46 | import org.openstreetmap.josm.tools.Logging; |
| 46 | 47 | |
| 47 | 48 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 49 | 50 | /** |
| 50 | 51 | * JUnit Test of {@link MapCSSTagChecker}. |
| 51 | 52 | */ |
| | 53 | @BasicPreferences |
| 52 | 54 | class MapCSSTagCheckerTest { |
| 53 | 55 | |
| 54 | 56 | /** |
| … |
… |
class MapCSSTagCheckerTest {
|
| 56 | 58 | */ |
| 57 | 59 | @RegisterExtension |
| 58 | 60 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 59 | | public JOSMTestRules test = new JOSMTestRules().projection().territories().preferences(); |
| | 61 | public JOSMTestRules test = new JOSMTestRules().projection().territories(); |
| 60 | 62 | |
| 61 | 63 | /** |
| 62 | 64 | * Setup test. |
-
diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/MultipolygonTestTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/MultipolygonTestTest.java
index 3d3dd861b7..a97c7114b7 100644
|
a
|
b
|
import org.openstreetmap.josm.io.OsmReader;
|
| 15 | 15 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 16 | 16 | |
| 17 | 17 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 18 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * JUnit Test of Multipolygon validation test. |
| 21 | 22 | */ |
| | 23 | @BasicPreferences |
| 22 | 24 | class MultipolygonTestTest { |
| 23 | 25 | |
| 24 | 26 | |
| … |
… |
class MultipolygonTestTest {
|
| 27 | 29 | */ |
| 28 | 30 | @RegisterExtension |
| 29 | 31 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 30 | | public JOSMTestRules test = new JOSMTestRules().projection().mapStyles().presets().main().preferences(); |
| | 32 | public JOSMTestRules test = new JOSMTestRules().projection().mapStyles().presets().main(); |
| 31 | 33 | |
| 32 | 34 | /** |
| 33 | 35 | * Test all error cases manually created in multipolygon.osm. |
| … |
… |
class MultipolygonTestTest {
|
| 70 | 72 | } |
| 71 | 73 | } |
| 72 | 74 | } |
| | 75 | |
-
diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
index ab467d180a..0f3aff2ba1 100644
|
a
|
b
|
import org.openstreetmap.josm.data.validation.TestError;
|
| 23 | 23 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 24 | 24 | |
| 25 | 25 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 26 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 26 | 27 | |
| 27 | 28 | /** |
| 28 | 29 | * JUnit Test of {@link TagChecker}. |
| 29 | 30 | */ |
| | 31 | @BasicPreferences |
| 30 | 32 | class TagCheckerTest { |
| 31 | 33 | |
| 32 | 34 | /** |
| … |
… |
class TagCheckerTest {
|
| 391 | 393 | assertFalse(TagChecker.containsUnusualUnicodeCharacter("name", "Yuułuʔiłʔatḥ Lands")); |
| 392 | 394 | } |
| 393 | 395 | } |
| | 396 | |
-
diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/TurnRestrictionTestTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/TurnRestrictionTestTest.java
index e036a42c73..73337822aa 100644
|
a
|
b
|
import org.junit.jupiter.api.Test;
|
| 6 | 6 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 7 | 7 | |
| 8 | 8 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 9 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 9 | 10 | |
| 10 | 11 | /** |
| 11 | 12 | * JUnit Test of turn restriction validation test. |
| 12 | 13 | */ |
| | 14 | @BasicPreferences |
| 13 | 15 | class TurnRestrictionTestTest { |
| 14 | 16 | |
| 15 | 17 | private static final TurnrestrictionTest TURNRESTRICTION_TEST = new TurnrestrictionTest(); |
| … |
… |
class TurnRestrictionTestTest {
|
| 33 | 35 | name -> name.startsWith("E"), TURNRESTRICTION_TEST, RELATION_TEST); |
| 34 | 36 | } |
| 35 | 37 | } |
| | 38 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java b/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java
index 7afa85a3cc..ede06c3684 100644
|
a
|
b
|
import org.openstreetmap.josm.plugins.PluginListParseException;
|
| 44 | 44 | import org.openstreetmap.josm.plugins.PluginListParser; |
| 45 | 45 | import org.openstreetmap.josm.spi.preferences.Config; |
| 46 | 46 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 47 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 47 | 48 | import org.openstreetmap.josm.tools.Logging; |
| 48 | 49 | import org.openstreetmap.josm.tools.PlatformManager; |
| 49 | 50 | import org.openstreetmap.josm.tools.Shortcut; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 53 | 54 | /** |
| 54 | 55 | * Unit tests of {@link MainApplication} class. |
| 55 | 56 | */ |
| | 57 | @BasicPreferences |
| 56 | 58 | public class MainApplicationTest { |
| 57 | 59 | |
| 58 | 60 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/MapScalerTest.java b/test/unit/org/openstreetmap/josm/gui/MapScalerTest.java
index eed8d2c0c2..bb80a7215d 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.DataSet;
|
| 14 | 14 | import org.openstreetmap.josm.gui.MapScaler.AccessibleMapScaler; |
| 15 | 15 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 16 | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 17 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 17 | 18 | |
| 18 | 19 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Unit tests of {@link MapScaler} class. |
| 22 | 23 | */ |
| | 24 | @BasicPreferences |
| 23 | 25 | class MapScalerTest { |
| 24 | 26 | |
| 25 | 27 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java b/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java
index bced2a293c..5d8964c8c0 100644
|
a
|
b
|
import org.openstreetmap.josm.data.coor.LatLon;
|
| 24 | 24 | import org.openstreetmap.josm.data.projection.ProjectionRegistry; |
| 25 | 25 | import org.openstreetmap.josm.gui.util.GuiHelper; |
| 26 | 26 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 27 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 27 | 28 | |
| 28 | 29 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 29 | 30 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 32 | 33 | * @author Michael Zangl |
| 33 | 34 | * |
| 34 | 35 | */ |
| | 36 | @BasicPreferences |
| 35 | 37 | class NavigatableComponentTest { |
| 36 | 38 | |
| 37 | 39 | private static final class NavigatableComponentMock extends NavigatableComponent { |
| … |
… |
class NavigatableComponentTest {
|
| 55 | 57 | */ |
| 56 | 58 | @RegisterExtension |
| 57 | 59 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 58 | | public JOSMTestRules test = new JOSMTestRules().preferences().projection(); |
| | 60 | public JOSMTestRules test = new JOSMTestRules().projection(); |
| 59 | 61 | |
| 60 | 62 | /** |
| 61 | 63 | * Create a new, fresh {@link NavigatableComponent} |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java b/test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java
index 53fa17f273..aec7b65fb2 100644
|
a
|
b
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
| 18 | 18 | import org.junit.jupiter.api.Test; |
| 19 | 19 | import org.openstreetmap.josm.TestUtils; |
| 20 | 20 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 21 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 21 | 22 | import org.openstreetmap.josm.tools.Logging; |
| 22 | 23 | import org.openstreetmap.josm.tools.ReflectionUtils; |
| 23 | 24 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 39 | 40 | * |
| 40 | 41 | * @see <a href="https://josm.openstreetmap.de/ticket/6301">#6301</a> |
| 41 | 42 | */ |
| | 43 | @BasicPreferences |
| 42 | 44 | class TableCellRendererTest { |
| 43 | 45 | |
| 44 | 46 | // list of classes that cannot be easily tested and are verified either manually or another unit tests |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java b/test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java
index c58dcc28b9..c1b02094e1 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 18 | 18 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 19 | 19 | |
| 20 | 20 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 21 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | 24 | * Unit tests of {@link OsmTransferHandler} class. |
| 24 | 25 | */ |
| | 26 | // Prefs for OSM primitives |
| | 27 | @BasicPreferences |
| 25 | 28 | class OsmTransferHandlerTest { |
| 26 | | /** |
| 27 | | * Prefs to use OSM primitives |
| 28 | | */ |
| 29 | 29 | @RegisterExtension |
| 30 | 30 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 31 | | public JOSMTestRules test = new JOSMTestRules().preferences().projection().main(); |
| | 31 | public JOSMTestRules test = new JOSMTestRules().projection().main(); |
| 32 | 32 | |
| 33 | 33 | private final OsmTransferHandler transferHandler = new OsmTransferHandler(); |
| 34 | 34 | |
| … |
… |
class OsmTransferHandlerTest {
|
| 72 | 72 | assertEquals("ok", n.get("test")); |
| 73 | 73 | } |
| 74 | 74 | } |
| | 75 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/CommandStackDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/CommandStackDialogTest.java
index 56a49140ec..da81bee6d4 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 16 | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 17 | 17 | |
| 18 | 18 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 19 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Unit tests of {@link CommandStackDialog} class. |
| 22 | 23 | */ |
| | 24 | @BasicPreferences |
| 23 | 25 | class CommandStackDialogTest { |
| 24 | 26 | |
| 25 | 27 | /** |
| … |
… |
class CommandStackDialogTest {
|
| 27 | 29 | */ |
| 28 | 30 | @RegisterExtension |
| 29 | 31 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 30 | | public JOSMTestRules test = new JOSMTestRules().main().projection().preferences(); |
| | 32 | public JOSMTestRules test = new JOSMTestRules().main().projection(); |
| 31 | 33 | |
| 32 | 34 | /** |
| 33 | 35 | * Unit test of {@link CommandStackDialog} class - empty case. |
| … |
… |
class CommandStackDialogTest {
|
| 113 | 115 | } |
| 114 | 116 | } |
| 115 | 117 | } |
| | 118 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java
index 26eca27009..33b544da57 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 21 | 21 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 22 | 22 | |
| 23 | 23 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 24 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 24 | 25 | |
| 25 | 26 | /** |
| 26 | 27 | * Unit tests of {@link ConflictDialog} class. |
| 27 | 28 | */ |
| | 29 | @BasicPreferences |
| 28 | 30 | class ConflictDialogTest { |
| 29 | 31 | |
| 30 | 32 | /** |
| … |
… |
class ConflictDialogTest {
|
| 73 | 75 | cp.visit(r); |
| 74 | 76 | } |
| 75 | 77 | } |
| | 78 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialogTest.java
index b338d3f330..ff2d873346 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 23 | 23 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 24 | 24 | |
| 25 | 25 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 26 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 26 | 27 | |
| 27 | 28 | /** |
| 28 | 29 | * Unit tests of {@link InspectPrimitiveDialog} class. |
| 29 | 30 | */ |
| | 31 | @BasicPreferences |
| 30 | 32 | class InspectPrimitiveDialogTest { |
| 31 | 33 | |
| 32 | 34 | /** |
| … |
… |
class InspectPrimitiveDialogTest {
|
| 170 | 172 | } |
| 171 | 173 | } |
| 172 | 174 | } |
| | 175 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/MapPaintDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/MapPaintDialogTest.java
index e395bf7378..e37b587ae7 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 9 | 9 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 10 | 10 | |
| 11 | 11 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 12 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 12 | 13 | |
| 13 | 14 | /** |
| 14 | 15 | * Unit tests of {@link MapPaintDialog} class. |
| 15 | 16 | */ |
| | 17 | @BasicPreferences |
| 16 | 18 | class MapPaintDialogTest { |
| 17 | 19 | |
| 18 | 20 | /** |
| … |
… |
class MapPaintDialogTest {
|
| 31 | 33 | MainApplication.getMap().mapPaintDialog.new InfoAction().actionPerformed(null); |
| 32 | 34 | } |
| 33 | 35 | } |
| | 36 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
index c2399a6aa3..7bec43b9cf 100644
|
a
|
b
|
|
| 2 | 2 | package org.openstreetmap.josm.gui.dialogs; |
| 3 | 3 | |
| 4 | 4 | import static java.util.concurrent.TimeUnit.MILLISECONDS; |
| 5 | | import static org.junit.Assert.assertArrayEquals; |
| 6 | | import static org.junit.Assert.assertEquals; |
| 7 | | import static org.junit.Assert.assertFalse; |
| 8 | | import static org.junit.Assert.assertTrue; |
| 9 | | import static org.junit.Assert.fail; |
| | 5 | import static org.junit.jupiter.api.Assertions.assertArrayEquals; |
| | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | 7 | import static org.junit.jupiter.api.Assertions.assertFalse; |
| | 8 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| | 9 | import static org.junit.jupiter.api.Assertions.fail; |
| 10 | 10 | import static org.openstreetmap.josm.tools.I18n.tr; |
| 11 | 11 | |
| 12 | 12 | import java.awt.Color; |
| … |
… |
import javax.swing.JMenuItem;
|
| 27 | 27 | import javax.swing.JPopupMenu; |
| 28 | 28 | |
| 29 | 29 | import org.awaitility.Awaitility; |
| 30 | | import org.junit.Rule; |
| 31 | | import org.junit.Test; |
| | 30 | import org.junit.jupiter.api.Test; |
| | 31 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 32 | 32 | import org.openstreetmap.josm.TestUtils; |
| 33 | 33 | import org.openstreetmap.josm.data.Bounds; |
| 34 | 34 | import org.openstreetmap.josm.data.DataSource; |
| … |
… |
import org.openstreetmap.josm.gui.util.GuiHelper;
|
| 48 | 48 | import org.openstreetmap.josm.spi.preferences.Config; |
| 49 | 49 | import org.openstreetmap.josm.testutils.ImagePatternMatching; |
| 50 | 50 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 51 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 52 | import org.openstreetmap.josm.testutils.annotations.FakeImagery; |
| 51 | 53 | |
| 52 | 54 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 53 | 55 | |
| 54 | 56 | /** |
| 55 | 57 | * Unit tests of {@link MinimapDialog} class. |
| 56 | 58 | */ |
| 57 | | public class MinimapDialogTest { |
| | 59 | @BasicPreferences |
| | 60 | @FakeImagery |
| | 61 | class MinimapDialogTest { |
| 58 | 62 | |
| 59 | 63 | /** |
| 60 | 64 | * Setup tests |
| 61 | 65 | */ |
| 62 | | @Rule |
| | 66 | @RegisterExtension |
| 63 | 67 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 64 | | public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection().fakeImagery(); |
| | 68 | public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection(); |
| 65 | 69 | |
| 66 | 70 | /** |
| 67 | 71 | * Unit test of {@link MinimapDialog} class. |
| 68 | 72 | */ |
| 69 | 73 | @Test |
| 70 | | public void testMinimapDialog() { |
| | 74 | void testMinimapDialog() { |
| 71 | 75 | MinimapDialog dlg = new MinimapDialog(); |
| 72 | 76 | dlg.showDialog(); |
| 73 | 77 | assertTrue(dlg.isVisible()); |
| … |
… |
public class MinimapDialogTest {
|
| 101 | 105 | boolean isSelected = ((JMenuItem) c).isSelected(); |
| 102 | 106 | assertEquals(equalText, isSelected); |
| 103 | 107 | if (equalText) { |
| 104 | | assertFalse("Second selected source found", found); |
| | 108 | assertFalse(found, "Second selected source found"); |
| 105 | 109 | found = true; |
| 106 | 110 | } |
| 107 | 111 | } |
| 108 | 112 | } |
| 109 | | assertTrue("Selected source not found in menu", found); |
| | 113 | assertTrue(found, "Selected source not found in menu"); |
| 110 | 114 | } |
| 111 | 115 | |
| 112 | 116 | protected void clickSourceMenuItemByLabel(final String label) { |
| … |
… |
public class MinimapDialogTest {
|
| 198 | 202 | * @throws Exception if any error occurs |
| 199 | 203 | */ |
| 200 | 204 | @Test |
| 201 | | public void testSourceSwitching() throws Exception { |
| | 205 | void testSourceSwitching() throws Exception { |
| 202 | 206 | // relevant prefs starting out empty, should choose the first source and have shown download area enabled |
| 203 | 207 | // (not that there's a data layer for it to use) |
| 204 | 208 | |
| … |
… |
public class MinimapDialogTest {
|
| 245 | 249 | * @throws Exception if any error occurs |
| 246 | 250 | */ |
| 247 | 251 | @Test |
| 248 | | public void testRefreshSourcesRetainsSelection() throws Exception { |
| | 252 | void testRefreshSourcesRetainsSelection() throws Exception { |
| 249 | 253 | // relevant prefs starting out empty, should choose the first source and have shown download area enabled |
| 250 | 254 | // (not that there's a data layer for it to use) |
| 251 | 255 | |
| … |
… |
public class MinimapDialogTest {
|
| 283 | 287 | * @throws Exception if any error occurs |
| 284 | 288 | */ |
| 285 | 289 | @Test |
| 286 | | public void testRemovedSourceStillSelected() throws Exception { |
| | 290 | void testRemovedSourceStillSelected() throws Exception { |
| 287 | 291 | // relevant prefs starting out empty, should choose the first source and have shown download area enabled |
| 288 | 292 | // (not that there's a data layer for it to use) |
| 289 | 293 | |
| … |
… |
public class MinimapDialogTest {
|
| 316 | 320 | * @throws Exception if any error occurs |
| 317 | 321 | */ |
| 318 | 322 | @Test |
| 319 | | public void testTileSourcesFromCurrentLayers() throws Exception { |
| | 323 | void testTileSourcesFromCurrentLayers() throws Exception { |
| 320 | 324 | // relevant prefs starting out empty, should choose the first (ImageryLayerInfo) source and have shown download area enabled |
| 321 | 325 | // (not that there's a data layer for it to use) |
| 322 | 326 | |
| … |
… |
public class MinimapDialogTest {
|
| 450 | 454 | * @throws Exception if any error occurs |
| 451 | 455 | */ |
| 452 | 456 | @Test |
| 453 | | public void testSourcePrefObeyed() throws Exception { |
| | 457 | void testSourcePrefObeyed() throws Exception { |
| 454 | 458 | Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); |
| 455 | 459 | |
| 456 | 460 | this.setUpMiniMap(); |
| … |
… |
public class MinimapDialogTest {
|
| 477 | 481 | * @throws Exception if any error occurs |
| 478 | 482 | */ |
| 479 | 483 | @Test |
| 480 | | public void testSourcePrefInvalid() throws Exception { |
| | 484 | void testSourcePrefInvalid() throws Exception { |
| 481 | 485 | Config.getPref().put("slippy_map_chooser.mapstyle", "Hooloovoo Tiles"); |
| 482 | 486 | |
| 483 | 487 | this.setUpMiniMap(); |
| … |
… |
public class MinimapDialogTest {
|
| 499 | 503 | * @throws Exception if any error occurs |
| 500 | 504 | */ |
| 501 | 505 | @Test |
| 502 | | public void testViewportAspectRatio() throws Exception { |
| | 506 | void testViewportAspectRatio() throws Exception { |
| 503 | 507 | // Add a test layer to the layer manager to get the MapFrame & MapView |
| 504 | 508 | MainApplication.getLayerManager().addLayer(new TestLayer()); |
| 505 | 509 | |
| … |
… |
public class MinimapDialogTest {
|
| 545 | 549 | // (within a tolerance for numerical error) the number of pixels on the left of the viewport marker |
| 546 | 550 | // should equal the number on the right |
| 547 | 551 | assertTrue( |
| 548 | | "Viewport marker not horizontally centered", |
| 549 | | Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4 |
| | 552 | Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4, |
| | 553 | "Viewport marker not horizontally centered" |
| 550 | 554 | ); |
| 551 | 555 | |
| 552 | 556 | Matcher colMatcher = ImagePatternMatching.columnMatch( |
| … |
… |
public class MinimapDialogTest {
|
| 560 | 564 | // (within a tolerance for numerical error) the number of pixels on the top of the viewport marker |
| 561 | 565 | // should equal the number on the bottom |
| 562 | 566 | assertTrue( |
| 563 | | "Viewport marker not vertically centered", |
| 564 | | Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4 |
| | 567 | Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4, |
| | 568 | "Viewport marker not vertically centered" |
| 565 | 569 | ); |
| 566 | 570 | |
| 567 | 571 | // (within a tolerance for numerical error) the viewport marker should be square |
| 568 | 572 | assertTrue( |
| 569 | | "Viewport marker not square", |
| 570 | | Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4 |
| | 573 | Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4, |
| | 574 | "Viewport marker not square" |
| 571 | 575 | ); |
| 572 | 576 | |
| 573 | 577 | // now change the mapView size |
| … |
… |
public class MinimapDialogTest {
|
| 590 | 594 | true |
| 591 | 595 | ); |
| 592 | 596 | assertTrue( |
| 593 | | "Viewport marker not horizontally centered", |
| 594 | | Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4 |
| | 597 | Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4, |
| | 598 | "Viewport marker not horizontally centered" |
| 595 | 599 | ); |
| 596 | 600 | |
| 597 | 601 | colMatcher = ImagePatternMatching.columnMatch( |
| … |
… |
public class MinimapDialogTest {
|
| 602 | 606 | true |
| 603 | 607 | ); |
| 604 | 608 | assertTrue( |
| 605 | | "Viewport marker not vertically centered", |
| 606 | | Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4 |
| | 609 | Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4, |
| | 610 | "Viewport marker not vertically centered" |
| 607 | 611 | ); |
| 608 | 612 | |
| 609 | 613 | try { |
| … |
… |
public class MinimapDialogTest {
|
| 613 | 617 | } |
| 614 | 618 | |
| 615 | 619 | assertTrue( |
| 616 | | "Viewport marker not 2:1 aspect ratio", |
| 617 | | Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5 |
| | 620 | Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5, |
| | 621 | "Viewport marker not 2:1 aspect ratio" |
| 618 | 622 | ); |
| 619 | 623 | } |
| 620 | 624 | |
| … |
… |
public class MinimapDialogTest {
|
| 623 | 627 | boolean afterSeparator = false; |
| 624 | 628 | for (Component c: menu.getComponents()) { |
| 625 | 629 | if (JPopupMenu.Separator.class.isInstance(c)) { |
| 626 | | assertFalse("More than one separator before target item", afterSeparator); |
| | 630 | assertFalse(afterSeparator, "More than one separator before target item"); |
| 627 | 631 | afterSeparator = true; |
| 628 | 632 | } else if (((JMenuItem) c).getText().equals(tr("Show downloaded area"))) { |
| 629 | | assertTrue("Separator not found before target item", afterSeparator); |
| 630 | | assertTrue("Target item doesn't appear to be a JCheckBoxMenuItem", JCheckBoxMenuItem.class.isInstance(c)); |
| | 633 | assertTrue(afterSeparator, "Separator not found before target item"); |
| | 634 | assertTrue(JCheckBoxMenuItem.class.isInstance(c), "Target item doesn't appear to be a JCheckBoxMenuItem"); |
| 631 | 635 | return (JCheckBoxMenuItem) c; |
| 632 | 636 | } |
| 633 | 637 | } |
| … |
… |
public class MinimapDialogTest {
|
| 640 | 644 | * @throws Exception if any error occurs |
| 641 | 645 | */ |
| 642 | 646 | @Test |
| 643 | | public void testShowDownloadedArea() throws Exception { |
| | 647 | void testShowDownloadedArea() throws Exception { |
| 644 | 648 | Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); |
| 645 | 649 | Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", false); |
| 646 | 650 | |
| … |
… |
public class MinimapDialogTest {
|
| 799 | 803 | * @throws Exception if any error occurs |
| 800 | 804 | */ |
| 801 | 805 | @Test |
| 802 | | public void testShowDownloadedAreaLayerSwitching() throws Exception { |
| | 806 | void testShowDownloadedAreaLayerSwitching() throws Exception { |
| 803 | 807 | Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); |
| 804 | 808 | Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", true); |
| 805 | 809 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanelTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanelTest.java
index 146c5a3bad..2b94122872 100644
|
a
|
b
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
| 8 | 8 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 9 | 9 | import org.junit.jupiter.api.Test; |
| 10 | 10 | import org.junit.jupiter.api.extension.RegisterExtension; |
| | 11 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * Unit tests of {@link ChangesetContentPanel} class. |
| 14 | 15 | */ |
| | 16 | @BasicPreferences |
| 15 | 17 | class ChangesetContentPanelTest { |
| 16 | 18 | |
| 17 | 19 | /** |
| … |
… |
class ChangesetContentPanelTest {
|
| 19 | 21 | */ |
| 20 | 22 | @RegisterExtension |
| 21 | 23 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 22 | | public JOSMTestRules test = new JOSMTestRules().preferences().main(); |
| | 24 | public JOSMTestRules test = new JOSMTestRules().main(); |
| 23 | 25 | |
| 24 | 26 | /** |
| 25 | 27 | * Unit test of {@link ChangesetContentPanel#ChangesetContentPanel}. |
| … |
… |
class ChangesetContentPanelTest {
|
| 29 | 31 | assertNotNull(new ChangesetContentPanel()); |
| 30 | 32 | } |
| 31 | 33 | } |
| | 34 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/layer/CycleLayerActionTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/layer/CycleLayerActionTest.java
index 62febb878c..62cbc6606a 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.gui.dialogs.layer; |
| 3 | 3 | |
| 4 | | import static org.junit.Assert.assertEquals; |
| | 4 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 5 | 5 | import static org.openstreetmap.josm.tools.I18n.tr; |
| 6 | 6 | |
| 7 | | import org.junit.Before; |
| 8 | | import org.junit.Rule; |
| 9 | | import org.junit.Test; |
| | 7 | import org.junit.jupiter.api.BeforeEach; |
| | 8 | import org.junit.jupiter.api.Test; |
| | 9 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 10 | 10 | import org.openstreetmap.josm.data.imagery.ImageryInfo; |
| 11 | 11 | import org.openstreetmap.josm.data.imagery.ImageryLayerInfo; |
| 12 | 12 | import org.openstreetmap.josm.data.osm.DataSet; |
| … |
… |
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 17 | 17 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 18 | 18 | |
| 19 | 19 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 20 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 21 | import org.openstreetmap.josm.testutils.annotations.FakeImagery; |
| 20 | 22 | |
| 21 | 23 | /** |
| 22 | 24 | * Test class for {@link CycleLayerDownAction} |
| 23 | 25 | * |
| 24 | 26 | * @author Taylor Smock |
| 25 | 27 | */ |
| 26 | | public class CycleLayerActionTest { |
| | 28 | @BasicPreferences |
| | 29 | @FakeImagery |
| | 30 | class CycleLayerActionTest { |
| 27 | 31 | /** Layers need a projection */ |
| 28 | | @Rule |
| | 32 | @RegisterExtension |
| 29 | 33 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 30 | | public JOSMTestRules test = new JOSMTestRules().main().preferences().projection().fakeImagery(); |
| | 34 | public JOSMTestRules test = new JOSMTestRules().main().projection(); |
| 31 | 35 | |
| 32 | 36 | private CycleLayerDownAction cycleDown; |
| 33 | 37 | private CycleLayerUpAction cycleUp; |
| … |
… |
public class CycleLayerActionTest {
|
| 36 | 40 | /** |
| 37 | 41 | * Set up common items (make layers, etc.) |
| 38 | 42 | */ |
| 39 | | @Before |
| | 43 | @BeforeEach |
| 40 | 44 | public void setUp() { |
| 41 | 45 | cycleDown = new CycleLayerDownAction(); |
| 42 | 46 | cycleUp = new CycleLayerUpAction(); |
| … |
… |
public class CycleLayerActionTest {
|
| 50 | 54 | * Test going down from the bottom |
| 51 | 55 | */ |
| 52 | 56 | @Test |
| 53 | | public void testDownBottom() { |
| | 57 | void testDownBottom() { |
| 54 | 58 | manager.setActiveLayer(manager.getLayers().get(0)); |
| 55 | 59 | cycleDown.actionPerformed(null); |
| 56 | 60 | assertEquals(manager.getLayers().size() - 1, manager.getLayers().indexOf(manager.getActiveLayer())); |
| … |
… |
public class CycleLayerActionTest {
|
| 60 | 64 | * Check going up from the top |
| 61 | 65 | */ |
| 62 | 66 | @Test |
| 63 | | public void testUpTop() { |
| | 67 | void testUpTop() { |
| 64 | 68 | manager.setActiveLayer(manager.getLayers().get(manager.getLayers().size() - 1)); |
| 65 | 69 | cycleUp.actionPerformed(null); |
| 66 | 70 | assertEquals(0, manager.getLayers().indexOf(manager.getActiveLayer())); |
| … |
… |
public class CycleLayerActionTest {
|
| 70 | 74 | * Check going down |
| 71 | 75 | */ |
| 72 | 76 | @Test |
| 73 | | public void testDown() { |
| | 77 | void testDown() { |
| 74 | 78 | manager.setActiveLayer(manager.getLayers().get(3)); |
| 75 | 79 | cycleDown.actionPerformed(null); |
| 76 | 80 | assertEquals(2, manager.getLayers().indexOf(manager.getActiveLayer())); |
| … |
… |
public class CycleLayerActionTest {
|
| 80 | 84 | * Check going up |
| 81 | 85 | */ |
| 82 | 86 | @Test |
| 83 | | public void testUp() { |
| | 87 | void testUp() { |
| 84 | 88 | manager.setActiveLayer(manager.getLayers().get(3)); |
| 85 | 89 | cycleUp.actionPerformed(null); |
| 86 | 90 | assertEquals(4, manager.getLayers().indexOf(manager.getActiveLayer())); |
| … |
… |
public class CycleLayerActionTest {
|
| 90 | 94 | * Test no layers |
| 91 | 95 | */ |
| 92 | 96 | @Test |
| 93 | | public void testNoLayers() { |
| | 97 | void testNoLayers() { |
| 94 | 98 | manager.getLayers().forEach(manager::removeLayer); |
| 95 | 99 | cycleUp.actionPerformed(null); |
| 96 | 100 | cycleDown.actionPerformed(null); |
| … |
… |
public class CycleLayerActionTest {
|
| 101 | 105 | * Test with an aerial imagery layer |
| 102 | 106 | */ |
| 103 | 107 | @Test |
| 104 | | public void testWithAerialImagery() { |
| | 108 | void testWithAerialImagery() { |
| 105 | 109 | final ImageryInfo magentaTilesInfo = ImageryLayerInfo.instance.getLayers().stream() |
| 106 | 110 | .filter(i -> i.getName().equals("Magenta Tiles")).findAny().get(); |
| 107 | 111 | ImageryLayer imageryLayer = ImageryLayer.create(magentaTilesInfo); |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/layer/DuplicateActionTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/layer/DuplicateActionTest.java
index 0e95c82738..eb55970417 100644
|
a
|
b
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
| 8 | 8 | |
| 9 | 9 | import java.io.InputStream; |
| 10 | 10 | |
| | 11 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 11 | 12 | import org.openstreetmap.josm.TestUtils; |
| 12 | 13 | import org.openstreetmap.josm.gui.MainApplication; |
| 13 | 14 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 14 | 15 | import org.openstreetmap.josm.io.OsmReader; |
| | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 15 | 17 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 16 | 18 | |
| 17 | 19 | import org.junit.jupiter.api.Test; |
| … |
… |
import org.junit.jupiter.api.Test;
|
| 22 | 24 | // TMS layer needs prefs. Platform for LayerListDialog shortcuts. |
| 23 | 25 | @BasicPreferences |
| 24 | 26 | class DuplicateActionTest { |
| | 27 | // Needed for layer cleanup |
| | 28 | @RegisterExtension |
| | 29 | JOSMTestRules rules = new JOSMTestRules(); |
| 25 | 30 | /** |
| 26 | 31 | * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/4539">#4539</a>. |
| 27 | 32 | * @throws Exception if an error occurs |
| … |
… |
class DuplicateActionTest {
|
| 29 | 34 | @Test |
| 30 | 35 | void testTicket4539() throws Exception { |
| 31 | 36 | try (InputStream is = TestUtils.getRegressionDataStream(4539, "josm_error_#4539.osm.zip")) { |
| 32 | | OsmDataLayer layer = new OsmDataLayer(OsmReader.parseDataSet(is, null), null, null); |
| | 37 | OsmDataLayer layer = new OsmDataLayer(OsmReader.parseDataSet(is, null), "DuplicateActionTest#testTicket4539", null); |
| 33 | 38 | OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); |
| 34 | 39 | assertNull(editLayer); |
| 35 | 40 | try { |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityActionTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityActionTest.java
index 1ee10011a2..a9f09a16ce 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.TMSLayerTest;
|
| 16 | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 17 | 17 | |
| 18 | 18 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 19 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Unit tests of {@link LayerVisibilityAction} class. |
| 22 | 23 | */ |
| | 24 | @BasicPreferences |
| 23 | 25 | class LayerVisibilityActionTest { |
| 24 | 26 | /** |
| 25 | 27 | * TMS layer needs prefs. Platform for LayerListDialog shortcuts. |
| 26 | 28 | */ |
| 27 | 29 | @RegisterExtension |
| 28 | 30 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 29 | | public JOSMTestRules test = new JOSMTestRules().preferences().projection().main(); |
| | 31 | public JOSMTestRules test = new JOSMTestRules().projection().main(); |
| 30 | 32 | |
| 31 | 33 | /** |
| 32 | 34 | * Unit test of {@link LayerVisibilityAction} class. |
| … |
… |
class LayerVisibilityActionTest {
|
| 95 | 97 | assertEquals(1.0, layer.getOpacity(), 1e-15); |
| 96 | 98 | } |
| 97 | 99 | } |
| | 100 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRendererTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRendererTest.java
index 61dd6b0dfc..8789edaa7d 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.dialogs.properties;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 5 | 5 | |
| 6 | | import java.util.function.IntFunction; |
| 7 | | |
| 8 | 6 | import javax.swing.JLabel; |
| 9 | 7 | import javax.swing.JTable; |
| 10 | 8 | import javax.swing.table.DefaultTableModel; |
| | 9 | import java.util.function.IntFunction; |
| 11 | 10 | |
| 12 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| 13 | 11 | import org.junit.jupiter.api.Test; |
| 14 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 15 | | |
| 16 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 12 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 17 | 13 | |
| 18 | 14 | /** |
| 19 | 15 | * Unit tests of {@link PropertiesCellRenderer} class. |
| 20 | 16 | */ |
| | 17 | @BasicPreferences |
| 21 | 18 | class PropertiesCellRendererTest { |
| 22 | | |
| 23 | | /** |
| 24 | | * Setup test. |
| 25 | | */ |
| 26 | | @RegisterExtension |
| 27 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 28 | | public JOSMTestRules test = new JOSMTestRules().preferences(); |
| 29 | | |
| 30 | 19 | /** |
| 31 | 20 | * Test of color rendering. |
| 32 | 21 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java
index ac2a9d4628..0863e616cb 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 22 | 22 | import org.openstreetmap.josm.gui.tagging.TagEditorPanel; |
| 23 | 23 | import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; |
| 24 | 24 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 25 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 25 | 26 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 26 | 27 | |
| 27 | 28 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 29 | 30 | /** |
| 30 | 31 | * Unit tests of {@link GenericRelationEditor} class. |
| 31 | 32 | */ |
| | 33 | @BasicPreferences |
| 32 | 34 | public class GenericRelationEditorTest { |
| 33 | 35 | |
| 34 | 36 | /** |
| … |
… |
public class GenericRelationEditorTest {
|
| 36 | 38 | */ |
| 37 | 39 | @RegisterExtension |
| 38 | 40 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 39 | | public JOSMTestRules test = new JOSMTestRules().preferences().main(); |
| | 41 | public JOSMTestRules test = new JOSMTestRules().main(); |
| 40 | 42 | |
| 41 | 43 | /** |
| 42 | 44 | * Returns a new relation editor for unit tests. |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorActionTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorActionTest.java
index 90bd4ec9e7..6ea4fb20f6 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.tagging.TagEditorModel;
|
| 23 | 23 | import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; |
| 24 | 24 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; |
| 25 | 25 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 26 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 26 | 27 | |
| 27 | 28 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 28 | 29 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 31 | 32 | * @author Michael Zangl |
| 32 | 33 | */ |
| 33 | 34 | @Disabled |
| | 35 | @BasicPreferences |
| 34 | 36 | public abstract class AbstractRelationEditorActionTest { |
| 35 | 37 | /** |
| 36 | 38 | * Platform for tooltips. |
| 37 | 39 | */ |
| 38 | 40 | @RegisterExtension |
| 39 | 41 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 40 | | public JOSMTestRules test = new JOSMTestRules().preferences().main(); |
| | 42 | public JOSMTestRules test = new JOSMTestRules().main(); |
| 41 | 43 | |
| 42 | 44 | protected OsmDataLayer layer; |
| 43 | 45 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java
index 398de3afc8..1197c8bb3c 100644
|
a
|
b
|
import javax.swing.text.JTextComponent;
|
| 14 | 14 | import org.junit.jupiter.api.Test; |
| 15 | 15 | import org.openstreetmap.josm.TestUtils; |
| 16 | 16 | import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; |
| | 17 | import org.openstreetmap.josm.testutils.annotations.I18n; |
| 17 | 18 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 18 | 19 | |
| 19 | 20 | import mockit.Mock; |
| … |
… |
import mockit.MockUp;
|
| 22 | 23 | /** |
| 23 | 24 | * Unit tests for relation editor actions. |
| 24 | 25 | */ |
| | 26 | @I18n |
| 25 | 27 | class RelationEditorActionsTest extends AbstractRelationEditorActionTest { |
| 26 | 28 | |
| 27 | 29 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
index c48563391a..19d6cb4a6a 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
| 18 | 18 | import org.openstreetmap.josm.io.IllegalDataException; |
| 19 | 19 | import org.openstreetmap.josm.io.OsmReader; |
| 20 | 20 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 21 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 21 | 22 | |
| 22 | 23 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 23 | 24 | |
| 24 | 25 | /** |
| 25 | 26 | * Unit tests of {@link RelationSorter} class. |
| 26 | 27 | */ |
| | 28 | @BasicPreferences |
| 27 | 29 | class RelationSorterTest { |
| 28 | 30 | |
| 29 | 31 | private final RelationSorter sorter = new RelationSorter(); |
| … |
… |
class RelationSorterTest {
|
| 34 | 36 | */ |
| 35 | 37 | @RegisterExtension |
| 36 | 38 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 37 | | public JOSMTestRules test = new JOSMTestRules().preferences().projection(); |
| | 39 | public JOSMTestRules test = new JOSMTestRules().projection(); |
| 38 | 40 | |
| 39 | 41 | /** |
| 40 | 42 | * Load the test data set |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java
index 624b829e22..e0d30efcc3 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
| 24 | 24 | import org.openstreetmap.josm.io.IllegalDataException; |
| 25 | 25 | import org.openstreetmap.josm.io.OsmReader; |
| 26 | 26 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 27 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 27 | 28 | |
| 28 | 29 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 29 | 30 | |
| 30 | 31 | /** |
| 31 | 32 | * Unit tests of {@link WayConnectionTypeCalculator} class. |
| 32 | 33 | */ |
| | 34 | @BasicPreferences |
| 33 | 35 | class WayConnectionTypeCalculatorTest { |
| 34 | 36 | |
| 35 | 37 | private final RelationSorter sorter = new RelationSorter(); |
| … |
… |
class WayConnectionTypeCalculatorTest {
|
| 41 | 43 | */ |
| 42 | 44 | @RegisterExtension |
| 43 | 45 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 44 | | public JOSMTestRules test = new JOSMTestRules().preferences().projection(); |
| | 46 | public JOSMTestRules test = new JOSMTestRules().projection(); |
| 45 | 47 | |
| 46 | 48 | /** |
| 47 | 49 | * Load the test data set |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java b/test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java
index 0eb9f795bb..2293527eee 100644
|
a
|
b
|
import org.junit.jupiter.api.Test;
|
| 12 | 12 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 13 | 13 | import org.openstreetmap.josm.TestUtils; |
| 14 | 14 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 15 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 15 | 16 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 16 | 17 | import org.openstreetmap.josm.tools.LanguageInfo.LocaleType; |
| 17 | 18 | import org.openstreetmap.josm.tools.PlatformHook; |
| … |
… |
import mockit.Mocked;
|
| 25 | 26 | /** |
| 26 | 27 | * Unit tests of {@link HelpBrowser} class. |
| 27 | 28 | */ |
| | 29 | @BasicPreferences |
| 28 | 30 | class HelpBrowserTest { |
| 29 | 31 | |
| 30 | 32 | static final String URL_1 = "https://josm.openstreetmap.de/wiki/Help"; |
| … |
… |
class HelpBrowserTest {
|
| 36 | 38 | */ |
| 37 | 39 | @RegisterExtension |
| 38 | 40 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 39 | | static JOSMTestRules test = new JOSMTestRules().preferences().https(); |
| | 41 | static JOSMTestRules test = new JOSMTestRules().https(); |
| 40 | 42 | |
| 41 | 43 | static IHelpBrowser newHelpBrowser() { |
| 42 | 44 | return new IHelpBrowser() { |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserModelTest.java b/test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserModelTest.java
index 2be15c5a66..6331442a04 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.history.History;
|
| 17 | 17 | import org.openstreetmap.josm.data.osm.history.HistoryDataSet; |
| 18 | 18 | import org.openstreetmap.josm.data.osm.history.HistoryNode; |
| 19 | 19 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 20 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 20 | 21 | |
| 21 | 22 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 22 | 23 | |
| … |
… |
import java.awt.Color;
|
| 25 | 26 | /** |
| 26 | 27 | * Unit tests of {@link HistoryBrowserModel} class. |
| 27 | 28 | */ |
| | 29 | @BasicPreferences |
| 28 | 30 | class HistoryBrowserModelTest { |
| 29 | 31 | |
| 30 | 32 | /** |
| … |
… |
class HistoryBrowserModelTest {
|
| 32 | 34 | */ |
| 33 | 35 | @RegisterExtension |
| 34 | 36 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 35 | | public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(30000); |
| | 37 | public JOSMTestRules test = new JOSMTestRules().devAPI().timeout(30000); |
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * Test for {@link HistoryBrowserModel#HistoryBrowserModel}. |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/history/HistoryLoadTaskTest.java b/test/unit/org/openstreetmap/josm/gui/history/HistoryLoadTaskTest.java
index 86997dfbce..917aedf335 100644
|
a
|
b
|
import org.openstreetmap.josm.io.OsmHistoryReader;
|
| 22 | 22 | import org.openstreetmap.josm.io.OsmServerHistoryReader; |
| 23 | 23 | import org.openstreetmap.josm.io.OsmTransferException; |
| 24 | 24 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 25 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 25 | 26 | import org.xml.sax.SAXException; |
| 26 | 27 | |
| 27 | 28 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 29 | 30 | /** |
| 30 | 31 | * Unit tests of {@link HistoryLoadTask} class. |
| 31 | 32 | */ |
| | 33 | @BasicPreferences |
| 32 | 34 | class HistoryLoadTaskTest { |
| 33 | 35 | |
| 34 | 36 | /** |
| … |
… |
class HistoryLoadTaskTest {
|
| 36 | 38 | */ |
| 37 | 39 | @RegisterExtension |
| 38 | 40 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 39 | | public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(20000); |
| | 41 | public JOSMTestRules test = new JOSMTestRules().devAPI().timeout(20000); |
| 40 | 42 | |
| 41 | 43 | /** |
| 42 | 44 | * Unit test of {@link HistoryLoadTask#getLoadingMessage} |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java b/test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java
index 16d0dcf978..2eac67759f 100644
|
a
|
b
|
import org.openstreetmap.josm.TestUtils;
|
| 19 | 19 | import org.openstreetmap.josm.data.UserIdentityManager; |
| 20 | 20 | import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard; |
| 21 | 21 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 22 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 22 | 23 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 23 | 24 | import org.openstreetmap.josm.testutils.mockers.WindowMocker; |
| 24 | 25 | import org.openstreetmap.josm.tools.UserCancelException; |
| … |
… |
import mockit.MockUp;
|
| 31 | 32 | /** |
| 32 | 33 | * Unit tests of {@link DownloadOpenChangesetsTask} class. |
| 33 | 34 | */ |
| | 35 | @BasicPreferences |
| 34 | 36 | class DownloadOpenChangesetsTaskTest { |
| 35 | 37 | |
| 36 | 38 | /** |
| … |
… |
class DownloadOpenChangesetsTaskTest {
|
| 38 | 40 | */ |
| 39 | 41 | @RegisterExtension |
| 40 | 42 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 41 | | public JOSMTestRules test = new JOSMTestRules().preferences().devAPI(); |
| | 43 | public JOSMTestRules test = new JOSMTestRules().devAPI(); |
| 42 | 44 | |
| 43 | 45 | /** |
| 44 | 46 | * OAuth wizard mocker. |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/io/DownloadPrimitivesTaskTest.java b/test/unit/org/openstreetmap/josm/gui/io/DownloadPrimitivesTaskTest.java
index 47695f6758..43e197c602 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
|
| 14 | 14 | import org.openstreetmap.josm.data.osm.SimplePrimitiveId; |
| 15 | 15 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 16 | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 17 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 17 | 18 | |
| 18 | 19 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Unit tests of {@link DownloadPrimitivesTask} class. |
| 22 | 23 | */ |
| | 24 | @BasicPreferences |
| 23 | 25 | class DownloadPrimitivesTaskTest { |
| 24 | 26 | |
| 25 | 27 | /** |
| … |
… |
class DownloadPrimitivesTaskTest {
|
| 27 | 29 | */ |
| 28 | 30 | @RegisterExtension |
| 29 | 31 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 30 | | public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(20000); |
| | 32 | public JOSMTestRules test = new JOSMTestRules().devAPI().timeout(20000); |
| 31 | 33 | |
| 32 | 34 | /** |
| 33 | 35 | * Test of {@link DownloadPrimitivesTask} class. |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/io/UploadDialogModelTest.java b/test/unit/org/openstreetmap/josm/gui/io/UploadDialogModelTest.java
index 9223ca87dd..bb08f7221c 100644
|
a
|
b
|
import org.junit.jupiter.api.Test;
|
| 10 | 10 | |
| 11 | 11 | import org.openstreetmap.josm.data.osm.DataSet; |
| 12 | 12 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 13 | 14 | |
| 14 | 15 | /** |
| 15 | 16 | * Unit tests of {@link UploadDialogModel} class. |
| 16 | 17 | */ |
| | 18 | @BasicPreferences |
| 17 | 19 | public class UploadDialogModelTest { |
| 18 | 20 | /** |
| 19 | 21 | * Setup tests |
| 20 | 22 | */ |
| 21 | 23 | @RegisterExtension |
| 22 | | public JOSMTestRules test = new JOSMTestRules().preferences().main(); |
| | 24 | public JOSMTestRules test = new JOSMTestRules().main(); |
| 23 | 25 | |
| 24 | 26 | /** |
| 25 | 27 | * Test of {@link UploadDialogModel}. |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanelTest.java b/test/unit/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanelTest.java
index 2f46704710..84a910aa56 100644
|
a
|
b
|
import org.junit.jupiter.api.Test;
|
| 8 | 8 | import org.openstreetmap.josm.io.UploadStrategy; |
| 9 | 9 | import org.openstreetmap.josm.io.UploadStrategySpecification; |
| 10 | 10 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 11 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 11 | 12 | |
| 12 | 13 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 13 | 14 | |
| 14 | 15 | /** |
| 15 | 16 | * Unit tests of {@link UploadStrategySelectionPanel} class. |
| 16 | 17 | */ |
| | 18 | @BasicPreferences |
| 17 | 19 | class UploadStrategySelectionPanelTest { |
| 18 | 20 | |
| 19 | 21 | /** |
| … |
… |
class UploadStrategySelectionPanelTest {
|
| 21 | 23 | */ |
| 22 | 24 | @RegisterExtension |
| 23 | 25 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 24 | | public JOSMTestRules test = new JOSMTestRules().preferences().devAPI(); |
| | 26 | public JOSMTestRules test = new JOSMTestRules().devAPI(); |
| 25 | 27 | |
| 26 | 28 | /** |
| 27 | 29 | * Test of {@link UploadStrategySelectionPanel#UploadStrategySelectionPanel}. |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayerTest.java
index 14ebf64641..a13482bc04 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.DataSet;
|
| 32 | 32 | import org.openstreetmap.josm.gui.MainApplication; |
| 33 | 33 | import org.openstreetmap.josm.gui.layer.imagery.ImageryFilterSettings; |
| 34 | 34 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 35 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 35 | 36 | |
| 36 | 37 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 37 | 38 | |
| 38 | 39 | /** |
| 39 | 40 | * Test of the base {@link AbstractTileSourceLayer} class |
| 40 | 41 | */ |
| | 42 | @BasicPreferences |
| 41 | 43 | class AbstractTileSourceLayerTest { |
| 42 | 44 | |
| 43 | 45 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/AutosaveTaskTest.java b/test/unit/org/openstreetmap/josm/gui/layer/AutosaveTaskTest.java
index fa84a4ae91..6ada037c62 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.Node;
|
| 29 | 29 | import org.openstreetmap.josm.gui.MainApplication; |
| 30 | 30 | import org.openstreetmap.josm.gui.layer.AutosaveTask.AutosaveLayerInfo; |
| 31 | 31 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 32 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 32 | 33 | |
| 33 | 34 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 34 | 35 | |
| 35 | 36 | /** |
| 36 | 37 | * Unit tests for class {@link AutosaveTask}. |
| 37 | 38 | */ |
| | 39 | @BasicPreferences |
| 38 | 40 | class AutosaveTaskTest { |
| 39 | 41 | /** |
| 40 | 42 | * We need preferences and a home directory for this. |
| 41 | 43 | */ |
| 42 | 44 | @RegisterExtension |
| 43 | 45 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 44 | | public JOSMTestRules test = new JOSMTestRules().preferences().projection(); |
| | 46 | public JOSMTestRules test = new JOSMTestRules().projection(); |
| 45 | 47 | |
| 46 | 48 | private AutosaveTask task; |
| 47 | 49 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java
index 98fe1f676d..74d921f986 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.MainApplication;
|
| 35 | 35 | import org.openstreetmap.josm.gui.widgets.HtmlPanel; |
| 36 | 36 | import org.openstreetmap.josm.io.GpxReaderTest; |
| 37 | 37 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 38 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 38 | 39 | import org.openstreetmap.josm.tools.date.DateUtils; |
| 39 | 40 | import org.xml.sax.SAXException; |
| 40 | 41 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 43 | 44 | /** |
| 44 | 45 | * Unit tests of {@link GpxLayer} class. |
| 45 | 46 | */ |
| | 47 | @BasicPreferences |
| 46 | 48 | public class GpxLayerTest { |
| 47 | 49 | |
| 48 | 50 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java
index 102a629a5e..d3f8160e3a 100644
|
a
|
b
|
import org.junit.jupiter.api.Test;
|
| 14 | 14 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 15 | 15 | import org.openstreetmap.josm.data.projection.ProjectionRegistry; |
| 16 | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 17 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 17 | 18 | |
| 18 | 19 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 19 | 20 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 21 | 22 | * Test of the base {@link Layer} class |
| 22 | 23 | * @author Michael Zangl |
| 23 | 24 | */ |
| | 25 | @BasicPreferences |
| 24 | 26 | class LayerTest { |
| 25 | 27 | /** |
| 26 | 28 | * We need projection |
| 27 | 29 | */ |
| 28 | 30 | @RegisterExtension |
| 29 | 31 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 30 | | public JOSMTestRules test = new JOSMTestRules().preferences().projection(); |
| | 32 | public JOSMTestRules test = new JOSMTestRules().projection(); |
| 31 | 33 | |
| 32 | 34 | private Layer testLayer; |
| 33 | 35 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
index 7629c1318d..70f46f655e 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
|
| 35 | 35 | import org.openstreetmap.josm.io.IllegalDataException; |
| 36 | 36 | import org.openstreetmap.josm.io.OsmReader; |
| 37 | 37 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 38 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 38 | 39 | import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; |
| 39 | 40 | import org.openstreetmap.josm.tools.Logging; |
| 40 | 41 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 43 | 44 | /** |
| 44 | 45 | * Unit tests of {@link OsmDataLayer} class. |
| 45 | 46 | */ |
| | 47 | @BasicPreferences |
| 46 | 48 | class OsmDataLayerTest { |
| 47 | 49 | |
| 48 | 50 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/TMSLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/TMSLayerTest.java
index e1c21890e7..f448860786 100644
|
a
|
b
|
import org.openstreetmap.josm.data.imagery.ImageryInfo;
|
| 9 | 9 | import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; |
| 10 | 10 | import org.openstreetmap.josm.gui.MainApplication; |
| 11 | 11 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 12 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 12 | 13 | |
| 13 | 14 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * Unit tests of {@link TMSLayer} class. |
| 17 | 18 | */ |
| | 19 | @BasicPreferences |
| 18 | 20 | public class TMSLayerTest { |
| 19 | 21 | |
| 20 | 22 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/ValidatorLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/ValidatorLayerTest.java
index 0f1f9444f3..759a8ef880 100644
|
a
|
b
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
| 6 | 6 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 7 | 7 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| 8 | 8 | |
| 9 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| 10 | 9 | import org.junit.jupiter.api.Test; |
| | 10 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 11 | 11 | import org.openstreetmap.josm.data.osm.DataSet; |
| 12 | 12 | import org.openstreetmap.josm.gui.MainApplication; |
| 13 | 13 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 14 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 14 | 15 | |
| 15 | 16 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Unit tests of {@link ValidatorLayer} class. |
| 19 | 20 | */ |
| | 21 | @BasicPreferences |
| 20 | 22 | class ValidatorLayerTest { |
| 21 | 23 | |
| 22 | 24 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/WMSLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/WMSLayerTest.java
index b3a72a5129..bbfbb3f773 100644
|
a
|
b
|
import org.openstreetmap.josm.data.imagery.ImageryInfo;
|
| 10 | 10 | import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; |
| 11 | 11 | import org.openstreetmap.josm.gui.MainApplication; |
| 12 | 12 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 13 | 14 | |
| 14 | 15 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 15 | 16 | |
| 16 | 17 | /** |
| 17 | 18 | * Unit tests of {@link WMSLayer} class. |
| 18 | 19 | */ |
| | 20 | @BasicPreferences |
| 19 | 21 | class WMSLayerTest { |
| 20 | 22 | |
| 21 | 23 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/WMTSLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/WMTSLayerTest.java
index 225dd0bc6a..af264a0538 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.layer;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| | 7 | import org.junit.jupiter.api.Timeout; |
| 8 | 8 | import org.openstreetmap.josm.data.imagery.ImageryInfo; |
| 9 | 9 | import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; |
| 10 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 11 | | |
| 12 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 10 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 13 | 11 | |
| 14 | 12 | /** |
| 15 | 13 | * Unit tests of {@link WMTSLayer} class. |
| 16 | 14 | */ |
| | 15 | @BasicPreferences |
| | 16 | @Timeout(20) |
| 17 | 17 | class WMTSLayerTest { |
| 18 | | |
| 19 | | /** |
| 20 | | * Setup tests |
| 21 | | */ |
| 22 | | @RegisterExtension |
| 23 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 24 | | public JOSMTestRules test = new JOSMTestRules().preferences().timeout(20000); |
| 25 | | |
| 26 | 18 | /** |
| 27 | 19 | * Unit test of {@link WMTSLayer#WMTSLayer}. |
| 28 | 20 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoaderTest.java b/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoaderTest.java
index 23f26d730e..c46015e625 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.MainApplication;
|
| 16 | 16 | import org.openstreetmap.josm.gui.layer.GpxLayer; |
| 17 | 17 | import org.openstreetmap.josm.io.GpxReader; |
| 18 | 18 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 19 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 19 | 20 | |
| 20 | 21 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | 24 | * Unit tests of {@link ImagesLoader} class. |
| 24 | 25 | */ |
| | 26 | @BasicPreferences |
| 25 | 27 | class ImagesLoaderTest { |
| 26 | 28 | |
| 27 | 29 | /** |
| 28 | | * We need prefs for this. |
| | 30 | * We need prefs for this. And it also cleans up the layers. |
| 29 | 31 | */ |
| 30 | 32 | @RegisterExtension |
| 31 | 33 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 32 | | public JOSMTestRules test = new JOSMTestRules().preferences(); |
| | 34 | public JOSMTestRules test = new JOSMTestRules(); |
| 33 | 35 | |
| 34 | 36 | /** |
| 35 | 37 | * Unit test of {@link ImagesLoader} class. |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java b/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java
index a824478ab3..32eb057cff 100644
|
a
|
b
|
import java.util.Objects;
|
| 15 | 15 | import java.util.stream.Collectors; |
| 16 | 16 | |
| 17 | 17 | import org.junit.jupiter.api.Test; |
| 18 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| 19 | 18 | import org.openstreetmap.josm.TestUtils; |
| 20 | 19 | import org.openstreetmap.josm.data.coor.LatLon; |
| 21 | 20 | import org.openstreetmap.josm.data.gpx.GpxData; |
| … |
… |
import org.openstreetmap.josm.io.GpxReaderTest;
|
| 28 | 27 | import org.openstreetmap.josm.io.IllegalDataException; |
| 29 | 28 | import org.openstreetmap.josm.io.OsmReader; |
| 30 | 29 | import org.openstreetmap.josm.spi.preferences.Config; |
| 31 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 30 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 32 | 31 | import org.xml.sax.SAXException; |
| 33 | 32 | |
| 34 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 35 | | |
| 36 | 33 | /** |
| 37 | 34 | * Unit tests of {@link ConvertToDataLayerAction} class. |
| 38 | 35 | */ |
| | 36 | @BasicPreferences |
| 39 | 37 | public class ConvertToDataLayerActionTest { |
| 40 | | |
| 41 | | /** |
| 42 | | * Setup test. |
| 43 | | */ |
| 44 | | @RegisterExtension |
| 45 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 46 | | public JOSMTestRules test = new JOSMTestRules(); |
| 47 | | |
| 48 | 38 | /** |
| 49 | 39 | * Tests a conversion from a GPX marker layer to a OSM dataset |
| 50 | 40 | * @throws Exception if the parsing fails |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java b/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java
index d0ccb1be8b..67242fbb15 100644
|
a
|
b
|
|
| 2 | 2 | package org.openstreetmap.josm.gui.layer.gpx; |
| 3 | 3 | |
| 4 | 4 | import static java.util.concurrent.TimeUnit.MILLISECONDS; |
| 5 | | import static org.junit.Assert.assertEquals; |
| 6 | | import static org.junit.Assert.assertNotNull; |
| 7 | | import static org.junit.Assert.assertNull; |
| 8 | | import static org.junit.Assert.assertTrue; |
| | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | 6 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| | 7 | import static org.junit.jupiter.api.Assertions.assertNull; |
| | 8 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| 9 | 9 | |
| 10 | 10 | import java.util.Collections; |
| | 11 | import java.util.List; |
| 11 | 12 | |
| 12 | 13 | import org.awaitility.Awaitility; |
| 13 | | import org.junit.Rule; |
| 14 | | import org.junit.Test; |
| | 14 | import org.junit.jupiter.api.Test; |
| | 15 | import org.junit.jupiter.api.extension.RegisterExtension; |
| | 16 | import org.openstreetmap.josm.TestUtils; |
| 15 | 17 | import org.openstreetmap.josm.actions.MergeLayerActionTest.MergeLayerExtendedDialogMocker; |
| 16 | 18 | import org.openstreetmap.josm.data.gpx.GpxData; |
| 17 | 19 | import org.openstreetmap.josm.gui.MainApplication; |
| 18 | 20 | import org.openstreetmap.josm.gui.layer.GpxLayerTest; |
| 19 | 21 | import org.openstreetmap.josm.gui.layer.TMSLayer; |
| 20 | 22 | import org.openstreetmap.josm.gui.layer.gpx.DownloadWmsAlongTrackAction.PrecacheWmsTask; |
| 21 | | import org.openstreetmap.josm.TestUtils; |
| 22 | 23 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 23 | | import org.openstreetmap.josm.testutils.TileSourceRule; |
| | 24 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 25 | import org.openstreetmap.josm.testutils.annotations.BasicWiremock; |
| | 26 | import org.openstreetmap.josm.testutils.annotations.FakeImagery; |
| | 27 | import org.openstreetmap.josm.testutils.annotations.fake_imagery.ConstSource; |
| 24 | 28 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 25 | 29 | |
| | 30 | import com.github.tomakehurst.wiremock.WireMockServer; |
| | 31 | |
| 26 | 32 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 27 | 33 | |
| 28 | 34 | /** |
| 29 | 35 | * Unit tests of {@link DownloadWmsAlongTrackAction} class. |
| 30 | 36 | */ |
| 31 | | public class DownloadWmsAlongTrackActionTest { |
| | 37 | @BasicPreferences |
| | 38 | @FakeImagery |
| | 39 | class DownloadWmsAlongTrackActionTest { |
| 32 | 40 | |
| 33 | 41 | /** |
| 34 | 42 | * Setup test. |
| 35 | 43 | */ |
| 36 | | @Rule |
| | 44 | @RegisterExtension |
| 37 | 45 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 38 | 46 | public JOSMTestRules test = new JOSMTestRules().main().projection().fakeImagery().timeout(20000); |
| 39 | 47 | |
| … |
… |
public class DownloadWmsAlongTrackActionTest {
|
| 41 | 49 | * Test action without layer. |
| 42 | 50 | */ |
| 43 | 51 | @Test |
| 44 | | public void testNoLayer() { |
| | 52 | void testNoLayer() { |
| 45 | 53 | TestUtils.assumeWorkingJMockit(); |
| 46 | 54 | final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker( |
| 47 | 55 | Collections.singletonMap("There are no imagery layers.", 0) |
| … |
… |
public class DownloadWmsAlongTrackActionTest {
|
| 60 | 68 | * @throws Exception if an error occurs |
| 61 | 69 | */ |
| 62 | 70 | @Test |
| 63 | | public void testTMSLayer() throws Exception { |
| | 71 | void testTMSLayer(@BasicWiremock final WireMockServer wireMockServer, |
| | 72 | @FakeImagery final List<ConstSource> constSources) throws Exception { |
| 64 | 73 | TestUtils.assumeWorkingJMockit(); |
| 65 | 74 | final MergeLayerExtendedDialogMocker edMocker = new MergeLayerExtendedDialogMocker(); |
| 66 | 75 | edMocker.getMockResultMap().put("Please select the imagery layer.", "Download"); |
| 67 | 76 | |
| 68 | | final TileSourceRule tileSourceRule = this.test.getTileSourceRule(); |
| 69 | | |
| 70 | 77 | final TMSLayer layer = new TMSLayer( |
| 71 | | tileSourceRule.getSourcesList().get(0).getImageryInfo(tileSourceRule.port()) |
| | 78 | constSources.get(0).getImageryInfo(wireMockServer) |
| 72 | 79 | ); |
| 73 | 80 | try { |
| 74 | 81 | MainApplication.getLayerManager().addLayer(layer); |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelperTest.java b/test/unit/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelperTest.java
index 839fbdd7dc..72a9f32abb 100644
|
a
|
b
|
import java.util.List;
|
| 11 | 11 | import java.util.Map; |
| 12 | 12 | import java.util.stream.Collectors; |
| 13 | 13 | |
| 14 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| 15 | 14 | import org.junit.jupiter.api.Test; |
| 16 | 15 | import org.openstreetmap.josm.TestUtils; |
| 17 | 16 | import org.openstreetmap.josm.data.gpx.GpxData; |
| 18 | 17 | import org.openstreetmap.josm.gui.layer.GpxLayer; |
| 19 | 18 | import org.openstreetmap.josm.gui.layer.gpx.GpxDrawHelper.ColorMode; |
| 20 | 19 | import org.openstreetmap.josm.io.GpxReaderTest; |
| 21 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 20 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 22 | 21 | import org.openstreetmap.josm.tools.ColorHelper; |
| 23 | 22 | import org.xml.sax.SAXException; |
| 24 | 23 | |
| 25 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 26 | | |
| 27 | 24 | /** |
| 28 | 25 | * Unit tests of {@link GpxDrawHelper} class. |
| 29 | 26 | */ |
| | 27 | @BasicPreferences |
| 30 | 28 | class GpxDrawHelperTest { |
| 31 | | |
| 32 | | /** |
| 33 | | * Setup test. |
| 34 | | */ |
| 35 | | @RegisterExtension |
| 36 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 37 | | public JOSMTestRules test = new JOSMTestRules(); |
| 38 | | |
| 39 | 29 | /** |
| 40 | 30 | * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12312">#12312</a>. |
| 41 | 31 | * @throws IOException if any I/O error occurs |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarkerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarkerTest.java
index ea04e500e3..7d7b0edc91 100644
|
a
|
b
|
import org.openstreetmap.josm.JOSMFixture;
|
| 12 | 12 | import org.openstreetmap.josm.data.coor.LatLon; |
| 13 | 13 | import org.openstreetmap.josm.data.gpx.GpxData; |
| 14 | 14 | import org.openstreetmap.josm.data.gpx.WayPoint; |
| | 15 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 15 | 16 | |
| 16 | 17 | /** |
| 17 | 18 | * Unit tests of {@link AudioMarker} class. |
| 18 | 19 | */ |
| | 20 | @BasicPreferences |
| 19 | 21 | class AudioMarkerTest { |
| 20 | 22 | |
| 21 | 23 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarkerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarkerTest.java
index 0df5962e39..4cc210bf3d 100644
|
a
|
b
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
| 6 | 6 | import java.net.MalformedURLException; |
| 7 | 7 | import java.net.URL; |
| 8 | 8 | |
| 9 | | import org.junit.jupiter.api.BeforeAll; |
| 10 | 9 | import org.junit.jupiter.api.Test; |
| 11 | | import org.openstreetmap.josm.JOSMFixture; |
| 12 | 10 | import org.openstreetmap.josm.data.coor.LatLon; |
| 13 | 11 | import org.openstreetmap.josm.data.gpx.GpxData; |
| 14 | 12 | import org.openstreetmap.josm.data.gpx.WayPoint; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 15 | 14 | |
| 16 | 15 | /** |
| 17 | 16 | * Unit tests of {@link ImageMarker} class. |
| 18 | 17 | */ |
| | 18 | @BasicPreferences |
| 19 | 19 | class ImageMarkerTest { |
| 20 | | |
| 21 | | /** |
| 22 | | * Setup tests |
| 23 | | */ |
| 24 | | @BeforeAll |
| 25 | | public static void setUpBeforeClass() { |
| 26 | | JOSMFixture.createUnitTestFixture().init(); |
| 27 | | } |
| 28 | | |
| 29 | 20 | /** |
| 30 | 21 | * Unit test of {@link ImageMarker#ImageMarker}. |
| 31 | 22 | * @throws MalformedURLException never |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayerTest.java
index c6931ec939..bba9167890 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.MapFrame;
|
| 22 | 22 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 23 | 23 | import org.openstreetmap.josm.spi.preferences.Config; |
| 24 | 24 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 25 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 25 | 26 | |
| 26 | 27 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 27 | 28 | |
| 28 | 29 | /** |
| 29 | 30 | * Unit tests of {@link MarkerLayer} class. |
| 30 | 31 | */ |
| | 32 | @BasicPreferences |
| 31 | 33 | class MarkerLayerTest { |
| 32 | 34 | |
| 33 | 35 | /** |
| … |
… |
class MarkerLayerTest {
|
| 35 | 37 | */ |
| 36 | 38 | @RegisterExtension |
| 37 | 39 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 38 | | public JOSMTestRules test = new JOSMTestRules().main().preferences().projection(); |
| | 40 | public JOSMTestRules test = new JOSMTestRules().main().projection(); |
| 39 | 41 | |
| 40 | 42 | /** |
| 41 | 43 | * Setup tests |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/WebMarkerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/WebMarkerTest.java
index 21ce309d49..5acc1dbb4f 100644
|
a
|
b
|
import org.openstreetmap.josm.data.coor.LatLon;
|
| 12 | 12 | import org.openstreetmap.josm.data.gpx.GpxData; |
| 13 | 13 | import org.openstreetmap.josm.data.gpx.WayPoint; |
| 14 | 14 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 15 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 15 | 16 | import org.openstreetmap.josm.tools.PlatformManager; |
| 16 | 17 | import org.openstreetmap.josm.tools.PlatformHook; |
| 17 | 18 | |
| … |
… |
import mockit.Mocked;
|
| 24 | 25 | /** |
| 25 | 26 | * Unit tests of {@link WebMarker} class. |
| 26 | 27 | */ |
| | 28 | @BasicPreferences |
| 27 | 29 | class WebMarkerTest { |
| 28 | 30 | |
| 29 | 31 | /** |
| … |
… |
class WebMarkerTest {
|
| 31 | 33 | */ |
| 32 | 34 | @RegisterExtension |
| 33 | 35 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 34 | | public JOSMTestRules test = new JOSMTestRules().preferences().https(); |
| | 36 | public JOSMTestRules test = new JOSMTestRules().https(); |
| 35 | 37 | |
| 36 | 38 | /** |
| 37 | 39 | * Unit test of {@link WebMarker#WebMarker}. |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/AllMapCSSTests.java b/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/AllMapCSSTests.java
index bbb7fe4ea1..6d040e3089 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.gui.mappaint.mapcss; |
| 3 | 3 | |
| 4 | | import org.junit.runner.RunWith; |
| 5 | | import org.junit.runners.Suite; |
| | 4 | import org.junit.platform.suite.api.SelectClasses; |
| 6 | 5 | |
| 7 | 6 | /** |
| 8 | 7 | * All MapCSS tests. |
| 9 | 8 | */ |
| 10 | | @RunWith(Suite.class) |
| 11 | | @Suite.SuiteClasses({ |
| | 9 | @SelectClasses({ |
| 12 | 10 | KeyValueConditionTest.class, |
| 13 | 11 | ParsingLinkSelectorTest.class, |
| 14 | 12 | KeyConditionTest.class, |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTestIT.java b/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTestIT.java
index 6db613fbe7..5561a0a99c 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser;
|
| 8 | 8 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 9 | 9 | |
| 10 | 10 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 11 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * Integration tests of {@link MapCSSParser}. |
| 14 | 15 | */ |
| | 16 | @IntegrationTest |
| 15 | 17 | class MapCSSParserTestIT { |
| 16 | 18 | |
| 17 | 19 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java
index f9be2da17a..dc36fb24e2 100644
|
a
|
b
|
import org.junit.jupiter.api.Test;
|
| 10 | 10 | import org.openstreetmap.josm.TestUtils; |
| 11 | 11 | import org.openstreetmap.josm.data.Preferences; |
| 12 | 12 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 13 | 14 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 14 | 15 | |
| 15 | 16 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 17 | 18 | /** |
| 18 | 19 | * Unit tests of {@link ExportProfileAction} class. |
| 19 | 20 | */ |
| | 21 | @BasicPreferences |
| 20 | 22 | class ExportProfileActionTest { |
| 21 | 23 | /** |
| 22 | 24 | * Setup tests |
| 23 | 25 | */ |
| 24 | 26 | @RegisterExtension |
| 25 | 27 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 26 | | public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT(); |
| | 28 | public JOSMTestRules test = new JOSMTestRules().assertionsInEDT(); |
| 27 | 29 | |
| 28 | 30 | /** |
| 29 | 31 | * Unit test of {@link ExportProfileAction#actionPerformed}. |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTableTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTableTest.java
index 2264a2fe05..cd6c540c9d 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.ExtendedDialog;
|
| 17 | 17 | import org.openstreetmap.josm.gui.preferences.advanced.PreferencesTable.AllSettingsTableModel; |
| 18 | 18 | import org.openstreetmap.josm.spi.preferences.StringSetting; |
| 19 | 19 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 20 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 20 | 21 | import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; |
| 21 | 22 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 22 | 23 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 25 | 26 | /** |
| 26 | 27 | * Unit tests of {@link PreferencesTable} class. |
| 27 | 28 | */ |
| | 29 | @BasicPreferences |
| 28 | 30 | class PreferencesTableTest { |
| 29 | 31 | /** |
| 30 | 32 | * Setup tests |
| 31 | 33 | */ |
| 32 | 34 | @RegisterExtension |
| 33 | 35 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 34 | | public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT(); |
| | 36 | public JOSMTestRules test = new JOSMTestRules().assertionsInEDT(); |
| 35 | 37 | |
| 36 | 38 | private static PrefEntry newPrefEntry(String value) { |
| 37 | 39 | StringSetting val = new StringSetting(value); |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/ColorPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/ColorPreferenceTest.java
index 3cc1540cb4..6627aa4bb5 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.display;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link ColorPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class ColorPreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link ColorPreference#ColorPreference}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/DisplayPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/DisplayPreferenceTest.java
index 7d95ab5400..eefb29741c 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.display;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link DisplayPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class DisplayPreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link DisplayPreference#DisplayPreference}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/DrawingPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/DrawingPreferenceTest.java
index c8036c2d31..b882415357 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.display;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link DrawingPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class DrawingPreferenceTest { |
| 15 | 15 | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 16 | /** |
| 25 | 17 | * Unit test of {@link DrawingPreference#DrawingPreference}. |
| 26 | 18 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/GPXPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/GPXPreferenceTest.java
index 7346bb118c..4c1fa12965 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.display;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link GPXPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class GPXPreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link GPXPreference.Factory}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/LafPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/LafPreferenceTest.java
index bb0e1e37f7..16145335a5 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.display;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link LafPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class LafPreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link LafPreference#LafPreference}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/LanguagePreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/LanguagePreferenceTest.java
index f1ff6df7b2..8844d1856e 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.display;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link LanguagePreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class LanguagePreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link LanguagePreference#LanguagePreference}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTest.java
index fe01b7e3b6..d1467f6d89 100644
|
a
|
b
|
import org.openstreetmap.josm.TestUtils;
|
| 12 | 12 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| 13 | 13 | import org.openstreetmap.josm.spi.preferences.Config; |
| 14 | 14 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 15 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 15 | 16 | |
| 16 | 17 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Unit tests of {@link ImageryPreference} class. |
| 20 | 21 | */ |
| | 22 | @BasicPreferences |
| 21 | 23 | class ImageryPreferenceTest { |
| 22 | 24 | |
| 23 | 25 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java b/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
index e667e2310b..6d2d350108 100644
|
a
|
b
|
import org.openstreetmap.josm.data.projection.Projections;
|
| 65 | 65 | import org.openstreetmap.josm.io.imagery.ApiKeyProvider; |
| 66 | 66 | import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException; |
| 67 | 67 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 68 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 68 | 69 | import org.openstreetmap.josm.tools.HttpClient; |
| 69 | 70 | import org.openstreetmap.josm.tools.HttpClient.Response; |
| 70 | 71 | import org.openstreetmap.josm.tools.Logging; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 75 | 76 | /** |
| 76 | 77 | * Integration tests of {@link ImageryPreference} class. |
| 77 | 78 | */ |
| | 79 | @IntegrationTest |
| 78 | 80 | public class ImageryPreferenceTestIT { |
| 79 | 81 | |
| 80 | 82 | private static final String ERROR_SEP = " -> "; |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/map/BackupPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/map/BackupPreferenceTest.java
index 12ddd6c475..2f54b22edc 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.map;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link BackupPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class BackupPreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link BackupPreference#BackupPreference}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java b/test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java
index e3e668c0a7..913f2a0497 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCas
|
| 25 | 25 | import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule; |
| 26 | 26 | import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; |
| 27 | 27 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 28 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 28 | 29 | import org.openstreetmap.josm.tools.ImageProvider; |
| 29 | 30 | |
| 30 | 31 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 32 | 33 | /** |
| 33 | 34 | * Integration tests of {@link MapPaintPreference} class. |
| 34 | 35 | */ |
| | 36 | @IntegrationTest |
| 35 | 37 | class MapPaintPreferenceTestIT extends AbstractExtendedSourceEntryTestCase { |
| 36 | 38 | |
| 37 | 39 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTest.java
index 74bdb1d8c5..d341635d41 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.map;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link TaggingPresetPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class TaggingPresetPreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link TaggingPresetPreference#TaggingPresetPreference}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java b/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java
index 3e714bd3c8..871524deb7 100644
|
a
|
b
|
import java.util.HashSet;
|
| 14 | 14 | import java.util.List; |
| 15 | 15 | import java.util.Locale; |
| 16 | 16 | import java.util.Set; |
| | 17 | import java.util.concurrent.TimeUnit; |
| 17 | 18 | |
| 18 | 19 | import org.junit.jupiter.api.BeforeAll; |
| | 20 | import org.junit.jupiter.api.Timeout; |
| 19 | 21 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 20 | 22 | import org.junit.jupiter.params.ParameterizedTest; |
| 21 | 23 | import org.junit.jupiter.params.provider.MethodSource; |
| … |
… |
import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetsTest;
|
| 28 | 30 | import org.openstreetmap.josm.gui.tagging.presets.items.Link; |
| 29 | 31 | import org.openstreetmap.josm.spi.preferences.Config; |
| 30 | 32 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 33 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 34 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 31 | 35 | import org.openstreetmap.josm.tools.HttpClient; |
| 32 | 36 | import org.openstreetmap.josm.tools.HttpClient.Response; |
| 33 | 37 | import org.openstreetmap.josm.tools.ImageProvider; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 39 | 43 | /** |
| 40 | 44 | * Integration tests of {@link TaggingPresetPreference} class. |
| 41 | 45 | */ |
| | 46 | @IntegrationTest |
| | 47 | @BasicPreferences |
| | 48 | @Timeout(value = 20, unit = TimeUnit.MINUTES) |
| 42 | 49 | class TaggingPresetPreferenceTestIT extends AbstractExtendedSourceEntryTestCase { |
| 43 | 50 | |
| 44 | 51 | /** |
| … |
… |
class TaggingPresetPreferenceTestIT extends AbstractExtendedSourceEntryTestCase
|
| 46 | 53 | */ |
| 47 | 54 | @RegisterExtension |
| 48 | 55 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 49 | | public static JOSMTestRules test = new JOSMTestRules().https().timeout(10000*120).parameters(); |
| | 56 | public static JOSMTestRules test = new JOSMTestRules().https().parameters(); |
| 50 | 57 | |
| 51 | 58 | /** |
| 52 | 59 | * Setup test |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
index 1bdab05056..0df7137c36 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.gui.preferences.plugin; |
| 3 | 3 | |
| 4 | | import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; |
| 5 | 4 | import static java.util.concurrent.TimeUnit.MILLISECONDS; |
| 6 | | import static org.junit.Assert.assertEquals; |
| 7 | | import static org.junit.Assert.assertFalse; |
| 8 | | import static org.junit.Assert.assertTrue; |
| | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | 6 | import static org.junit.jupiter.api.Assertions.assertFalse; |
| | 7 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| 9 | 8 | |
| 10 | 9 | import java.awt.Component; |
| 11 | 10 | import java.io.File; |
| … |
… |
import java.util.stream.Collectors;
|
| 18 | 17 | |
| 19 | 18 | import javax.swing.JOptionPane; |
| 20 | 19 | |
| | 20 | import com.github.tomakehurst.wiremock.WireMockServer; |
| | 21 | import com.github.tomakehurst.wiremock.client.WireMock; |
| | 22 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 23 | import mockit.MockUp; |
| 21 | 24 | import org.awaitility.Awaitility; |
| 22 | | import org.junit.After; |
| 23 | | import org.junit.Before; |
| 24 | | import org.junit.Rule; |
| 25 | | import org.junit.Test; |
| | 25 | import org.junit.jupiter.api.AfterEach; |
| | 26 | import org.junit.jupiter.api.BeforeEach; |
| | 27 | import org.junit.jupiter.api.Test; |
| | 28 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 26 | 29 | import org.openstreetmap.josm.TestUtils; |
| 27 | 30 | import org.openstreetmap.josm.data.Preferences; |
| 28 | 31 | import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; |
| … |
… |
import org.openstreetmap.josm.plugins.PluginProxy;
|
| 33 | 36 | import org.openstreetmap.josm.spi.preferences.Config; |
| 34 | 37 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 35 | 38 | import org.openstreetmap.josm.testutils.PluginServer; |
| | 39 | import org.openstreetmap.josm.testutils.annotations.AssumeRevision; |
| | 40 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 41 | import org.openstreetmap.josm.testutils.annotations.BasicWiremock; |
| 36 | 42 | import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; |
| 37 | 43 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 38 | 44 | |
| 39 | | import com.github.tomakehurst.wiremock.client.WireMock; |
| 40 | | import com.github.tomakehurst.wiremock.junit.WireMockRule; |
| 41 | | |
| 42 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 43 | | import mockit.MockUp; |
| 44 | | |
| 45 | 45 | /** |
| 46 | 46 | * Higher level tests of {@link PluginPreference} class. |
| 47 | 47 | */ |
| 48 | | public class PluginPreferenceHighLevelTest { |
| | 48 | @AssumeRevision("Revision: 10000\n") |
| | 49 | @BasicPreferences(true) |
| | 50 | @BasicWiremock |
| | 51 | class PluginPreferenceHighLevelTest { |
| 49 | 52 | /** |
| 50 | 53 | * Setup test. |
| 51 | 54 | */ |
| 52 | | @Rule |
| | 55 | @RegisterExtension |
| 53 | 56 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 54 | | public JOSMTestRules test = new JOSMTestRules().assumeRevision( |
| 55 | | "Revision: 10000\n" |
| 56 | | ).preferences().main().assertionsInEDT(); |
| | 57 | public JOSMTestRules test = new JOSMTestRules().main().assertionsInEDT(); |
| 57 | 58 | |
| 58 | 59 | /** |
| 59 | 60 | * Plugin server mock. |
| 60 | 61 | */ |
| 61 | | @Rule |
| 62 | | public WireMockRule pluginServerRule = new WireMockRule( |
| 63 | | options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot()) |
| 64 | | ); |
| | 62 | @BasicWiremock |
| | 63 | public WireMockServer pluginServerRule; |
| 65 | 64 | |
| 66 | 65 | /** |
| 67 | 66 | * Setup test. |
| 68 | 67 | * @throws ReflectiveOperationException never |
| 69 | 68 | */ |
| 70 | | @Before |
| | 69 | @BeforeEach |
| 71 | 70 | public void setUp() throws ReflectiveOperationException { |
| 72 | 71 | |
| 73 | 72 | // some other tests actually go ahead and load plugins (notably at time of writing, |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 106 | 105 | * Tear down. |
| 107 | 106 | * @throws ReflectiveOperationException never |
| 108 | 107 | */ |
| 109 | | @After |
| | 108 | @AfterEach |
| 110 | 109 | public void tearDown() throws ReflectiveOperationException { |
| 111 | 110 | // restore actual PluginHandler#pluginList |
| 112 | 111 | @SuppressWarnings("unchecked") |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 135 | 134 | * @throws Exception never |
| 136 | 135 | */ |
| 137 | 136 | @Test |
| 138 | | public void testInstallWithoutUpdate() throws Exception { |
| | 137 | void testInstallWithoutUpdate() throws Exception { |
| 139 | 138 | final PluginServer pluginServer = new PluginServer( |
| 140 | 139 | new PluginServer.RemotePlugin(this.referenceDummyJarNew), |
| 141 | 140 | new PluginServer.RemotePlugin(this.referenceBazJarOld), |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 169 | 168 | Awaitility.await().atMost(2000, MILLISECONDS).until(() -> Config.getPref().getInt("pluginmanager.version", 999) != 999); |
| 170 | 169 | |
| 171 | 170 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); |
| 172 | | WireMock.resetAllRequests(); |
| | 171 | this.pluginServerRule.resetRequests(); |
| 173 | 172 | |
| 174 | 173 | final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( |
| 175 | 174 | tabbedPane.getPluginPreference(), |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 256 | 255 | * @throws Exception never |
| 257 | 256 | */ |
| 258 | 257 | @Test |
| 259 | | public void testDisablePluginWithUpdatesAvailable() throws Exception { |
| | 258 | void testDisablePluginWithUpdatesAvailable() throws Exception { |
| 260 | 259 | final PluginServer pluginServer = new PluginServer( |
| 261 | 260 | new PluginServer.RemotePlugin(this.referenceDummyJarNew), |
| 262 | 261 | new PluginServer.RemotePlugin(this.referenceBazJarNew), |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 289 | 288 | Awaitility.await().atMost(2000, MILLISECONDS).until(() -> Config.getPref().getInt("pluginmanager.version", 999) != 999); |
| 290 | 289 | |
| 291 | 290 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); |
| 292 | | WireMock.resetAllRequests(); |
| | 291 | this.pluginServerRule.resetRequests(); |
| 293 | 292 | |
| 294 | 293 | final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( |
| 295 | 294 | tabbedPane.getPluginPreference(), |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 378 | 377 | * @throws Exception never |
| 379 | 378 | */ |
| 380 | 379 | @Test |
| 381 | | public void testUpdateOnlySelectedPlugin() throws Exception { |
| | 380 | void testUpdateOnlySelectedPlugin() throws Exception { |
| 382 | 381 | TestUtils.assumeWorkingJMockit(); |
| 383 | 382 | final PluginServer pluginServer = new PluginServer( |
| 384 | 383 | new PluginServer.RemotePlugin(this.referenceDummyJarNew), |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 406 | 405 | TestUtils.syncEDTAndWorkerThreads(); |
| 407 | 406 | |
| 408 | 407 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); |
| 409 | | WireMock.resetAllRequests(); |
| | 408 | this.pluginServerRule.resetRequests(); |
| 410 | 409 | |
| 411 | 410 | final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( |
| 412 | 411 | tabbedPane.getPluginPreference(), |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 485 | 484 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar"))); |
| 486 | 485 | // baz_plugin has not |
| 487 | 486 | this.pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/baz_plugin.v7.jar"))); |
| 488 | | WireMock.resetAllRequests(); |
| | 487 | this.pluginServerRule.resetRequests(); |
| 489 | 488 | |
| 490 | 489 | // pluginmanager.version has been set to the current version |
| 491 | 490 | // questionably correct |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 566 | 565 | * @throws Exception never |
| 567 | 566 | */ |
| 568 | 567 | @Test |
| 569 | | public void testUpdateWithNoAvailableUpdates() throws Exception { |
| | 568 | void testUpdateWithNoAvailableUpdates() throws Exception { |
| 570 | 569 | TestUtils.assumeWorkingJMockit(); |
| 571 | 570 | final PluginServer pluginServer = new PluginServer( |
| 572 | 571 | new PluginServer.RemotePlugin(this.referenceDummyJarOld), |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 600 | 599 | TestUtils.syncEDTAndWorkerThreads(); |
| 601 | 600 | |
| 602 | 601 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); |
| 603 | | WireMock.resetAllRequests(); |
| | 602 | this.pluginServerRule.resetRequests(); |
| 604 | 603 | |
| 605 | 604 | final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( |
| 606 | 605 | tabbedPane.getPluginPreference(), |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 656 | 655 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); |
| 657 | 656 | // that should have been the only request to our PluginServer |
| 658 | 657 | assertEquals(1, this.pluginServerRule.getAllServeEvents().size()); |
| 659 | | WireMock.resetAllRequests(); |
| | 658 | this.pluginServerRule.resetRequests(); |
| 660 | 659 | |
| 661 | 660 | // pluginmanager.version has been set to the current version |
| 662 | 661 | assertEquals(10000, Config.getPref().getInt("pluginmanager.version", 111)); |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 705 | 704 | * @throws Exception never |
| 706 | 705 | */ |
| 707 | 706 | @Test |
| 708 | | public void testInstallWithoutRestartRequired() throws Exception { |
| | 707 | void testInstallWithoutRestartRequired() throws Exception { |
| 709 | 708 | TestUtils.assumeWorkingJMockit(); |
| 710 | 709 | final boolean[] loadPluginsCalled = new boolean[] {false}; |
| 711 | 710 | new MockUp<PluginHandler>() { |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 749 | 748 | TestUtils.syncEDTAndWorkerThreads(); |
| 750 | 749 | |
| 751 | 750 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); |
| 752 | | WireMock.resetAllRequests(); |
| | 751 | this.pluginServerRule.resetRequests(); |
| 753 | 752 | |
| 754 | 753 | final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( |
| 755 | 754 | tabbedPane.getPluginPreference(), |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 825 | 824 | * preventing us from using the latest version |
| 826 | 825 | * @throws Exception on failure |
| 827 | 826 | */ |
| 828 | | @JOSMTestRules.OverrideAssumeRevision("Revision: 7000\n") |
| | 827 | @AssumeRevision("Revision: 7000\n") |
| 829 | 828 | @Test |
| 830 | | public void testInstallMultiVersion() throws Exception { |
| | 829 | void testInstallMultiVersion() throws Exception { |
| 831 | 830 | TestUtils.assumeWorkingJMockit(); |
| 832 | 831 | |
| 833 | 832 | final String bazOldServePath = "/baz/old.jar"; |
| … |
… |
public class PluginPreferenceHighLevelTest {
|
| 870 | 869 | TestUtils.syncEDTAndWorkerThreads(); |
| 871 | 870 | |
| 872 | 871 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); |
| 873 | | WireMock.resetAllRequests(); |
| | 872 | this.pluginServerRule.resetRequests(); |
| 874 | 873 | |
| 875 | 874 | final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField( |
| 876 | 875 | tabbedPane.getPluginPreference(), |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java
index fc602eae74..d0d2e5a817 100644
|
a
|
b
|
import org.openstreetmap.josm.plugins.PluginDownloadTask;
|
| 18 | 18 | import org.openstreetmap.josm.plugins.PluginException; |
| 19 | 19 | import org.openstreetmap.josm.plugins.PluginInformation; |
| 20 | 20 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 21 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 21 | 22 | import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; |
| 22 | 23 | |
| 23 | 24 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 25 | 26 | /** |
| 26 | 27 | * Unit tests of {@link PluginPreference} class. |
| 27 | 28 | */ |
| | 29 | @BasicPreferences |
| 28 | 30 | public class PluginPreferenceTest { |
| 29 | 31 | /** |
| 30 | 32 | * Setup test. |
| 31 | 33 | */ |
| 32 | 34 | @RegisterExtension |
| 33 | 35 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 34 | | public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT(); |
| | 36 | public JOSMTestRules test = new JOSMTestRules().assertionsInEDT(); |
| 35 | 37 | |
| 36 | 38 | /** |
| 37 | 39 | * Unit test of {@link PluginPreference#PluginPreference}. |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreferenceTest.java
index 3ebd2f214a..c5762b1904 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.projection;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link ProjectionPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class ProjectionPreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link ProjectionPreference#ProjectionPreference}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreferenceTest.java
index f884389305..206ff41cc3 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.remotecontrol;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link RemoteControlPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class RemoteControlPreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link RemoteControlPreference#RemoteControlPreference}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreferenceTest.java
index 735689b2a5..0206638a5c 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.validator;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link ValidatorPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class ValidatorPreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link ValidatorPreference#ValidatorPreference}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java b/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java
index 677cc11049..fcf25a975c 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCas
|
| 26 | 26 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 27 | 27 | |
| 28 | 28 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 29 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 29 | 30 | |
| 30 | 31 | /** |
| 31 | 32 | * Integration tests of {@link ValidatorTagCheckerRulesPreference} class. |
| 32 | 33 | */ |
| | 34 | @IntegrationTest |
| 33 | 35 | class ValidatorTagCheckerRulesPreferenceTestIT extends AbstractExtendedSourceEntryTestCase { |
| 34 | 36 | |
| 35 | 37 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreferenceTest.java
index 3c03344059..4538f3c5ba 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.preferences.validator;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 5 | |
| 6 | | import org.junit.jupiter.api.BeforeAll; |
| 7 | 6 | import org.junit.jupiter.api.Test; |
| 8 | | import org.openstreetmap.josm.JOSMFixture; |
| 9 | 7 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| | 8 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Unit tests of {@link ValidatorTestsPreference} class. |
| 13 | 12 | */ |
| | 13 | @BasicPreferences |
| 14 | 14 | class ValidatorTestsPreferenceTest { |
| 15 | | |
| 16 | | /** |
| 17 | | * Setup test. |
| 18 | | */ |
| 19 | | @BeforeAll |
| 20 | | public static void setUpBeforeClass() { |
| 21 | | JOSMFixture.createUnitTestFixture().init(); |
| 22 | | } |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Unit test of {@link ValidatorTestsPreference#ValidatorTestsPreference}. |
| 26 | 17 | */ |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/PresetClassificationsTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/PresetClassificationsTest.java
index eba467c4f4..d912fd9ff2 100644
|
a
|
b
|
import java.util.stream.Collectors;
|
| 13 | 13 | |
| 14 | 14 | import org.junit.jupiter.api.BeforeAll; |
| 15 | 15 | import org.junit.jupiter.api.Test; |
| 16 | | import org.openstreetmap.josm.JOSMFixture; |
| 17 | 16 | import org.openstreetmap.josm.data.osm.Node; |
| 18 | 17 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
| 19 | 18 | import org.openstreetmap.josm.data.osm.OsmUtils; |
| 20 | 19 | import org.openstreetmap.josm.data.osm.Way; |
| 21 | 20 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector.PresetClassification; |
| 22 | 21 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector.PresetClassifications; |
| | 22 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 23 | 23 | import org.xml.sax.SAXException; |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Unit tests of {@link PresetClassifications} class. |
| 27 | 27 | */ |
| | 28 | @BasicPreferences |
| 28 | 29 | class PresetClassificationsTest { |
| 29 | 30 | |
| 30 | 31 | static final PresetClassifications classifications = new PresetClassifications(); |
| … |
… |
class PresetClassificationsTest {
|
| 36 | 37 | */ |
| 37 | 38 | @BeforeAll |
| 38 | 39 | public static void setUp() throws IOException, SAXException { |
| 39 | | JOSMFixture.createUnitTestFixture().init(); |
| 40 | 40 | final Collection<TaggingPreset> presets = TaggingPresetReader.readAll("resource://data/defaultpresets.xml", true); |
| 41 | 41 | classifications.loadPresets(presets); |
| 42 | 42 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java
index c4cf522762..8f42792ba1 100644
|
a
|
b
|
import java.util.Collection;
|
| 12 | 12 | import java.util.List; |
| 13 | 13 | import java.util.stream.Collectors; |
| 14 | 14 | |
| 15 | | import org.junit.Assert; |
| 16 | 15 | import org.junit.jupiter.api.Test; |
| 17 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| 18 | 16 | import org.openstreetmap.josm.TestUtils; |
| 19 | 17 | import org.openstreetmap.josm.gui.tagging.presets.items.Check; |
| 20 | 18 | import org.openstreetmap.josm.gui.tagging.presets.items.Key; |
| 21 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 19 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 22 | 20 | import org.xml.sax.SAXException; |
| 23 | 21 | |
| 24 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 25 | | |
| 26 | 22 | /** |
| 27 | 23 | * Unit tests of {@link TaggingPresetReader} class. |
| 28 | 24 | */ |
| | 25 | @BasicPreferences |
| 29 | 26 | class TaggingPresetReaderTest { |
| 30 | | |
| 31 | | /** |
| 32 | | * Setup rule |
| 33 | | */ |
| 34 | | @RegisterExtension |
| 35 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 36 | | public JOSMTestRules test = new JOSMTestRules(); |
| 37 | | |
| 38 | 27 | /** |
| 39 | 28 | * #8954 - last checkbox in the preset is not added |
| 40 | 29 | * @throws SAXException if any XML error occurs |
| … |
… |
class TaggingPresetReaderTest {
|
| 44 | 33 | void testTicket8954() throws SAXException, IOException { |
| 45 | 34 | String presetfile = TestUtils.getRegressionDataFile(8954, "preset.xml"); |
| 46 | 35 | final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(presetfile, false); |
| 47 | | Assert.assertEquals("Number of preset items", 1, presets.size()); |
| | 36 | assertEquals(1, presets.size(), "Number of preset items"); |
| 48 | 37 | final TaggingPreset preset = presets.iterator().next(); |
| 49 | | Assert.assertEquals("Number of entries", 1, preset.data.size()); |
| | 38 | assertEquals(1, preset.data.size(), "Number of entries"); |
| 50 | 39 | final TaggingPresetItem item = preset.data.get(0); |
| 51 | | Assert.assertTrue("Entry is not checkbox", item instanceof Check); |
| | 40 | assertTrue(item instanceof Check, "Entry is not checkbox"); |
| 52 | 41 | } |
| 53 | 42 | |
| 54 | 43 | /** |
| … |
… |
class TaggingPresetReaderTest {
|
| 92 | 81 | void testReadDefaulPresets() throws SAXException, IOException { |
| 93 | 82 | String presetfile = "resource://data/defaultpresets.xml"; |
| 94 | 83 | final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(presetfile, true); |
| 95 | | Assert.assertTrue("Default presets are empty", presets.size() > 0); |
| | 84 | assertTrue(presets.size() > 0, "Default presets are empty"); |
| 96 | 85 | } |
| 97 | 86 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/CheckTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/CheckTest.java
index 8fae5a60d0..5e6e30ed4b 100644
|
a
|
b
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
| 10 | 10 | import org.junit.jupiter.api.Test; |
| 11 | 11 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; |
| 12 | 12 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 13 | 14 | |
| 14 | 15 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 15 | 16 | |
| 16 | 17 | /** |
| 17 | 18 | * Unit tests of {@link Check} class. |
| 18 | 19 | */ |
| | 20 | @BasicPreferences |
| 19 | 21 | class CheckTest { |
| 20 | 22 | |
| 21 | 23 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java
index feabfa1bea..689503a9fa 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
| 14 | 14 | import org.openstreetmap.josm.data.osm.OsmUtils; |
| 15 | 15 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; |
| 16 | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 17 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 17 | 18 | |
| 18 | 19 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Unit tests of {@link Combo} class. |
| 22 | 23 | */ |
| | 24 | @BasicPreferences |
| 23 | 25 | class ComboTest { |
| 24 | 26 | |
| 25 | 27 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/PresetLinkTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/PresetLinkTest.java
index 66c151189d..93afd59cf3 100644
|
a
|
b
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
| 11 | 11 | import org.junit.jupiter.api.Test; |
| 12 | 12 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; |
| 13 | 13 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 14 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 14 | 15 | |
| 15 | 16 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Unit tests of {@link PresetLink} class. |
| 19 | 20 | */ |
| | 21 | @BasicPreferences |
| 20 | 22 | class PresetLinkTest { |
| 21 | 23 | |
| 22 | 24 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/TextTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/TextTest.java
index 6979cad768..64d201a277 100644
|
a
|
b
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
| 10 | 10 | import org.junit.jupiter.api.Test; |
| 11 | 11 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; |
| 12 | 12 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 13 | 14 | |
| 14 | 15 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 15 | 16 | |
| 16 | 17 | /** |
| 17 | 18 | * Unit tests of {@link Text} class. |
| 18 | 19 | */ |
| | 20 | @BasicPreferences |
| 19 | 21 | class TextTest { |
| 20 | 22 | |
| 21 | 23 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTestIT.java b/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTestIT.java
index 90d640e298..16b4107e32 100644
|
a
|
b
|
import org.openstreetmap.josm.TestUtils;
|
| 19 | 19 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 20 | 20 | |
| 21 | 21 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 22 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * Integration tests of {@link CertificateAmendment} class. |
| 25 | 26 | */ |
| | 27 | @IntegrationTest |
| 26 | 28 | class CertificateAmendmentTestIT { |
| 27 | 29 | |
| 28 | 30 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/io/NameFinderTest.java b/test/unit/org/openstreetmap/josm/io/NameFinderTest.java
index 8a3f0569fa..dee6b497ca 100644
|
a
|
b
|
import java.util.Arrays;
|
| 8 | 8 | import java.util.stream.Collectors; |
| 9 | 9 | |
| 10 | 10 | import org.junit.jupiter.api.Test; |
| 11 | | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 12 | 11 | |
| 13 | 12 | /** |
| 14 | 13 | * Unit tests of {@link NameFinder} class. |
| 15 | 14 | */ |
| 16 | | @BasicPreferences |
| 17 | 15 | class NameFinderTest { |
| 18 | 16 | |
| 19 | 17 | // CHECKSTYLE.OFF: LineLength |
-
diff --git a/test/unit/org/openstreetmap/josm/io/NetworkManagerTest.java b/test/unit/org/openstreetmap/josm/io/NetworkManagerTest.java
index 22ddf1a670..dc722476f1 100644
|
a
|
b
|
import java.util.Map;
|
| 12 | 12 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 13 | 13 | import org.junit.jupiter.api.Test; |
| 14 | 14 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 15 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 15 | 16 | |
| 16 | 17 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Unit tests of {@link NetworkManager} class. |
| 20 | 21 | */ |
| | 22 | @BasicPreferences |
| 21 | 23 | class NetworkManagerTest { |
| 22 | 24 | |
| 23 | 25 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/io/ValidatorErrorWriterTest.java b/test/unit/org/openstreetmap/josm/io/ValidatorErrorWriterTest.java
index 0385968622..c90799bd47 100644
|
a
|
b
|
import java.util.Collections;
|
| 12 | 12 | import java.util.Locale; |
| 13 | 13 | |
| 14 | 14 | import org.junit.jupiter.api.Test; |
| 15 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| 16 | 15 | import org.openstreetmap.josm.data.coor.LatLon; |
| 17 | 16 | import org.openstreetmap.josm.data.osm.Node; |
| 18 | 17 | import org.openstreetmap.josm.data.validation.Severity; |
| 19 | 18 | import org.openstreetmap.josm.data.validation.TestError; |
| 20 | 19 | import org.openstreetmap.josm.data.validation.tests.RightAngleBuildingTest; |
| 21 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 22 | | |
| 23 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 20 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 24 | 21 | |
| 25 | 22 | /** |
| 26 | 23 | * Unit tests of {@link ValidatorErrorWriter} |
| 27 | 24 | */ |
| | 25 | @BasicPreferences |
| 28 | 26 | class ValidatorErrorWriterTest { |
| 29 | | |
| 30 | | /** |
| 31 | | * Setup rule |
| 32 | | */ |
| 33 | | @RegisterExtension |
| 34 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 35 | | public JOSMTestRules test = new JOSMTestRules().preferences(); |
| 36 | | |
| 37 | 27 | @Test |
| 38 | 28 | void testEmpty() throws IOException { |
| 39 | 29 | doTest(Collections.emptyList(), ""); |
-
diff --git a/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java b/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
index 583ab5f393..c03f1311a7 100644
|
a
|
b
|
import org.junit.jupiter.api.Test;
|
| 16 | 16 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 17 | 17 | import org.openstreetmap.josm.spi.preferences.Config; |
| 18 | 18 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 19 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 19 | 20 | import org.openstreetmap.josm.tools.Utils; |
| 20 | 21 | |
| 21 | 22 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 23 | 24 | /** |
| 24 | 25 | * Unit tests for Remote Control |
| 25 | 26 | */ |
| | 27 | @BasicPreferences |
| 26 | 28 | class RemoteControlTest { |
| 27 | 29 | |
| 28 | 30 | private String httpBase; |
| … |
… |
class RemoteControlTest {
|
| 32 | 34 | */ |
| 33 | 35 | @RegisterExtension |
| 34 | 36 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 35 | | public JOSMTestRules test = new JOSMTestRules().preferences().https().assertionsInEDT(); |
| | 37 | public JOSMTestRules test = new JOSMTestRules().https().assertionsInEDT(); |
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * Starts Remote control before testing requests. |
-
diff --git a/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java b/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java
index 976134f011..9e09ba66f4 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.MainApplication;
|
| 12 | 12 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 13 | 13 | import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException; |
| 14 | 14 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 15 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 15 | 16 | |
| 16 | 17 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Unit tests of {@link AddNodeHandler} class. |
| 20 | 21 | */ |
| | 22 | @BasicPreferences |
| 21 | 23 | class AddNodeHandlerTest { |
| 22 | 24 | /** |
| 23 | 25 | * Setup test. |
-
diff --git a/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java b/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java
index 625759f3f6..f81e8c7409 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.MainApplication;
|
| 14 | 14 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 15 | 15 | import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException; |
| 16 | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 17 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 17 | 18 | import org.openstreetmap.josm.tools.Utils; |
| 18 | 19 | |
| 19 | 20 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 21 | 22 | /** |
| 22 | 23 | * Unit tests of {@link ImportHandler} class. |
| 23 | 24 | */ |
| | 25 | @BasicPreferences |
| 24 | 26 | class ImportHandlerTest { |
| 25 | 27 | /** |
| 26 | 28 | * Setup test. |
-
diff --git a/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java b/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java
index acf5f77170..69158c461a 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 27 | 27 | import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; |
| 28 | 28 | import org.openstreetmap.josm.io.IllegalDataException; |
| 29 | 29 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 30 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 30 | 31 | |
| 31 | 32 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 32 | 33 | |
| 33 | 34 | /** |
| 34 | 35 | * Unit tests for Session reading. |
| 35 | 36 | */ |
| | 37 | @BasicPreferences |
| 36 | 38 | class SessionReaderTest { |
| 37 | 39 | |
| 38 | 40 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java b/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
index 0cce3b77de..3a41c0b374 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 37 | 37 | import org.openstreetmap.josm.gui.layer.TMSLayer; |
| 38 | 38 | import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; |
| 39 | 39 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 40 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 40 | 41 | import org.openstreetmap.josm.tools.MultiMap; |
| 41 | 42 | import org.openstreetmap.josm.tools.Utils; |
| 42 | 43 | |
| … |
… |
import static org.junit.jupiter.api.Assertions.assertEquals;
|
| 47 | 48 | /** |
| 48 | 49 | * Unit tests for Session writing. |
| 49 | 50 | */ |
| | 51 | @BasicPreferences |
| 50 | 52 | class SessionWriterTest { |
| 51 | 53 | |
| 52 | 54 | protected static final class OsmHeadlessJosExporter extends OsmDataSessionExporter { |
-
diff --git a/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java b/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java
index 5dffde15f8..210261104f 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.plugins; |
| 3 | 3 | |
| 4 | | import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; |
| 5 | | import static org.junit.Assert.assertEquals; |
| 6 | | import static org.junit.Assert.assertFalse; |
| 7 | | import static org.junit.Assert.assertNotEquals; |
| | 4 | |
| | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | 6 | import static org.junit.jupiter.api.Assertions.assertFalse; |
| | 7 | import static org.junit.jupiter.api.Assertions.assertNotEquals; |
| 8 | 8 | |
| 9 | 9 | import java.io.File; |
| 10 | 10 | import java.io.IOException; |
| … |
… |
import java.util.Comparator;
|
| 17 | 17 | import java.util.List; |
| 18 | 18 | import java.util.stream.Collectors; |
| 19 | 19 | |
| 20 | | import org.junit.Before; |
| 21 | | import org.junit.Rule; |
| 22 | | import org.junit.Test; |
| | 20 | import com.github.tomakehurst.wiremock.WireMockServer; |
| | 21 | import com.github.tomakehurst.wiremock.client.WireMock; |
| | 22 | import org.junit.jupiter.api.BeforeEach; |
| | 23 | import org.junit.jupiter.api.Test; |
| | 24 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 23 | 25 | import org.openstreetmap.josm.TestUtils; |
| 24 | 26 | import org.openstreetmap.josm.data.Preferences; |
| 25 | 27 | import org.openstreetmap.josm.gui.MainApplication; |
| 26 | 28 | import org.openstreetmap.josm.spi.preferences.Config; |
| 27 | 29 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 28 | 30 | import org.openstreetmap.josm.testutils.PluginServer; |
| | 31 | import org.openstreetmap.josm.testutils.annotations.AssumeRevision; |
| | 32 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 33 | import org.openstreetmap.josm.testutils.annotations.BasicWiremock; |
| 29 | 34 | import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; |
| 30 | 35 | import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; |
| 31 | 36 | |
| 32 | | import com.github.tomakehurst.wiremock.client.WireMock; |
| 33 | | import com.github.tomakehurst.wiremock.junit.WireMockRule; |
| 34 | | |
| 35 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 36 | | |
| 37 | 37 | /** |
| 38 | 38 | * Test parts of {@link PluginHandler} class when the reported JOSM version is too old for the plugin. |
| 39 | 39 | */ |
| 40 | | public class PluginHandlerJOSMTooOldTest { |
| 41 | | /** |
| 42 | | * Setup test. |
| 43 | | */ |
| 44 | | @Rule |
| 45 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 46 | | public JOSMTestRules test = new JOSMTestRules().preferences().main().assumeRevision( |
| 47 | | "Revision: 6000\n" |
| 48 | | ); |
| | 40 | @BasicPreferences(true) |
| | 41 | @BasicWiremock |
| | 42 | @AssumeRevision("Revision: 6000\n") |
| | 43 | class PluginHandlerJOSMTooOldTest { |
| | 44 | @RegisterExtension |
| | 45 | @SuppressWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| | 46 | JOSMTestRules josmTestRules = new JOSMTestRules().main(); |
| 49 | 47 | |
| 50 | 48 | /** |
| 51 | 49 | * Plugin server mock. |
| 52 | 50 | */ |
| 53 | | @Rule |
| 54 | | public WireMockRule pluginServerRule = new WireMockRule( |
| 55 | | options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot()) |
| 56 | | ); |
| | 51 | @BasicWiremock |
| | 52 | public WireMockServer pluginServerRule; |
| 57 | 53 | |
| 58 | 54 | /** |
| 59 | 55 | * Setup test. |
| 60 | 56 | */ |
| 61 | | @Before |
| | 57 | @BeforeEach |
| 62 | 58 | public void setUp() { |
| 63 | 59 | Config.getPref().putInt("pluginmanager.version", 999); |
| 64 | 60 | Config.getPref().put("pluginmanager.lastupdate", "999"); |
| … |
… |
public class PluginHandlerJOSMTooOldTest {
|
| 114 | 110 | * @throws IOException never |
| 115 | 111 | */ |
| 116 | 112 | @Test |
| 117 | | public void testUpdatePluginsDownloadBoth() throws IOException { |
| | 113 | void testUpdatePluginsDownloadBoth() throws IOException { |
| 118 | 114 | TestUtils.assumeWorkingJMockit(); |
| 119 | 115 | final PluginServer pluginServer = new PluginServer( |
| 120 | 116 | new PluginServer.RemotePlugin(this.referenceDummyJarNew), |
| … |
… |
public class PluginHandlerJOSMTooOldTest {
|
| 176 | 172 | * @throws IOException never |
| 177 | 173 | */ |
| 178 | 174 | @Test |
| 179 | | public void testUpdatePluginsSkipOne() throws IOException { |
| | 175 | void testUpdatePluginsSkipOne() throws IOException { |
| 180 | 176 | TestUtils.assumeWorkingJMockit(); |
| 181 | 177 | final PluginServer pluginServer = new PluginServer( |
| 182 | 178 | new PluginServer.RemotePlugin(this.referenceDummyJarNew), |
| … |
… |
public class PluginHandlerJOSMTooOldTest {
|
| 248 | 244 | * @throws IOException never |
| 249 | 245 | */ |
| 250 | 246 | @Test |
| 251 | | public void testUpdatePluginsUnexpectedlyJOSMTooOld() throws IOException { |
| | 247 | void testUpdatePluginsUnexpectedlyJOSMTooOld() throws IOException { |
| 252 | 248 | TestUtils.assumeWorkingJMockit(); |
| 253 | 249 | final PluginServer pluginServer = new PluginServer( |
| 254 | 250 | new PluginServer.RemotePlugin(this.referenceDummyJarNew), |
| … |
… |
public class PluginHandlerJOSMTooOldTest {
|
| 302 | 298 | * @throws IOException never |
| 303 | 299 | */ |
| 304 | 300 | @Test |
| 305 | | @JOSMTestRules.OverrideAssumeRevision("Revision: 7200\n") |
| 306 | | public void testUpdatePluginsMultiVersionInsufficient() throws IOException { |
| | 301 | @AssumeRevision("Revision: 7200\n") |
| | 302 | void testUpdatePluginsMultiVersionInsufficient() throws IOException { |
| 307 | 303 | TestUtils.assumeWorkingJMockit(); |
| 308 | 304 | |
| 309 | 305 | final PluginServer pluginServer = new PluginServer( |
| … |
… |
public class PluginHandlerJOSMTooOldTest {
|
| 342 | 338 | // questionably correct |
| 343 | 339 | TestUtils.assertFileContentsEqual(this.referenceQuxJarNewer, this.targetQuxJar); |
| 344 | 340 | |
| 345 | | assertEquals(2, WireMock.getAllServeEvents().size()); |
| | 341 | assertEquals(2, this.pluginServerRule.getAllServeEvents().size(), "Requests: " + this.pluginServerRule.getAllServeEvents().stream() |
| | 342 | .map(serveEvent -> serveEvent.getRequest().getUrl()).collect(Collectors.joining(", "))); |
| 346 | 343 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); |
| 347 | 344 | // questionably correct |
| 348 | 345 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/qux_plugin.v432.jar"))); |
-
diff --git a/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java b/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java
index 16d93c571e..0b09ac155e 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.plugins; |
| 3 | 3 | |
| 4 | | import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; |
| 5 | | import static org.junit.Assert.assertEquals; |
| 6 | | import static org.junit.Assert.assertFalse; |
| 7 | | import static org.junit.Assert.assertNotEquals; |
| | 4 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | 5 | import static org.junit.jupiter.api.Assertions.assertFalse; |
| | 6 | import static org.junit.jupiter.api.Assertions.assertNotEquals; |
| 8 | 7 | |
| 9 | 8 | import java.io.File; |
| | 9 | import java.io.IOException; |
| 10 | 10 | import java.nio.file.Files; |
| 11 | 11 | import java.util.Arrays; |
| 12 | 12 | import java.util.Collections; |
| … |
… |
import java.util.List;
|
| 16 | 16 | import java.util.Map; |
| 17 | 17 | import java.util.stream.Collectors; |
| 18 | 18 | |
| 19 | | import org.junit.Before; |
| 20 | | import org.junit.Rule; |
| 21 | | import org.junit.Test; |
| | 19 | import com.github.tomakehurst.wiremock.WireMockServer; |
| | 20 | import com.github.tomakehurst.wiremock.client.WireMock; |
| | 21 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 22 | import org.apache.commons.io.FileUtils; |
| | 23 | import org.junit.jupiter.api.AfterEach; |
| | 24 | import org.junit.jupiter.api.BeforeEach; |
| | 25 | import org.junit.jupiter.api.Test; |
| | 26 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 22 | 27 | import org.openstreetmap.josm.TestUtils; |
| 23 | 28 | import org.openstreetmap.josm.data.Preferences; |
| 24 | 29 | import org.openstreetmap.josm.gui.MainApplication; |
| 25 | 30 | import org.openstreetmap.josm.spi.preferences.Config; |
| 26 | 31 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 27 | 32 | import org.openstreetmap.josm.testutils.PluginServer; |
| | 33 | import org.openstreetmap.josm.testutils.annotations.AssumeRevision; |
| | 34 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 35 | import org.openstreetmap.josm.testutils.annotations.BasicWiremock; |
| 28 | 36 | import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; |
| 29 | 37 | |
| 30 | | import com.github.tomakehurst.wiremock.client.WireMock; |
| 31 | | import com.github.tomakehurst.wiremock.junit.WireMockRule; |
| 32 | | |
| 33 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 34 | | |
| 35 | 38 | /** |
| 36 | 39 | * Test parts of {@link PluginHandler} class with plugins that advertise multiple versions for compatibility. |
| 37 | 40 | */ |
| 38 | | public class PluginHandlerMultiVersionTest { |
| | 41 | @BasicWiremock |
| | 42 | @BasicPreferences |
| | 43 | @AssumeRevision("7000") |
| | 44 | class PluginHandlerMultiVersionTest { |
| 39 | 45 | /** |
| 40 | 46 | * Setup test. |
| 41 | 47 | */ |
| 42 | | @Rule |
| | 48 | @RegisterExtension |
| 43 | 49 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 44 | | public JOSMTestRules test = new JOSMTestRules().preferences().main(); |
| | 50 | public JOSMTestRules test = new JOSMTestRules().main(); |
| 45 | 51 | |
| 46 | 52 | /** |
| 47 | 53 | * Plugin server mock. |
| 48 | 54 | */ |
| 49 | | @Rule |
| 50 | | public WireMockRule pluginServerRule = new WireMockRule( |
| 51 | | options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot()) |
| 52 | | ); |
| | 55 | @BasicWiremock |
| | 56 | WireMockServer pluginServerRule; |
| 53 | 57 | |
| 54 | 58 | /** |
| 55 | 59 | * Setup test. |
| 56 | 60 | */ |
| 57 | | @Before |
| 58 | | public void setUp() { |
| | 61 | @BeforeEach |
| | 62 | void setUp() throws IOException { |
| 59 | 63 | Config.getPref().putInt("pluginmanager.version", 999); |
| 60 | 64 | Config.getPref().put("pluginmanager.lastupdate", "999"); |
| 61 | 65 | Config.getPref().putList("pluginmanager.sites", |
| … |
… |
public class PluginHandlerMultiVersionTest {
|
| 71 | 75 | this.targetBazJarNew = new File(this.pluginDir, "baz_plugin.jar.new"); |
| 72 | 76 | this.targetQuxJar = new File(this.pluginDir, "qux_plugin.jar"); |
| 73 | 77 | this.targetQuxJarNew = new File(this.pluginDir, "qux_plugin.jar.new"); |
| | 78 | // Clean up the plugin directory |
| | 79 | if (this.pluginDir.isDirectory()) { |
| | 80 | FileUtils.cleanDirectory(this.pluginDir); |
| | 81 | } |
| 74 | 82 | this.pluginDir.mkdirs(); |
| 75 | 83 | } |
| 76 | 84 | |
| | 85 | @AfterEach |
| | 86 | void afterEach() { |
| | 87 | |
| | 88 | } |
| | 89 | |
| 77 | 90 | private static final String referencePathQuxJarOld = "plugin/qux_plugin.v345.jar"; |
| 78 | 91 | private static final String referencePathQuxJarNewer = "plugin/qux_plugin.v432.jar"; |
| 79 | 92 | private static final String referencePathQuxJarNewest = "plugin/qux_plugin.v435.jar"; |
| … |
… |
public class PluginHandlerMultiVersionTest {
|
| 93 | 106 | * but an additional version is listed which *does* support our version |
| 94 | 107 | * @throws Exception on failure |
| 95 | 108 | */ |
| 96 | | @JOSMTestRules.OverrideAssumeRevision("Revision: 7501\n") |
| | 109 | @AssumeRevision("Revision: 7501\n") |
| 97 | 110 | @Test |
| 98 | | public void testUpdatePluginsOneMultiVersion() throws Exception { |
| | 111 | void testUpdatePluginsOneMultiVersion() throws Exception { |
| 99 | 112 | TestUtils.assumeWorkingJMockit(); |
| 100 | 113 | |
| 101 | 114 | final String quxNewerServePath = "/qux/newer.jar"; |
| … |
… |
public class PluginHandlerMultiVersionTest {
|
| 146 | 159 | TestUtils.assertFileContentsEqual(this.referenceBazJarOld, this.targetBazJar); |
| 147 | 160 | TestUtils.assertFileContentsEqual(this.referenceQuxJarNewer, this.targetQuxJar); |
| 148 | 161 | |
| 149 | | assertEquals(2, WireMock.getAllServeEvents().size()); |
| | 162 | assertEquals(2, this.pluginServerRule.getAllServeEvents().size()); |
| 150 | 163 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); |
| 151 | 164 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo(quxNewerServePath))); |
| 152 | 165 | |
| … |
… |
public class PluginHandlerMultiVersionTest {
|
| 160 | 173 | * we already have, which is still listed. |
| 161 | 174 | * @throws Exception on failure |
| 162 | 175 | */ |
| 163 | | @JOSMTestRules.OverrideAssumeRevision("Revision: 7000\n") |
| | 176 | @AssumeRevision("Revision: 7000\n") |
| 164 | 177 | @Test |
| 165 | | public void testUpdatePluginsExistingVersionLatestPossible() throws Exception { |
| | 178 | void testUpdatePluginsExistingVersionLatestPossible() throws Exception { |
| 166 | 179 | TestUtils.assumeWorkingJMockit(); |
| 167 | 180 | |
| 168 | 181 | final Map<String, String> attrOverrides = new HashMap<String, String>() {{ |
| … |
… |
public class PluginHandlerMultiVersionTest {
|
| 206 | 219 | TestUtils.assertFileContentsEqual(this.referenceQuxJarOld, this.targetQuxJar); |
| 207 | 220 | |
| 208 | 221 | // only the plugins list should have been downloaded |
| 209 | | assertEquals(1, WireMock.getAllServeEvents().size()); |
| | 222 | assertEquals(1, this.pluginServerRule.getAllServeEvents().size()); |
| 210 | 223 | this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins"))); |
| 211 | 224 | |
| 212 | 225 | assertEquals(7000, Config.getPref().getInt("pluginmanager.version", 111)); |
-
diff --git a/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java b/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java
index aeefa91805..875cf24278 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.widgets.JosmTextArea;
|
| 23 | 23 | import org.openstreetmap.josm.plugins.PluginHandler.DeprecatedPlugin; |
| 24 | 24 | import org.openstreetmap.josm.plugins.PluginHandler.PluginInformationAction; |
| 25 | 25 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 26 | import org.openstreetmap.josm.testutils.annotations.I18n; |
| 26 | 27 | import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; |
| 27 | 28 | import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; |
| 28 | 29 | |
| … |
… |
import org.junit.jupiter.api.Test;
|
| 33 | 34 | * Unit tests of {@link PluginHandler} class. |
| 34 | 35 | */ |
| 35 | 36 | @BasicPreferences |
| | 37 | @I18n |
| 36 | 38 | class PluginHandlerTest { |
| 37 | 39 | /** |
| 38 | 40 | * Unit test of methods {@link DeprecatedPlugin#equals} and {@link DeprecatedPlugin#hashCode}. |
-
diff --git a/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java b/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java
index 6e70c9889b..51f80edee0 100644
|
a
|
b
|
import java.util.HashMap;
|
| 15 | 15 | import java.util.Iterator; |
| 16 | 16 | import java.util.List; |
| 17 | 17 | import java.util.Map; |
| 18 | | import java.util.Map.Entry; |
| 19 | 18 | import java.util.Set; |
| | 19 | import java.util.concurrent.TimeUnit; |
| 20 | 20 | import java.util.function.Consumer; |
| 21 | 21 | import java.util.stream.Collectors; |
| 22 | 22 | |
| 23 | 23 | import org.junit.jupiter.api.BeforeAll; |
| 24 | 24 | import org.junit.jupiter.api.Test; |
| | 25 | import org.junit.jupiter.api.Timeout; |
| 25 | 26 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 26 | 27 | import org.openstreetmap.josm.TestUtils; |
| 27 | 28 | import org.openstreetmap.josm.data.Preferences; |
| … |
… |
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
| 34 | 35 | import org.openstreetmap.josm.gui.progress.NullProgressMonitor; |
| 35 | 36 | import org.openstreetmap.josm.spi.preferences.Config; |
| 36 | 37 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 38 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 39 | import org.openstreetmap.josm.testutils.annotations.Main; |
| | 40 | import org.openstreetmap.josm.testutils.annotations.Projection; |
| | 41 | import org.openstreetmap.josm.testutils.annotations.Territories; |
| 37 | 42 | import org.openstreetmap.josm.tools.Destroyable; |
| 38 | 43 | import org.openstreetmap.josm.tools.Logging; |
| 39 | 44 | import org.openstreetmap.josm.tools.Utils; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 43 | 48 | /** |
| 44 | 49 | * Integration tests of {@link PluginHandler} class. |
| 45 | 50 | */ |
| | 51 | @BasicPreferences |
| | 52 | @Projection |
| | 53 | @Main |
| | 54 | @Territories |
| | 55 | @Timeout(value = 10, unit = TimeUnit.MINUTES) |
| 46 | 56 | public class PluginHandlerTestIT { |
| 47 | 57 | |
| 48 | 58 | private static final List<String> errorsToIgnore = new ArrayList<>(); |
| … |
… |
public class PluginHandlerTestIT {
|
| 51 | 61 | */ |
| 52 | 62 | @RegisterExtension |
| 53 | 63 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 54 | | public static JOSMTestRules test = new JOSMTestRules().main().projection().preferences().https() |
| 55 | | .territories().timeout(10 * 60 * 1000); |
| | 64 | public static JOSMTestRules test = new JOSMTestRules().https(); |
| 56 | 65 | |
| 57 | 66 | /** |
| 58 | 67 | * Setup test |
| … |
… |
public class PluginHandlerTestIT {
|
| 73 | 82 | |
| 74 | 83 | Map<String, Throwable> loadingExceptions = PluginHandler.pluginLoadingExceptions.entrySet().stream() |
| 75 | 84 | .filter(e -> !(Utils.getRootCause(e.getValue()) instanceof HeadlessException)) |
| 76 | | .collect(Collectors.toMap(e -> e.getKey(), e -> Utils.getRootCause(e.getValue()))); |
| | 85 | .collect(Collectors.toMap(Map.Entry::getKey, e -> Utils.getRootCause(e.getValue()))); |
| 77 | 86 | |
| 78 | 87 | List<PluginInformation> loadedPlugins = PluginHandler.getPlugins(); |
| 79 | 88 | Map<String, List<String>> invalidManifestEntries = loadedPlugins.stream().filter(pi -> !pi.invalidManifestEntries.isEmpty()) |
| … |
… |
public class PluginHandlerTestIT {
|
| 147 | 156 | private static <T> Map<String, T> filterKnownErrors(Map<String, T> errorMap) { |
| 148 | 157 | return errorMap.entrySet().parallelStream() |
| 149 | 158 | .filter(entry -> !errorsToIgnore.contains(convertEntryToString(entry))) |
| 150 | | .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); |
| | 159 | .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); |
| 151 | 160 | } |
| 152 | 161 | |
| 153 | 162 | private static void debugPrint(Map<String, ?> invalidManifestEntries) { |
| 154 | 163 | System.out.println(invalidManifestEntries.entrySet() |
| 155 | 164 | .stream() |
| 156 | | .map(e -> convertEntryToString(e)) |
| | 165 | .map(PluginHandlerTestIT::convertEntryToString) |
| 157 | 166 | .collect(Collectors.joining(", "))); |
| 158 | 167 | } |
| 159 | 168 | |
| 160 | | private static String convertEntryToString(Entry<String, ?> entry) { |
| | 169 | private static String convertEntryToString(Map.Entry<String, ?> entry) { |
| 161 | 170 | return entry.getKey() + "=\"" + entry.getValue() + "\""; |
| 162 | 171 | } |
| 163 | 172 | |
-
diff --git a/test/unit/org/openstreetmap/josm/spi/lifecycle/LifecycleTest.java b/test/unit/org/openstreetmap/josm/spi/lifecycle/LifecycleTest.java
index 9c4fd03875..483ddf1fba 100644
|
a
|
b
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
| 7 | 7 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 8 | 8 | import org.junit.jupiter.api.Test; |
| 9 | 9 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 10 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 10 | 11 | |
| 11 | 12 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 12 | 13 | |
| 13 | 14 | /** |
| 14 | 15 | * Unit tests of {@link Lifecycle} class. |
| 15 | 16 | */ |
| | 17 | @BasicPreferences |
| 16 | 18 | class LifecycleTest { |
| 17 | 19 | |
| 18 | 20 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java b/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
index b68e571827..27f7959116 100644
|
a
|
b
|
import java.awt.GraphicsEnvironment;
|
| 6 | 6 | import java.awt.Toolkit; |
| 7 | 7 | import java.awt.Window; |
| 8 | 8 | import java.awt.event.WindowEvent; |
| 9 | | import java.io.ByteArrayInputStream; |
| 10 | 9 | import java.io.File; |
| 11 | 10 | import java.io.IOException; |
| 12 | 11 | import java.io.PrintWriter; |
| … |
… |
import java.lang.annotation.Retention;
|
| 17 | 16 | import java.lang.annotation.RetentionPolicy; |
| 18 | 17 | import java.lang.annotation.Target; |
| 19 | 18 | import java.lang.reflect.Method; |
| 20 | | import java.nio.charset.StandardCharsets; |
| 21 | 19 | import java.security.GeneralSecurityException; |
| 22 | 20 | import java.text.MessageFormat; |
| 23 | 21 | import java.util.Arrays; |
| … |
… |
import java.util.TimeZone;
|
| 26 | 24 | import java.util.logging.Handler; |
| 27 | 25 | import java.util.logging.Level; |
| 28 | 26 | |
| | 27 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 29 | 28 | import org.awaitility.Awaitility; |
| 30 | 29 | import org.junit.jupiter.api.extension.AfterAllCallback; |
| 31 | 30 | import org.junit.jupiter.api.extension.AfterEachCallback; |
| … |
… |
import org.openstreetmap.josm.io.OsmConnection;
|
| 64 | 63 | import org.openstreetmap.josm.io.OsmTransferCanceledException; |
| 65 | 64 | import org.openstreetmap.josm.spi.preferences.Config; |
| 66 | 65 | import org.openstreetmap.josm.spi.preferences.Setting; |
| | 66 | import org.openstreetmap.josm.testutils.annotations.MockVersion; |
| | 67 | import org.openstreetmap.josm.testutils.annotations.fake_imagery.ColorSource; |
| 67 | 68 | import org.openstreetmap.josm.testutils.mockers.EDTAssertionMocker; |
| 68 | 69 | import org.openstreetmap.josm.testutils.mockers.WindowlessMapViewStateMocker; |
| 69 | 70 | import org.openstreetmap.josm.testutils.mockers.WindowlessNavigatableComponentMocker; |
| … |
… |
import org.openstreetmap.josm.tools.Utils;
|
| 79 | 80 | import org.openstreetmap.josm.tools.bugreport.ReportedException; |
| 80 | 81 | import org.openstreetmap.josm.tools.date.DateUtils; |
| 81 | 82 | |
| 82 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 83 | | |
| 84 | 83 | /** |
| 85 | 84 | * This class runs a test in an environment that resembles the one used by the JOSM main application. |
| 86 | 85 | * <p> |
| … |
… |
public class JOSMTestRules implements TestRule, AfterEachCallback, BeforeEachCal
|
| 332 | 331 | true, |
| 333 | 332 | true, |
| 334 | 333 | true, |
| 335 | | new TileSourceRule.ColorSource(Color.WHITE, "White Tiles", 256), |
| 336 | | new TileSourceRule.ColorSource(Color.BLACK, "Black Tiles", 256), |
| 337 | | new TileSourceRule.ColorSource(Color.MAGENTA, "Magenta Tiles", 256), |
| 338 | | new TileSourceRule.ColorSource(Color.GREEN, "Green Tiles", 256) |
| | 334 | new ColorSource(Color.WHITE, "White Tiles", 256), |
| | 335 | new ColorSource(Color.BLACK, "Black Tiles", 256), |
| | 336 | new ColorSource(Color.MAGENTA, "Magenta Tiles", 256), |
| | 337 | new ColorSource(Color.GREEN, "Green Tiles", 256) |
| 339 | 338 | ) |
| 340 | 339 | ); |
| 341 | 340 | } |
| … |
… |
public class JOSMTestRules implements TestRule, AfterEachCallback, BeforeEachCal
|
| 403 | 402 | return this; |
| 404 | 403 | } |
| 405 | 404 | |
| 406 | | private static class MockVersion extends Version { |
| 407 | | MockVersion(final String propertiesString) { |
| 408 | | super.initFromRevisionInfo( |
| 409 | | new ByteArrayInputStream(propertiesString.getBytes(StandardCharsets.UTF_8)) |
| 410 | | ); |
| 411 | | } |
| 412 | | } |
| 413 | | |
| 414 | 405 | @Override |
| 415 | 406 | public Statement apply(Statement base, Description description) { |
| 416 | 407 | // First process any Override* annotations for per-test overrides. |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java b/test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java
index 9156cbd539..b7fc44b687 100644
|
a
|
b
|
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options
|
| 5 | 5 | import static org.openstreetmap.josm.TestUtils.getPrivateStaticField; |
| 6 | 6 | |
| 7 | 7 | import java.awt.Color; |
| 8 | | import java.awt.Graphics2D; |
| 9 | | import java.awt.image.BufferedImage; |
| 10 | | import java.io.ByteArrayOutputStream; |
| 11 | 8 | import java.io.IOException; |
| 12 | 9 | import java.util.Arrays; |
| 13 | 10 | import java.util.Collections; |
| 14 | 11 | import java.util.HashMap; |
| 15 | 12 | import java.util.List; |
| 16 | | import java.util.Objects; |
| 17 | | |
| 18 | | import javax.imageio.ImageIO; |
| 19 | 13 | |
| 20 | 14 | import org.junit.runner.Description; |
| 21 | 15 | import org.junit.runners.model.Statement; |
| … |
… |
public class TileSourceRule extends WireMockRule {
|
| 50 | 44 | |
| 51 | 45 | /** |
| 52 | 46 | * Class defining a tile source for TileSourceRule to mock. Due to the way WireMock is designed, it is far more |
| 53 | | * straightforward to serve a single image in all tile positions |
| | 47 | * straightforward to serve a single image in all tile positions. |
| | 48 | * |
| | 49 | * @deprecated Please extend {@link org.openstreetmap.josm.testutils.annotations.fake_imagery.ConstSource} instead. |
| | 50 | * When JUnit 4 support is removed from JOSM, this class will disappear. Until then, |
| | 51 | * {@link org.openstreetmap.josm.testutils.annotations.fake_imagery.ConstSource} will extend {@link ConstSource}. |
| 54 | 52 | */ |
| | 53 | @Deprecated |
| 55 | 54 | public abstract static class ConstSource { |
| 56 | 55 | /** |
| 57 | 56 | * method for actually generating the payload body bytes, uncached |
| … |
… |
public class TileSourceRule extends WireMockRule {
|
| 101 | 100 | |
| 102 | 101 | /** |
| 103 | 102 | * A plain color tile source |
| | 103 | * @deprecated Use {@link org.openstreetmap.josm.testutils.annotations.fake_imagery.ColorSource} instead |
| 104 | 104 | */ |
| 105 | | public static class ColorSource extends ConstSource { |
| 106 | | protected final Color color; |
| 107 | | protected final String label; |
| 108 | | protected final int tileSize; |
| 109 | | |
| | 105 | @Deprecated |
| | 106 | public static class ColorSource extends org.openstreetmap.josm.testutils.annotations.fake_imagery.ColorSource { |
| 110 | 107 | /** |
| 111 | 108 | * @param color Color for these tiles |
| 112 | 109 | * @param label text label/name for this source if displayed in JOSM menus |
| 113 | 110 | * @param tileSize Pixel dimension of tiles (usually 256) |
| 114 | 111 | */ |
| 115 | 112 | public ColorSource(Color color, String label, int tileSize) { |
| 116 | | this.color = color; |
| 117 | | this.label = label; |
| 118 | | this.tileSize = tileSize; |
| 119 | | } |
| 120 | | |
| 121 | | @Override |
| 122 | | public int hashCode() { |
| 123 | | return Objects.hash(this.color, this.label, this.tileSize, this.getClass()); |
| 124 | | } |
| 125 | | |
| 126 | | @Override |
| 127 | | public byte[] generatePayloadBytes() { |
| 128 | | BufferedImage image = new BufferedImage(this.tileSize, this.tileSize, BufferedImage.TYPE_INT_RGB); |
| 129 | | Graphics2D g = image.createGraphics(); |
| 130 | | g.setBackground(this.color); |
| 131 | | g.clearRect(0, 0, image.getWidth(), image.getHeight()); |
| 132 | | |
| 133 | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| 134 | | try { |
| 135 | | ImageIO.write(image, "png", outputStream); |
| 136 | | } catch (IOException e) { |
| 137 | | Logging.trace(e); |
| 138 | | } |
| 139 | | return outputStream.toByteArray(); |
| 140 | | } |
| 141 | | |
| 142 | | @Override |
| 143 | | public MappingBuilder getMappingBuilder() { |
| 144 | | return WireMock.get(WireMock.urlMatching(String.format("/%h/(\\d+)/(\\d+)/(\\d+)\\.png", this.hashCode()))); |
| 145 | | } |
| 146 | | |
| 147 | | @Override |
| 148 | | public ImageryInfo getImageryInfo(int port) { |
| 149 | | return new ImageryInfo( |
| 150 | | this.label, |
| 151 | | String.format("tms[20]:http://localhost:%d/%h/{z}/{x}/{y}.png", port, this.hashCode()), |
| 152 | | "tms", |
| 153 | | (String) null, |
| 154 | | (String) null |
| 155 | | ); |
| 156 | | } |
| 157 | | |
| 158 | | @Override |
| 159 | | public String getLabel() { |
| 160 | | return this.label; |
| | 113 | super(color, label, tileSize); |
| 161 | 114 | } |
| 162 | 115 | } |
| 163 | 116 | |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/AssumeRevision.java b/test/unit/org/openstreetmap/josm/testutils/annotations/AssumeRevision.java
new file mode 100644
index 0000000000..849f06cf13
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.testutils.annotations; |
| | 3 | |
| | 4 | import java.lang.annotation.Documented; |
| | 5 | import java.lang.annotation.ElementType; |
| | 6 | import java.lang.annotation.Retention; |
| | 7 | import java.lang.annotation.RetentionPolicy; |
| | 8 | import java.lang.annotation.Target; |
| | 9 | import java.util.Optional; |
| | 10 | |
| | 11 | import org.junit.jupiter.api.extension.AfterEachCallback; |
| | 12 | import org.junit.jupiter.api.extension.BeforeEachCallback; |
| | 13 | import org.junit.jupiter.api.extension.ExtendWith; |
| | 14 | import org.junit.jupiter.api.extension.ExtensionContext; |
| | 15 | import org.junit.jupiter.api.extension.ExtensionContext.Namespace; |
| | 16 | import org.junit.jupiter.api.extension.ExtensionContext.Store; |
| | 17 | import org.openstreetmap.josm.TestUtils; |
| | 18 | import org.openstreetmap.josm.data.Version; |
| | 19 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 20 | |
| | 21 | |
| | 22 | /** |
| | 23 | * Override this test's assumed JOSM version (as reported by {@link Version}). |
| | 24 | * @author Taylor Smock |
| | 25 | * @see JOSMTestRules#assumeRevision(String) |
| | 26 | * @since xxx |
| | 27 | */ |
| | 28 | @Documented |
| | 29 | @Retention(RetentionPolicy.RUNTIME) |
| | 30 | @Target({ElementType.METHOD, ElementType.TYPE}) |
| | 31 | @ExtendWith(AssumeRevision.AssumeRevisionExtension.class) |
| | 32 | public @interface AssumeRevision { |
| | 33 | /** |
| | 34 | * Returns overridden assumed JOSM version. |
| | 35 | * @return overridden assumed JOSM version |
| | 36 | */ |
| | 37 | String value(); |
| | 38 | |
| | 39 | /** |
| | 40 | * Override the JOSM revision information. Use {@link AssumeRevision} instead of directly using this extension. |
| | 41 | * @author Taylor Smock |
| | 42 | * @since xxx |
| | 43 | */ |
| | 44 | class AssumeRevisionExtension implements BeforeEachCallback, AfterEachCallback { |
| | 45 | |
| | 46 | @Override |
| | 47 | public void afterEach(ExtensionContext context) throws Exception { |
| | 48 | Store store = context.getStore(Namespace.create(AssumeRevisionExtension.class)); |
| | 49 | Version originalVersion = store.getOrDefault(Version.class, Version.class, null); |
| | 50 | if (originalVersion != null) { |
| | 51 | TestUtils.setPrivateStaticField(Version.class, "instance", originalVersion); |
| | 52 | } |
| | 53 | } |
| | 54 | |
| | 55 | @Override |
| | 56 | public void beforeEach(ExtensionContext context) throws Exception { |
| | 57 | Optional<AssumeRevision> annotation = AnnotationUtils.findFirstParentAnnotation(context, AssumeRevision.class); |
| | 58 | if (annotation.isPresent()) { |
| | 59 | Store store = context.getStore(Namespace.create(AssumeRevisionExtension.class)); |
| | 60 | if (store.get(Version.class, Version.class) == null) { |
| | 61 | store.put(Version.class, Version.getInstance()); |
| | 62 | } |
| | 63 | final Version replacementVersion = new MockVersion(annotation.get().value()); |
| | 64 | TestUtils.setPrivateStaticField(Version.class, "instance", replacementVersion); |
| | 65 | } |
| | 66 | } |
| | 67 | } |
| | 68 | |
| | 69 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/BasicPreferences.java b/test/unit/org/openstreetmap/josm/testutils/annotations/BasicPreferences.java
index 1ee93ed28b..ee81391c02 100644
|
a
|
b
|
package org.openstreetmap.josm.testutils.annotations;
|
| 3 | 3 | |
| 4 | 4 | import java.lang.annotation.Documented; |
| 5 | 5 | import java.lang.annotation.ElementType; |
| | 6 | import java.lang.annotation.Inherited; |
| 6 | 7 | import java.lang.annotation.Retention; |
| 7 | 8 | import java.lang.annotation.RetentionPolicy; |
| 8 | 9 | import java.lang.annotation.Target; |
| | 10 | import java.lang.reflect.Field; |
| | 11 | import java.nio.file.Path; |
| 9 | 12 | |
| 10 | 13 | import org.junit.jupiter.api.extension.AfterAllCallback; |
| 11 | 14 | import org.junit.jupiter.api.extension.AfterEachCallback; |
| … |
… |
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
| 14 | 17 | import org.junit.jupiter.api.extension.ExtendWith; |
| 15 | 18 | import org.junit.jupiter.api.extension.ExtensionContext; |
| 16 | 19 | import org.junit.jupiter.api.extension.ExtensionContext.Namespace; |
| | 20 | import org.junit.platform.commons.util.ClassFilter; |
| | 21 | import org.junit.platform.commons.util.ReflectionUtils; |
| 17 | 22 | import org.openstreetmap.josm.data.Preferences; |
| | 23 | import org.openstreetmap.josm.data.preferences.AbstractProperty; |
| 18 | 24 | import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; |
| 19 | 25 | import org.openstreetmap.josm.data.preferences.JosmUrls; |
| 20 | 26 | import org.openstreetmap.josm.spi.preferences.Config; |
| 21 | 27 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 28 | import org.openstreetmap.josm.tools.Logging; |
| 22 | 29 | |
| 23 | 30 | /** |
| 24 | 31 | * Allow tests to use JOSM preferences (see {@link JOSMTestRules#preferences()}). |
| … |
… |
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
| 31 | 38 | @Documented |
| 32 | 39 | @Retention(RetentionPolicy.RUNTIME) |
| 33 | 40 | @Target({ElementType.TYPE, ElementType.METHOD}) |
| | 41 | @Inherited |
| | 42 | // Force use of a new JOSM home every run (this helps avoid resetting the user's JOSM preferences, when run from an IDE) |
| | 43 | @JosmHome |
| 34 | 44 | @ExtendWith(BasicPreferences.BasicPreferencesExtension.class) |
| 35 | 45 | public @interface BasicPreferences { |
| 36 | 46 | |
| | 47 | /** {@code true} to clear preferences between tests. Alternatively, re-annotate specific tests with this annotation. */ |
| | 48 | boolean value() default false; |
| | 49 | |
| 37 | 50 | /** |
| 38 | 51 | * Initialize basic preferences. This is often more than enough for basic tests. |
| 39 | 52 | * @author Taylor Smock |
| … |
… |
public @interface BasicPreferences {
|
| 42 | 55 | @Override |
| 43 | 56 | public void afterAll(ExtensionContext context) throws Exception { |
| 44 | 57 | AnnotationUtils.resetStaticClass(Config.class); |
| | 58 | |
| | 59 | // Ensure that config tests are consistent |
| | 60 | resetConfigVariables(null); |
| 45 | 61 | } |
| 46 | 62 | |
| 47 | 63 | @Override |
| 48 | 64 | public void afterEach(ExtensionContext context) throws Exception { |
| 49 | | if (context.getElement().isPresent() && context.getElement().get().isAnnotationPresent(BasicPreferences.class)) { |
| | 65 | if (context.getElement().isPresent() && context.getElement().get().isAnnotationPresent(BasicPreferences.class) |
| | 66 | || AnnotationUtils.findFirstParentAnnotation(context, BasicPreferences.class).map(BasicPreferences::value).orElse(false)) { |
| 50 | 67 | this.afterAll(context); |
| 51 | 68 | } |
| 52 | 69 | } |
| … |
… |
public @interface BasicPreferences {
|
| 64 | 81 | |
| 65 | 82 | // Store the pref for other extensions |
| 66 | 83 | context.getStore(Namespace.create(BasicPreferencesExtension.class)).put("preferences", pref); |
| | 84 | |
| | 85 | resetConfigVariables(pref); |
| 67 | 86 | } |
| 68 | 87 | |
| 69 | 88 | @Override |
| 70 | 89 | public void beforeEach(ExtensionContext context) throws Exception { |
| 71 | | if (AnnotationUtils.elementIsAnnotated(context.getElement(), BasicPreferences.class) || Config.getPref() == null) { |
| | 90 | if (AnnotationUtils.elementIsAnnotated(context.getElement(), BasicPreferences.class) || Config.getPref() == null |
| | 91 | || AnnotationUtils.findFirstParentAnnotation(context, BasicPreferences.class).map(BasicPreferences::value).orElse(false)) { |
| 72 | 92 | this.beforeAll(context); |
| 73 | 93 | } |
| 74 | 94 | } |
| | 95 | |
| | 96 | /** |
| | 97 | * Reset all {@link AbstractProperty} preferences to the new preference |
| | 98 | * @param pref The preference to use |
| | 99 | * @throws ReflectiveOperationException if reflection fails |
| | 100 | */ |
| | 101 | private void resetConfigVariables(Preferences pref) throws ReflectiveOperationException { |
| | 102 | final Field configField = AbstractProperty.class.getDeclaredField("preferences"); |
| | 103 | configField.setAccessible(true); |
| | 104 | for (Path classPath : ReflectionUtils.getAllClasspathRootDirectories()) { |
| | 105 | for (Class<?> clazz : ReflectionUtils.findAllClassesInClasspathRoot(classPath.toUri(), ClassFilter.of(tClazz -> true))) { |
| | 106 | try { |
| | 107 | for (Field field : clazz.getDeclaredFields()) { |
| | 108 | if (ReflectionUtils.isStatic(field) && AbstractProperty.class.isAssignableFrom(field.getType())) { |
| | 109 | field.setAccessible(true); |
| | 110 | configField.set(field.get(null), pref); |
| | 111 | } |
| | 112 | } |
| | 113 | } catch (NoClassDefFoundError noClassDefFoundError) { |
| | 114 | Logging.warn("{0}: No class definition found", clazz.getName()); |
| | 115 | } |
| | 116 | } |
| | 117 | } |
| | 118 | |
| | 119 | // Ensure that the directories get reset as well. This is stored in the main preferences holder (Preferences.main()) |
| | 120 | JosmBaseDirectories.getInstance().clearMemos(); |
| | 121 | } |
| 75 | 122 | } |
| 76 | 123 | } |
| | 124 | |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/BasicWiremock.java b/test/unit/org/openstreetmap/josm/testutils/annotations/BasicWiremock.java
index 2abe8efff9..cf15c5a700 100644
|
a
|
b
|
import static org.junit.jupiter.api.Assertions.fail;
|
| 7 | 7 | |
| 8 | 8 | import java.lang.annotation.Documented; |
| 9 | 9 | import java.lang.annotation.ElementType; |
| | 10 | import java.lang.annotation.Inherited; |
| 10 | 11 | import java.lang.annotation.Retention; |
| 11 | 12 | import java.lang.annotation.RetentionPolicy; |
| 12 | 13 | import java.lang.annotation.Target; |
| … |
… |
import org.junit.jupiter.api.extension.ParameterContext;
|
| 29 | 30 | import org.junit.jupiter.api.extension.ParameterResolutionException; |
| 30 | 31 | import org.junit.jupiter.api.extension.ParameterResolver; |
| 31 | 32 | import org.junit.platform.commons.support.AnnotationSupport; |
| | 33 | import org.junit.platform.commons.util.ReflectionUtils; |
| 32 | 34 | import org.openstreetmap.josm.TestUtils; |
| 33 | 35 | import org.openstreetmap.josm.gui.progress.NullProgressMonitor; |
| 34 | 36 | import org.openstreetmap.josm.gui.util.GuiHelper; |
| … |
… |
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
|
| 54 | 56 | @Retention(RetentionPolicy.RUNTIME) |
| 55 | 57 | @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) |
| 56 | 58 | @ExtendWith(BasicWiremock.WireMockExtension.class) |
| | 59 | @ExtendWith(BasicWiremock.WireMockParameterResolver.class) |
| | 60 | @Inherited |
| 57 | 61 | public @interface BasicWiremock { |
| 58 | 62 | /** |
| 59 | 63 | * Set the path for the data. Default is {@link TestUtils#getTestDataRoot()}. |
| … |
… |
public @interface BasicWiremock {
|
| 78 | 82 | * |
| 79 | 83 | */ |
| 80 | 84 | class WireMockExtension |
| 81 | | implements AfterAllCallback, AfterEachCallback, BeforeAllCallback, BeforeEachCallback, ParameterResolver { |
| | 85 | implements AfterAllCallback, AfterEachCallback, BeforeAllCallback, BeforeEachCallback { |
| 82 | 86 | /** |
| 83 | 87 | * Get the default wiremock server |
| 84 | 88 | * @param context The context to search |
| … |
… |
public @interface BasicWiremock {
|
| 92 | 96 | final List<ResponseTransformer> transformers = new ArrayList<>(annotation.responseTransformers().length); |
| 93 | 97 | for (Class<? extends ResponseTransformer> responseTransformer : annotation.responseTransformers()) { |
| 94 | 98 | for (Pair<Class<?>[], Object[]> parameterMapping : Arrays.asList( |
| 95 | | new Pair<>(new Class<?>[] {ExtensionContext.class }, new Object[] {context }), |
| | 99 | new Pair<>(new Class<?>[] {ExtensionContext.class}, new Object[] {context}), |
| 96 | 100 | new Pair<>(new Class<?>[0], new Object[0]))) { |
| 97 | 101 | try { |
| 98 | | Constructor<? extends ResponseTransformer> constructor = responseTransformer |
| 99 | | .getConstructor(parameterMapping.a); |
| | 102 | Constructor<? extends ResponseTransformer> constructor = responseTransformer.getConstructor( |
| | 103 | parameterMapping.a); |
| 100 | 104 | transformers.add(constructor.newInstance(parameterMapping.b)); |
| 101 | 105 | break; |
| 102 | 106 | } catch (ReflectiveOperationException e) { |
| … |
… |
public @interface BasicWiremock {
|
| 104 | 108 | } |
| 105 | 109 | } |
| 106 | 110 | } |
| 107 | | return new WireMockServer( |
| 108 | | options().usingFilesUnderDirectory(Utils.isStripEmpty(annotation.value()) ? TestUtils.getTestDataRoot() : |
| 109 | | annotation.value()).extensions(transformers.toArray(new ResponseTransformer[0])).dynamicPort()); |
| | 111 | return new WireMockServer(options().usingFilesUnderDirectory( |
| | 112 | Utils.isStripEmpty(annotation.value()) ? TestUtils.getTestDataRoot() : |
| | 113 | annotation.value()).extensions(transformers.toArray(new ResponseTransformer[0])).dynamicPort()); |
| 110 | 114 | }, WireMockServer.class); |
| 111 | 115 | } |
| 112 | 116 | |
| … |
… |
public @interface BasicWiremock {
|
| 138 | 142 | List<LoggedRequest> missed = getWiremock(context).findUnmatchedRequests().getRequests(); |
| 139 | 143 | missed.forEach(r -> Logging.error(r.getAbsoluteUrl())); |
| 140 | 144 | try { |
| 141 | | assertTrue(missed.isEmpty(), missed.stream().map(LoggedRequest::getUrl).collect(Collectors.joining("\n\n"))); |
| | 145 | assertTrue(missed.isEmpty(), |
| | 146 | missed.stream().map(LoggedRequest::getUrl).collect(Collectors.joining("\n\n"))); |
| 142 | 147 | } finally { |
| 143 | 148 | getWiremock(context).resetRequests(); |
| 144 | 149 | getWiremock(context).resetToDefaultMappings(); |
| … |
… |
public @interface BasicWiremock {
|
| 153 | 158 | @Override |
| 154 | 159 | public void beforeAll(ExtensionContext context) throws Exception { |
| 155 | 160 | getWiremock(context).start(); |
| | 161 | setWireMocks(context); |
| 156 | 162 | } |
| 157 | 163 | |
| 158 | 164 | @Override |
| … |
… |
public @interface BasicWiremock {
|
| 160 | 166 | if (AnnotationUtils.elementIsAnnotated(context.getElement(), BasicWiremock.class) || getWiremock(context) == null) { |
| 161 | 167 | this.beforeAll(context); |
| 162 | 168 | } |
| | 169 | setWireMocks(context); |
| | 170 | } |
| | 171 | |
| | 172 | /** |
| | 173 | * Set wiremock fields |
| | 174 | * @param context The context to use |
| | 175 | * @throws IllegalAccessException If the object cannot be accessed |
| | 176 | */ |
| | 177 | private static void setWireMocks(ExtensionContext context) throws IllegalAccessException { |
| 163 | 178 | if (context.getTestClass().isPresent()) { |
| 164 | | List<Field> wireMockFields = AnnotationSupport.findAnnotatedFields(context.getRequiredTestClass(), BasicWiremock.class); |
| | 179 | List<Field> wireMockFields = AnnotationSupport.findAnnotatedFields(context.getRequiredTestClass(), |
| | 180 | BasicWiremock.class); |
| 165 | 181 | for (Field field : wireMockFields) { |
| 166 | | if (WireMockServer.class.isAssignableFrom(field.getType())) { |
| | 182 | if (field.getType().isAssignableFrom(WireMockServer.class)) { |
| 167 | 183 | final boolean isAccessible = field.isAccessible(); |
| 168 | 184 | field.setAccessible(true); |
| 169 | 185 | try { |
| 170 | | field.set(context.getTestInstance().orElse(null), getWiremock(context)); |
| | 186 | if (ReflectionUtils.isStatic(field) && context.getRequiredTestClass().equals(context.getElement().orElse(null))) { |
| | 187 | field.set(null, getWiremock(context)); |
| | 188 | } else if (context.getTestInstance().isPresent()) { |
| | 189 | field.set(context.getTestInstance().get(), getWiremock(context)); |
| | 190 | } |
| 171 | 191 | } finally { |
| 172 | 192 | field.setAccessible(isAccessible); |
| 173 | 193 | } |
| … |
… |
public @interface BasicWiremock {
|
| 176 | 196 | } |
| 177 | 197 | } |
| 178 | 198 | } |
| | 199 | |
| 179 | 200 | } |
| | 201 | } |
| 180 | 202 | |
| | 203 | /** |
| | 204 | * A specific resolver for WireMock parameters |
| | 205 | */ |
| | 206 | class WireMockParameterResolver implements ParameterResolver { |
| 181 | 207 | @Override |
| 182 | 208 | public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) |
| 183 | 209 | throws ParameterResolutionException { |
| 184 | 210 | return parameterContext.getParameter().getAnnotation(BasicWiremock.class) != null |
| 185 | | && parameterContext.getParameter().getType() == WireMockServer.class; |
| | 211 | && parameterContext.getParameter().getType().isAssignableFrom(WireMockServer.class); |
| 186 | 212 | } |
| 187 | 213 | |
| 188 | 214 | @Override |
| 189 | 215 | public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) |
| 190 | 216 | throws ParameterResolutionException { |
| 191 | | return getWiremock(extensionContext); |
| | 217 | return WireMockExtension.getWiremock(extensionContext); |
| 192 | 218 | } |
| 193 | 219 | } |
| 194 | 220 | |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/FakeImagery.java b/test/unit/org/openstreetmap/josm/testutils/annotations/FakeImagery.java
new file mode 100644
index 0000000000..db54a5af8f
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.testutils.annotations; |
| | 3 | |
| | 4 | import static org.junit.jupiter.api.Assertions.fail; |
| | 5 | import static org.openstreetmap.josm.TestUtils.getPrivateStaticField; |
| | 6 | |
| | 7 | import java.awt.Color; |
| | 8 | import java.io.IOException; |
| | 9 | import java.lang.annotation.Documented; |
| | 10 | import java.lang.annotation.ElementType; |
| | 11 | import java.lang.annotation.Retention; |
| | 12 | import java.lang.annotation.RetentionPolicy; |
| | 13 | import java.lang.annotation.Target; |
| | 14 | import java.lang.reflect.Method; |
| | 15 | import java.lang.reflect.Type; |
| | 16 | import java.util.ArrayList; |
| | 17 | import java.util.Arrays; |
| | 18 | import java.util.EnumSet; |
| | 19 | import java.util.List; |
| | 20 | import java.util.Optional; |
| | 21 | import java.util.Set; |
| | 22 | import java.util.function.Supplier; |
| | 23 | |
| | 24 | import org.junit.jupiter.api.extension.ExtendWith; |
| | 25 | import org.junit.jupiter.api.extension.ExtensionContext; |
| | 26 | import org.junit.jupiter.api.extension.ParameterContext; |
| | 27 | import org.junit.jupiter.api.extension.ParameterResolutionException; |
| | 28 | import org.junit.jupiter.api.extension.ParameterResolver; |
| | 29 | import org.junit.platform.commons.support.AnnotationSupport; |
| | 30 | import org.junit.platform.commons.util.ReflectionUtils; |
| | 31 | import org.openstreetmap.josm.data.imagery.ImageryInfo; |
| | 32 | import org.openstreetmap.josm.data.imagery.ImageryLayerInfo; |
| | 33 | import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser; |
| | 34 | import org.openstreetmap.josm.testutils.annotations.fake_imagery.ColorSource; |
| | 35 | import org.openstreetmap.josm.testutils.annotations.fake_imagery.ConstSource; |
| | 36 | import org.openstreetmap.josm.tools.Logging; |
| | 37 | import org.opentest4j.AssertionFailedError; |
| | 38 | |
| | 39 | import com.github.tomakehurst.wiremock.WireMockServer; |
| | 40 | import com.github.tomakehurst.wiremock.client.WireMock; |
| | 41 | |
| | 42 | /** |
| | 43 | * An annotation for fake imagery |
| | 44 | * Please note that this currently only supports single-color tile sources. |
| | 45 | * @author Taylor Smock |
| | 46 | * @since xxx |
| | 47 | */ |
| | 48 | @Documented |
| | 49 | @Retention(RetentionPolicy.RUNTIME) |
| | 50 | @Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER}) |
| | 51 | @BasicWiremock |
| | 52 | @ExtendWith(FakeImagery.FakeImageryExtension.class) |
| | 53 | @ExtendWith(FakeImagery.FakeImageryParameterResolver.class) |
| | 54 | public @interface FakeImagery { |
| | 55 | /** |
| | 56 | * The options to use for FakeImagery |
| | 57 | * @return The options |
| | 58 | */ |
| | 59 | Options[] options() default {Options.CLEAR_LAYER_LIST, Options.CLEAR_SLIPPY_MAP_SOURCES, Options.REGISTER_IN_LAYER_LIST}; |
| | 60 | |
| | 61 | /** |
| | 62 | * The color tile sources to use for FakeImagery |
| | 63 | * @return The simple color tile sources |
| | 64 | */ |
| | 65 | ColorTileSource[] colorTileSources() default {@ColorTileSource(colors = Colors.WHITE, name = "White Tiles"), |
| | 66 | @ColorTileSource(colors = Colors.BLACK, name = "Black Tiles"), |
| | 67 | @ColorTileSource(colors = Colors.MAGENTA, name = "Magenta Tiles"), @ColorTileSource(colors = Colors.GREEN, name = "Green Tiles")}; |
| | 68 | |
| | 69 | /** |
| | 70 | * The more complex tilesources to use. The classes <i>must</i> have a constructor with no arguments |
| | 71 | * @return The tile sources to instantiate |
| | 72 | */ |
| | 73 | Class<? extends ConstSource>[] tileSources() default {}; |
| | 74 | |
| | 75 | /** |
| | 76 | * Define a simple tile source (only single color supported at this time) |
| | 77 | * @author Taylor Smock |
| | 78 | */ |
| | 79 | @Retention(RetentionPolicy.RUNTIME) |
| | 80 | @Target(ElementType.LOCAL_VARIABLE) |
| | 81 | @interface ColorTileSource { |
| | 82 | /** |
| | 83 | * Pixel dimension of tiles (usually 256) |
| | 84 | * @return The expected size for the tiles |
| | 85 | */ |
| | 86 | int size() default 256; |
| | 87 | |
| | 88 | /** |
| | 89 | * Color for these tiles |
| | 90 | * @return The Color enum (sorry, you can't make your own arbitrary colors) |
| | 91 | */ |
| | 92 | Colors colors() default Colors.BLACK; |
| | 93 | |
| | 94 | /** |
| | 95 | * text label/name for this source if displayed in JOSM menus |
| | 96 | * @return The name for the layer/menu entry |
| | 97 | */ |
| | 98 | String name(); |
| | 99 | } |
| | 100 | |
| | 101 | /** |
| | 102 | * The options that can be used for FakeImagery |
| | 103 | * @author Taylor Smock |
| | 104 | * |
| | 105 | */ |
| | 106 | enum Options { |
| | 107 | /** |
| | 108 | * whether to clear ImageryLayerInfo's layer list of any pre-existing entries |
| | 109 | */ |
| | 110 | CLEAR_LAYER_LIST, |
| | 111 | /** |
| | 112 | * whether to clear SlippyMapBBoxChooser's stubborn fallback Mapnik ColorTileSource |
| | 113 | */ |
| | 114 | CLEAR_SLIPPY_MAP_SOURCES, |
| | 115 | /** |
| | 116 | * whether to add sources to ImageryLayerInfo's layer list |
| | 117 | */ |
| | 118 | REGISTER_IN_LAYER_LIST |
| | 119 | } |
| | 120 | |
| | 121 | /** |
| | 122 | * An enum for colors (currently only uses static colors from {@link Color}) |
| | 123 | */ |
| | 124 | enum Colors { |
| | 125 | BLACK(Color.BLACK), |
| | 126 | BLUE(Color.BLUE), |
| | 127 | CYAN(Color.CYAN), |
| | 128 | DARK_GRAY(Color.DARK_GRAY), |
| | 129 | GRAY(Color.GRAY), |
| | 130 | GREEN(Color.GREEN), |
| | 131 | LIGHT_GRAY(Color.LIGHT_GRAY), |
| | 132 | MAGENTA(Color.MAGENTA), |
| | 133 | ORANGE(Color.ORANGE), |
| | 134 | PINK(Color.PINK), |
| | 135 | RED(Color.RED), |
| | 136 | WHITE(Color.WHITE), |
| | 137 | YELLOW(Color.YELLOW); |
| | 138 | |
| | 139 | private final Color color; |
| | 140 | Colors(Color color) { |
| | 141 | this.color = color; |
| | 142 | } |
| | 143 | |
| | 144 | public Color getColor() { |
| | 145 | return this.color; |
| | 146 | } |
| | 147 | } |
| | 148 | |
| | 149 | /** |
| | 150 | * A class to specifically mock Imagery calls |
| | 151 | */ |
| | 152 | class FakeImageryExtension extends BasicWiremock.WireMockExtension { |
| | 153 | static final String SLIPPY_MAP_PROVIDERS = "slippyMapProviders"; |
| | 154 | static final String SLIPPY_MAP_DEFAULT_PROVIDER = "slippyMapDefaultProvider"; |
| | 155 | static final String ORIGINAL_IMAGERY_INFO_LIST = "originalImageryInfoList"; |
| | 156 | |
| | 157 | @Override |
| | 158 | public void afterEach(ExtensionContext context) throws Exception { |
| | 159 | try { |
| | 160 | super.afterEach(context); |
| | 161 | } finally { |
| | 162 | cleanup(context); |
| | 163 | } |
| | 164 | } |
| | 165 | |
| | 166 | @Override |
| | 167 | public void beforeAll(ExtensionContext context) throws Exception { |
| | 168 | if (context.getStore(ExtensionContext.Namespace.create(BasicPreferences.BasicPreferencesExtension.class)) |
| | 169 | .get("preferences") == null) { |
| | 170 | fail("FakeImageryExtension requires preferences (try @BasicPreferences)"); |
| | 171 | } |
| | 172 | super.beforeAll(context); |
| | 173 | |
| | 174 | // Get the wiremock server |
| | 175 | final WireMockServer wireMockServer = getWiremock(context); |
| | 176 | |
| | 177 | // set up a stub target for the early request hack |
| | 178 | wireMockServer.stubFor(WireMock.get( |
| | 179 | WireMock.urlMatching("/_poke") |
| | 180 | ).willReturn(WireMock.aResponse().withStatus(200).withBody("ow."))); |
| | 181 | runServer(wireMockServer); |
| | 182 | } |
| | 183 | |
| | 184 | @Override |
| | 185 | public void beforeEach(final ExtensionContext context) throws Exception { |
| | 186 | super.beforeEach(context); |
| | 187 | final FakeImagery fakeImagery = AnnotationSupport.findAnnotation(context.getElement(), FakeImagery.class) |
| | 188 | .orElseGet(() -> AnnotationSupport.findAnnotation(context.getRequiredTestClass(), FakeImagery.class) |
| | 189 | .orElseThrow((Supplier<AssertionFailedError>) () -> fail(context.getDisplayName() + " missing @FakeImagery annotation"))); |
| | 190 | final Set<Options> options = EnumSet.copyOf(Arrays.asList(fakeImagery.options())); |
| | 191 | final ColorTileSource[] colorTileSources = fakeImagery.colorTileSources(); |
| | 192 | final Class<? extends ConstSource>[] additionalTileSources = fakeImagery.tileSources(); |
| | 193 | |
| | 194 | // Get the wiremock server |
| | 195 | final WireMockServer wireMockServer = getWiremock(context); |
| | 196 | |
| | 197 | final List<ConstSource> constSourceList = new ArrayList<>(colorTileSources.length + additionalTileSources.length); |
| | 198 | for (ColorTileSource source : colorTileSources) { |
| | 199 | final ColorSource colorSource = new ColorSource(source); |
| | 200 | constSourceList.add(colorSource); |
| | 201 | wireMockServer.stubFor(colorSource.getMappingBuilder().willReturn(colorSource.getResponseDefinitionBuilder())); |
| | 202 | } |
| | 203 | |
| | 204 | for (Class<? extends ConstSource> constSourceClazz : additionalTileSources) { |
| | 205 | final ConstSource constSource = ReflectionUtils.newInstance(constSourceClazz); |
| | 206 | constSourceList.add(constSource); |
| | 207 | wireMockServer.stubFor(constSource.getMappingBuilder().willReturn(constSource.getResponseDefinitionBuilder())); |
| | 208 | } |
| | 209 | |
| | 210 | registerLayers(context, options, constSourceList, wireMockServer); |
| | 211 | } |
| | 212 | |
| | 213 | /** |
| | 214 | * A hack to circumvent a WireMock bug concerning delayed server startup. sending an early request |
| | 215 | * to the mock server seems to prompt it to start earlier (though this request itself is not |
| | 216 | * expected to succeed). See <a href="https://github.com/tomakehurst/wiremock/issues/97">WireMock Issue #97</a> |
| | 217 | */ |
| | 218 | private static void runServer(WireMockServer wireMockServer) { |
| | 219 | try { |
| | 220 | new java.net.URL(wireMockServer.url("/_poke")).getContent(); |
| | 221 | } catch (IOException e) { |
| | 222 | Logging.trace(e); |
| | 223 | } |
| | 224 | } |
| | 225 | |
| | 226 | private static void registerLayers(final ExtensionContext context, final Set<Options> options, final List<ConstSource> sourcesList, |
| | 227 | final WireMockServer wireMockServer) { |
| | 228 | if (options.contains(Options.REGISTER_IN_LAYER_LIST) || options.contains(Options.CLEAR_LAYER_LIST)) { |
| | 229 | ExtensionContext.Store store = context.getStore( |
| | 230 | ExtensionContext.Namespace.create(FakeImageryExtension.class)); |
| | 231 | if (options.contains(Options.CLEAR_SLIPPY_MAP_SOURCES)) { |
| | 232 | try { |
| | 233 | final List<SlippyMapBBoxChooser.TileSourceProvider> slippyMapProviders = |
| | 234 | (List<SlippyMapBBoxChooser.TileSourceProvider>) |
| | 235 | getPrivateStaticField(SlippyMapBBoxChooser.class, "providers"); |
| | 236 | // pop this off the beginning of the list, keep for later |
| | 237 | final SlippyMapBBoxChooser.TileSourceProvider slippyMapDefaultProvider = slippyMapProviders.remove(0); |
| | 238 | store.put(SLIPPY_MAP_PROVIDERS, slippyMapProviders); |
| | 239 | store.put(SLIPPY_MAP_DEFAULT_PROVIDER, slippyMapDefaultProvider); |
| | 240 | } catch (ReflectiveOperationException e) { |
| | 241 | Logging.warn("Failed to remove default SlippyMapBBoxChooser TileSourceProvider"); |
| | 242 | } |
| | 243 | } |
| | 244 | |
| | 245 | if (options.contains(Options.CLEAR_LAYER_LIST)) { |
| | 246 | final List<ImageryInfo> originalImageryInfoList = ImageryLayerInfo.instance.getLayers(); |
| | 247 | store.put(ORIGINAL_IMAGERY_INFO_LIST, originalImageryInfoList); |
| | 248 | ImageryLayerInfo.instance.clear(); |
| | 249 | } |
| | 250 | if (options.contains(Options.REGISTER_IN_LAYER_LIST)) { |
| | 251 | for (ConstSource source : sourcesList) { |
| | 252 | ImageryLayerInfo.addLayer(source.getImageryInfo(wireMockServer)); |
| | 253 | } |
| | 254 | } |
| | 255 | store.put(ConstSource.class, sourcesList); |
| | 256 | } |
| | 257 | } |
| | 258 | |
| | 259 | /** |
| | 260 | * Cleanup the environment |
| | 261 | * @param context The context with the original values |
| | 262 | */ |
| | 263 | private static void cleanup(final ExtensionContext context) { |
| | 264 | final ExtensionContext.Store store = context.getStore( |
| | 265 | ExtensionContext.Namespace.create(FakeImageryExtension.class)); |
| | 266 | final List<SlippyMapBBoxChooser.TileSourceProvider> slippyMapProviders = (List<SlippyMapBBoxChooser.TileSourceProvider>) |
| | 267 | store.remove(SLIPPY_MAP_PROVIDERS, List.class); |
| | 268 | final SlippyMapBBoxChooser.TileSourceProvider slippyMapDefaultProvider = store.remove(SLIPPY_MAP_DEFAULT_PROVIDER, |
| | 269 | SlippyMapBBoxChooser.TileSourceProvider.class); |
| | 270 | final List<ImageryInfo> originalImageryInfoList = (List<ImageryInfo>) store.remove(ORIGINAL_IMAGERY_INFO_LIST, List.class); |
| | 271 | // clean up to original state |
| | 272 | if (slippyMapDefaultProvider != null && slippyMapProviders != null) { |
| | 273 | slippyMapProviders.add(0, slippyMapDefaultProvider); |
| | 274 | } |
| | 275 | if (originalImageryInfoList != null) { |
| | 276 | ImageryLayerInfo.instance.clear(); |
| | 277 | ImageryLayerInfo.addLayers(originalImageryInfoList); |
| | 278 | } |
| | 279 | } |
| | 280 | } |
| | 281 | |
| | 282 | /** |
| | 283 | * A parameter resolver for FakeImagery |
| | 284 | */ |
| | 285 | class FakeImageryParameterResolver implements ParameterResolver { |
| | 286 | @Override |
| | 287 | public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) |
| | 288 | throws ParameterResolutionException { |
| | 289 | ExtensionContext.Store store = extensionContext.getStore( |
| | 290 | ExtensionContext.Namespace.create(FakeImageryExtension.class)); |
| | 291 | if (store.get(ConstSource.class) != null && parameterContext.isAnnotated(FakeImagery.class) |
| | 292 | && List.class.isAssignableFrom(parameterContext.getParameter().getType())) { |
| | 293 | Optional<Method> optionalMethod = ReflectionUtils.findMethod(parameterContext.getParameter().getParameterizedType().getClass(), |
| | 294 | "getActualTypeArguments"); |
| | 295 | if (!optionalMethod.isPresent() || !optionalMethod.get().getReturnType().isAssignableFrom(Type[].class)) { |
| | 296 | // We can't check the type. Therefore, we must hope that everything goes well. |
| | 297 | return true; |
| | 298 | } |
| | 299 | Type[] types = (Type[]) ReflectionUtils.invokeMethod(optionalMethod.get(), |
| | 300 | parameterContext.getParameter().getParameterizedType()); |
| | 301 | return types.length == 1 && ConstSource.class.isAssignableFrom((Class<?>) types[0]); |
| | 302 | } |
| | 303 | return false; |
| | 304 | } |
| | 305 | |
| | 306 | @Override |
| | 307 | public List<ConstSource> resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) |
| | 308 | throws ParameterResolutionException { |
| | 309 | ExtensionContext.Store store = extensionContext.getStore( |
| | 310 | ExtensionContext.Namespace.create(FakeImageryExtension.class)); |
| | 311 | return (List<ConstSource>) store.get(ConstSource.class, List.class); |
| | 312 | } |
| | 313 | } |
| | 314 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/FullPreferences.java b/test/unit/org/openstreetmap/josm/testutils/annotations/FullPreferences.java
index 92fa0844e5..42d07918df 100644
|
a
|
b
|
import org.openstreetmap.josm.testutils.annotations.BasicPreferences.BasicPrefer
|
| 29 | 29 | @Documented |
| 30 | 30 | @Retention(RetentionPolicy.RUNTIME) |
| 31 | 31 | @Target({ElementType.TYPE, ElementType.METHOD}) |
| 32 | | @JosmHome |
| 33 | 32 | @BasicPreferences |
| 34 | 33 | @ExtendWith(FullPreferences.UsePreferencesExtension.class) |
| 35 | 34 | public @interface FullPreferences { |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/IntegrationTest.java b/test/unit/org/openstreetmap/josm/testutils/annotations/IntegrationTest.java
new file mode 100644
index 0000000000..e1698055b6
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.testutils.annotations; |
| | 3 | |
| | 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; |
| | 5 | |
| | 6 | import java.lang.annotation.Documented; |
| | 7 | import java.lang.annotation.ElementType; |
| | 8 | import java.lang.annotation.Retention; |
| | 9 | import java.lang.annotation.Target; |
| | 10 | |
| | 11 | import org.junit.jupiter.api.Tag; |
| | 12 | |
| | 13 | /** |
| | 14 | * Integration Tests annotation (JUnit5 can filter tests with/without this annotation) |
| | 15 | * @author Taylor Smock |
| | 16 | * @since xxx |
| | 17 | */ |
| | 18 | @Documented |
| | 19 | @Retention(RUNTIME) |
| | 20 | @Target({ElementType.METHOD, ElementType.TYPE}) |
| | 21 | @Tag("integrationTest") |
| | 22 | public @interface IntegrationTest { |
| | 23 | |
| | 24 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/JosmHome.java b/test/unit/org/openstreetmap/josm/testutils/annotations/JosmHome.java
index c51d0e00f4..61075fbe2f 100644
|
a
|
b
|
import java.nio.file.attribute.BasicFileAttributes;
|
| 16 | 16 | import java.util.UUID; |
| 17 | 17 | |
| 18 | 18 | import org.junit.jupiter.api.extension.AfterAllCallback; |
| | 19 | import org.junit.jupiter.api.extension.AfterEachCallback; |
| 19 | 20 | import org.junit.jupiter.api.extension.BeforeAllCallback; |
| | 21 | import org.junit.jupiter.api.extension.BeforeEachCallback; |
| 20 | 22 | import org.junit.jupiter.api.extension.ExtendWith; |
| 21 | 23 | import org.junit.jupiter.api.extension.ExtensionContext; |
| 22 | 24 | import org.junit.jupiter.api.extension.ExtensionContext.Namespace; |
| … |
… |
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
| 25 | 27 | |
| 26 | 28 | /** |
| 27 | 29 | * Use the JOSM home directory. See {@link JOSMTestRules}. |
| 28 | | * Typically only used by {@link FullPreferences}. |
| | 30 | * Called by {@link BasicPreferences}. |
| 29 | 31 | * |
| 30 | 32 | * @author Taylor Smock |
| 31 | 33 | * @since 18037 |
| … |
… |
public @interface JosmHome {
|
| 39 | 41 | * Create a JOSM home directory. Prefer using {@link JosmHome}. |
| 40 | 42 | * @author Taylor Smock |
| 41 | 43 | */ |
| 42 | | class JosmHomeExtension implements BeforeAllCallback, AfterAllCallback { |
| | 44 | class JosmHomeExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback { |
| 43 | 45 | @Override |
| 44 | 46 | public void afterAll(ExtensionContext context) throws Exception { |
| 45 | 47 | Path tempDir = context.getStore(Namespace.create(JosmHome.class)).get("home", Path.class); |
| … |
… |
public @interface JosmHome {
|
| 66 | 68 | System.setProperty("josm.home", home.getAbsolutePath()); |
| 67 | 69 | JosmBaseDirectories.getInstance().clearMemos(); |
| 68 | 70 | } |
| | 71 | |
| | 72 | @Override |
| | 73 | public void afterEach(ExtensionContext context) throws Exception { |
| | 74 | if (shouldRun(context)) { |
| | 75 | this.afterAll(context); |
| | 76 | // Restore the "original" home |
| | 77 | ExtensionContext.Store store = context.getStore(Namespace.create(JosmHome.class)); |
| | 78 | Path oldHome = store.get("old_home", Path.class); |
| | 79 | System.setProperty("josm.home", oldHome.toFile().getAbsolutePath()); |
| | 80 | JosmBaseDirectories.getInstance().clearMemos(); |
| | 81 | } |
| | 82 | } |
| | 83 | |
| | 84 | @Override |
| | 85 | public void beforeEach(ExtensionContext context) throws Exception { |
| | 86 | if (shouldRun(context)) { |
| | 87 | // Store the "original" home |
| | 88 | ExtensionContext.Store store = context.getStore(Namespace.create(JosmHome.class)); |
| | 89 | store.put("old_home", store.get("home", Path.class)); |
| | 90 | this.beforeAll(context); |
| | 91 | } |
| | 92 | } |
| | 93 | |
| | 94 | /** |
| | 95 | * Check if this should run before/after each test |
| | 96 | * @param context The context to use |
| | 97 | * @return {@code true} if we should change home directories before/after each test |
| | 98 | */ |
| | 99 | private boolean shouldRun(ExtensionContext context) { |
| | 100 | return AnnotationUtils.findFirstParentAnnotation(context, BasicPreferences.class).map(BasicPreferences::value).orElse(false); |
| | 101 | } |
| 69 | 102 | } |
| 70 | 103 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/Main.java b/test/unit/org/openstreetmap/josm/testutils/annotations/Main.java
new file mode 100644
index 0000000000..1d430563b0
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.testutils.annotations; |
| | 3 | |
| | 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; |
| | 5 | |
| | 6 | import java.lang.annotation.Documented; |
| | 7 | import java.lang.annotation.ElementType; |
| | 8 | import java.lang.annotation.Retention; |
| | 9 | import java.lang.annotation.Target; |
| | 10 | import java.util.Optional; |
| | 11 | |
| | 12 | import org.junit.jupiter.api.extension.AfterEachCallback; |
| | 13 | import org.junit.jupiter.api.extension.BeforeEachCallback; |
| | 14 | import org.junit.jupiter.api.extension.ExtendWith; |
| | 15 | import org.junit.jupiter.api.extension.ExtensionContext; |
| | 16 | import org.junit.platform.commons.support.AnnotationSupport; |
| | 17 | import org.openstreetmap.josm.JOSMFixture; |
| | 18 | import org.openstreetmap.josm.gui.MainApplication; |
| | 19 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 20 | import org.openstreetmap.josm.testutils.mockers.WindowlessMapViewStateMocker; |
| | 21 | import org.openstreetmap.josm.testutils.mockers.WindowlessNavigatableComponentMocker; |
| | 22 | |
| | 23 | /** |
| | 24 | * Use the {@link MainApplication#main}, {@code Main.contentPanePrivate}, {@code Main.mainPanel}, global variables in this test. |
| | 25 | * @author Taylor Smock |
| | 26 | * @see JOSMTestRules#main() |
| | 27 | * @since xxx |
| | 28 | */ |
| | 29 | @Documented |
| | 30 | @Retention(RUNTIME) |
| | 31 | @Target({ ElementType.TYPE, ElementType.METHOD }) |
| | 32 | @BasicPreferences |
| | 33 | @HTTP // Prevent MOTD from throwing |
| | 34 | @ExtendWith(Main.MainExtension.class) |
| | 35 | public @interface Main { |
| | 36 | /** |
| | 37 | * Get the class to use as the mocker for the map view |
| | 38 | * @return The mocker class for the map view |
| | 39 | */ |
| | 40 | Class<?> mapViewStateMocker() default WindowlessMapViewStateMocker.class; |
| | 41 | |
| | 42 | /** |
| | 43 | * Get the class to use for the navigable component |
| | 44 | * @return The class to use for the navigable component. |
| | 45 | */ |
| | 46 | Class<?> navigableComponentMocker() default WindowlessNavigatableComponentMocker.class; |
| | 47 | |
| | 48 | /** |
| | 49 | * Initialize the MainApplication |
| | 50 | * @author Taylor Smock |
| | 51 | */ |
| | 52 | class MainExtension implements BeforeEachCallback, AfterEachCallback { |
| | 53 | @Override |
| | 54 | public void afterEach(ExtensionContext context) throws Exception { |
| | 55 | synchronized (MainExtension.class) { |
| | 56 | MainApplication.getLayerManager().resetState(); |
| | 57 | AnnotationUtils.resetStaticClass(MainApplication.class); |
| | 58 | } |
| | 59 | } |
| | 60 | |
| | 61 | @Override |
| | 62 | public void beforeEach(ExtensionContext context) throws Exception { |
| | 63 | Optional<Main> annotation = AnnotationSupport.findAnnotation(context.getElement(), Main.class); |
| | 64 | Class<?> mapViewStateMocker = null; |
| | 65 | Class<?> navigableComponentMocker = null; |
| | 66 | if (annotation.isPresent()) { |
| | 67 | mapViewStateMocker = annotation.get().mapViewStateMocker(); |
| | 68 | navigableComponentMocker = annotation.get().navigableComponentMocker(); |
| | 69 | } |
| | 70 | |
| | 71 | // apply mockers to MapViewState and NavigableComponent whether we're headless or not |
| | 72 | // as we generally don't create the josm main window even in non-headless mode. |
| | 73 | if (mapViewStateMocker != null) { |
| | 74 | mapViewStateMocker.getConstructor().newInstance(); |
| | 75 | } |
| | 76 | if (navigableComponentMocker != null) { |
| | 77 | navigableComponentMocker.getConstructor().newInstance(); |
| | 78 | } |
| | 79 | |
| | 80 | synchronized (MainExtension.class) { |
| | 81 | new MainApplication(); |
| | 82 | JOSMFixture.initContentPane(); |
| | 83 | JOSMFixture.initMainPanel(true); |
| | 84 | JOSMFixture.initToolbar(); |
| | 85 | JOSMFixture.initMainMenu(); |
| | 86 | } |
| | 87 | } |
| | 88 | } |
| | 89 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/MockVersion.java b/test/unit/org/openstreetmap/josm/testutils/annotations/MockVersion.java
new file mode 100644
index 0000000000..12ee7530c8
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.testutils.annotations; |
| | 3 | |
| | 4 | import java.io.ByteArrayInputStream; |
| | 5 | import java.nio.charset.StandardCharsets; |
| | 6 | |
| | 7 | import org.openstreetmap.josm.data.Version; |
| | 8 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 9 | |
| | 10 | /** |
| | 11 | * This is only publicly available for {@link JOSMTestRules#assumeRevision(String)}. |
| | 12 | * This may (and probably will) become a private class in the future. |
| | 13 | */ |
| | 14 | public class MockVersion extends Version { |
| | 15 | public MockVersion(final String propertiesString) { |
| | 16 | super.initFromRevisionInfo(new ByteArrayInputStream(propertiesString.getBytes(StandardCharsets.UTF_8))); |
| | 17 | } |
| | 18 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/OsmApiType.java b/test/unit/org/openstreetmap/josm/testutils/annotations/OsmApiType.java
new file mode 100644
index 0000000000..11a5bd8b23
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.testutils.annotations; |
| | 3 | |
| | 4 | import static java.lang.annotation.ElementType.METHOD; |
| | 5 | import static java.lang.annotation.ElementType.TYPE; |
| | 6 | import static java.lang.annotation.RetentionPolicy.RUNTIME; |
| | 7 | |
| | 8 | import java.lang.annotation.Documented; |
| | 9 | import java.lang.annotation.Retention; |
| | 10 | import java.lang.annotation.Target; |
| | 11 | import java.util.Optional; |
| | 12 | |
| | 13 | import org.junit.jupiter.api.extension.AfterAllCallback; |
| | 14 | import org.junit.jupiter.api.extension.AfterEachCallback; |
| | 15 | import org.junit.jupiter.api.extension.BeforeAllCallback; |
| | 16 | import org.junit.jupiter.api.extension.BeforeEachCallback; |
| | 17 | import org.junit.jupiter.api.extension.ExtendWith; |
| | 18 | import org.junit.jupiter.api.extension.ExtensionContext; |
| | 19 | import org.openstreetmap.josm.io.OsmApi; |
| | 20 | import org.openstreetmap.josm.spi.preferences.Config; |
| | 21 | import org.openstreetmap.josm.testutils.FakeOsmApi; |
| | 22 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 23 | |
| | 24 | /** |
| | 25 | * Specify the OSM API to use for the test. {@link APIType#NONE} has no effect. |
| | 26 | * |
| | 27 | * @author Taylor Smock |
| | 28 | * @see JOSMTestRules#devAPI() |
| | 29 | * @see JOSMTestRules#fakeAPI() |
| | 30 | * @since xxx |
| | 31 | */ |
| | 32 | @Documented |
| | 33 | @Retention(RUNTIME) |
| | 34 | @Target({ TYPE, METHOD }) |
| | 35 | @FullPreferences |
| | 36 | @HTTP |
| | 37 | @ExtendWith(OsmApiType.OsmApiTypeExtension.class) |
| | 38 | public @interface OsmApiType { |
| | 39 | /** |
| | 40 | * The API type to use |
| | 41 | * @return The API type to use (default NONE) |
| | 42 | */ |
| | 43 | APIType value() default APIType.NONE; |
| | 44 | |
| | 45 | /** |
| | 46 | * API types to initialize |
| | 47 | * @author Taylor Smock |
| | 48 | * |
| | 49 | */ |
| | 50 | enum APIType { |
| | 51 | NONE, FAKE, DEV |
| | 52 | } |
| | 53 | |
| | 54 | /** |
| | 55 | * Initialize the OSM api |
| | 56 | * @author Taylor Smock |
| | 57 | * |
| | 58 | */ |
| | 59 | class OsmApiTypeExtension implements AfterAllCallback, AfterEachCallback, BeforeAllCallback, BeforeEachCallback { |
| | 60 | @Override |
| | 61 | public void afterAll(ExtensionContext context) throws Exception { |
| | 62 | afterEach(context); |
| | 63 | } |
| | 64 | |
| | 65 | @Override |
| | 66 | public void afterEach(ExtensionContext context) throws Exception { |
| | 67 | // Reset to none |
| | 68 | Config.getPref().put("osm-server.url", null); |
| | 69 | AnnotationUtils.resetStaticClass(OsmApi.class); |
| | 70 | } |
| | 71 | |
| | 72 | @Override |
| | 73 | public void beforeAll(ExtensionContext context) throws Exception { |
| | 74 | beforeEach(context); |
| | 75 | } |
| | 76 | |
| | 77 | @Override |
| | 78 | public void beforeEach(ExtensionContext context) throws Exception { |
| | 79 | Optional<OsmApiType> annotation = AnnotationUtils.findFirstParentAnnotation(context, OsmApiType.class); |
| | 80 | APIType useAPI = APIType.NONE; |
| | 81 | if (annotation.isPresent()) { |
| | 82 | useAPI = annotation.get().value(); |
| | 83 | } |
| | 84 | // Set API |
| | 85 | if (useAPI == APIType.DEV) { |
| | 86 | Config.getPref().put("osm-server.url", "https://api06.dev.openstreetmap.org/api"); |
| | 87 | } else if (useAPI == APIType.FAKE) { |
| | 88 | FakeOsmApi api = FakeOsmApi.getInstance(); |
| | 89 | Config.getPref().put("osm-server.url", api.getServerUrl()); |
| | 90 | } |
| | 91 | |
| | 92 | // Initialize API |
| | 93 | if (useAPI != APIType.NONE) { |
| | 94 | OsmApi.getOsmApi().initialize(null); |
| | 95 | } |
| | 96 | } |
| | 97 | } |
| | 98 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/Projection.java b/test/unit/org/openstreetmap/josm/testutils/annotations/Projection.java
new file mode 100644
index 0000000000..0d0ce136ae
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.testutils.annotations; |
| | 3 | |
| | 4 | import java.lang.annotation.Documented; |
| | 5 | import java.lang.annotation.ElementType; |
| | 6 | import java.lang.annotation.Retention; |
| | 7 | import java.lang.annotation.RetentionPolicy; |
| | 8 | import java.lang.annotation.Target; |
| | 9 | import java.util.Optional; |
| | 10 | |
| | 11 | import org.junit.jupiter.api.extension.AfterAllCallback; |
| | 12 | import org.junit.jupiter.api.extension.BeforeAllCallback; |
| | 13 | import org.junit.jupiter.api.extension.BeforeEachCallback; |
| | 14 | import org.junit.jupiter.api.extension.ExtendWith; |
| | 15 | import org.junit.jupiter.api.extension.ExtensionContext; |
| | 16 | import org.junit.platform.commons.support.AnnotationSupport; |
| | 17 | import org.openstreetmap.josm.data.projection.ProjectionRegistry; |
| | 18 | import org.openstreetmap.josm.data.projection.Projections; |
| | 19 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 20 | |
| | 21 | /** |
| | 22 | * Use projections in tests (Mercator). |
| | 23 | * @author Taylor Smock |
| | 24 | * @see JOSMTestRules#projection() |
| | 25 | * |
| | 26 | */ |
| | 27 | @Documented |
| | 28 | @Retention(RetentionPolicy.RUNTIME) |
| | 29 | @Target({ElementType.METHOD, ElementType.TYPE}) |
| | 30 | @ExtendWith(Projection.ProjectionExtension.class) |
| | 31 | public @interface Projection { |
| | 32 | /** |
| | 33 | * The value to use for the projection. Defaults to EPSG:3857 (Mercator). |
| | 34 | * @return The value to use to get the projection from {@link Projections#getProjectionByCode}. |
| | 35 | */ |
| | 36 | String projectionCode() default "EPSG:3857"; |
| | 37 | |
| | 38 | /** |
| | 39 | * Use projections in tests. Use {@link Projection} preferentially. |
| | 40 | * @author Taylor Smock |
| | 41 | * |
| | 42 | */ |
| | 43 | class ProjectionExtension implements BeforeEachCallback, BeforeAllCallback, AfterAllCallback { |
| | 44 | @Override |
| | 45 | public void afterAll(ExtensionContext context) throws Exception { |
| | 46 | ProjectionRegistry.clearProjectionChangeListeners(); |
| | 47 | AnnotationUtils.resetStaticClass(ProjectionRegistry.class); |
| | 48 | } |
| | 49 | |
| | 50 | @Override |
| | 51 | public void beforeAll(ExtensionContext context) throws Exception { |
| | 52 | // Needed in order to run prior to Territories |
| | 53 | beforeEach(context); |
| | 54 | } |
| | 55 | |
| | 56 | @Override |
| | 57 | public void beforeEach(ExtensionContext context) throws Exception { |
| | 58 | Optional<Projection> annotation = AnnotationSupport.findAnnotation(context.getElement(), Projection.class); |
| | 59 | if (annotation.isPresent()) { |
| | 60 | ProjectionRegistry.setProjection(Projections.getProjectionByCode(annotation.get().projectionCode())); |
| | 61 | } else { |
| | 62 | ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator |
| | 63 | } |
| | 64 | } |
| | 65 | |
| | 66 | } |
| | 67 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/Territories.java b/test/unit/org/openstreetmap/josm/testutils/annotations/Territories.java
new file mode 100644
index 0000000000..5a552bfa04
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.testutils.annotations; |
| | 3 | |
| | 4 | import java.lang.annotation.Documented; |
| | 5 | import java.lang.annotation.ElementType; |
| | 6 | import java.lang.annotation.Retention; |
| | 7 | import java.lang.annotation.RetentionPolicy; |
| | 8 | import java.lang.annotation.Target; |
| | 9 | import java.util.Optional; |
| | 10 | |
| | 11 | import org.junit.jupiter.api.extension.AfterAllCallback; |
| | 12 | import org.junit.jupiter.api.extension.BeforeAllCallback; |
| | 13 | import org.junit.jupiter.api.extension.ExtendWith; |
| | 14 | import org.junit.jupiter.api.extension.ExtensionContext; |
| | 15 | import org.junit.platform.commons.support.AnnotationSupport; |
| | 16 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 17 | |
| | 18 | /** |
| | 19 | * Use boundaries dataset in this test. |
| | 20 | * @see JOSMTestRules#territories() |
| | 21 | * @author Taylor Smock |
| | 22 | * @since xxx |
| | 23 | */ |
| | 24 | @Documented |
| | 25 | @Retention(RetentionPolicy.RUNTIME) |
| | 26 | @Target(ElementType.TYPE) |
| | 27 | @BasicPreferences // Needed for nodes |
| | 28 | @Projection // Needed for getEastNorth |
| | 29 | @ExtendWith(Territories.TerritoriesExtension.class) |
| | 30 | public @interface Territories { |
| | 31 | /** |
| | 32 | * Initialization states. Please note that the highest initialization state holds. |
| | 33 | * @author Taylor Smock |
| | 34 | */ |
| | 35 | enum Initialize { |
| | 36 | /** Don't initialize */ |
| | 37 | NONE, |
| | 38 | /** Initialize only internal data */ |
| | 39 | INTERNAL, |
| | 40 | /** Initialize internal and external data. Requires {@link HTTP}. */ |
| | 41 | ALL |
| | 42 | } |
| | 43 | |
| | 44 | /** |
| | 45 | * The way to initialize Territories |
| | 46 | * @return The value to use |
| | 47 | */ |
| | 48 | Initialize value() default Initialize.INTERNAL; |
| | 49 | |
| | 50 | /** |
| | 51 | * Initialize boundaries prior to use |
| | 52 | * @author Taylor Smock |
| | 53 | * |
| | 54 | */ |
| | 55 | class TerritoriesExtension implements BeforeAllCallback, AfterAllCallback { |
| | 56 | /** This state is only used to avoid re-initializing the Territories class */ |
| | 57 | private static Initialize state = Initialize.NONE; |
| | 58 | @Override |
| | 59 | public void afterAll(ExtensionContext context) throws Exception { |
| | 60 | synchronized (TerritoriesExtension.class) { |
| | 61 | // TODO org.openstreetmap.josm.tools.Territories.uninitialize(); |
| | 62 | } |
| | 63 | } |
| | 64 | |
| | 65 | @Override |
| | 66 | public void beforeAll(ExtensionContext context) throws Exception { |
| | 67 | Optional<Territories> annotation = AnnotationSupport.findAnnotation(context.getElement(), Territories.class); |
| | 68 | if (annotation.isPresent()) { |
| | 69 | Initialize current = annotation.get().value(); |
| | 70 | // Avoid potential race conditions if tests are parallelized |
| | 71 | synchronized (TerritoriesExtension.class) { |
| | 72 | if (current == Initialize.INTERNAL && state != Initialize.ALL && state != Initialize.INTERNAL) { |
| | 73 | org.openstreetmap.josm.tools.Territories.initializeInternalData(); |
| | 74 | state = Initialize.INTERNAL; |
| | 75 | } else if (current == Initialize.ALL && state != Initialize.ALL) { |
| | 76 | org.openstreetmap.josm.tools.Territories.initialize(); |
| | 77 | state = Initialize.ALL; |
| | 78 | } |
| | 79 | } |
| | 80 | } |
| | 81 | } |
| | 82 | } |
| | 83 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/fake_imagery/ColorSource.java b/test/unit/org/openstreetmap/josm/testutils/annotations/fake_imagery/ColorSource.java
new file mode 100644
index 0000000000..b06d502f4d
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.testutils.annotations.fake_imagery; |
| | 3 | |
| | 4 | import javax.imageio.ImageIO; |
| | 5 | import java.awt.Color; |
| | 6 | import java.awt.Graphics2D; |
| | 7 | import java.awt.image.BufferedImage; |
| | 8 | import java.io.ByteArrayOutputStream; |
| | 9 | import java.io.IOException; |
| | 10 | import java.util.Objects; |
| | 11 | |
| | 12 | import org.openstreetmap.josm.data.imagery.ImageryInfo; |
| | 13 | import org.openstreetmap.josm.testutils.annotations.FakeImagery; |
| | 14 | import org.openstreetmap.josm.tools.Logging; |
| | 15 | |
| | 16 | import com.github.tomakehurst.wiremock.client.MappingBuilder; |
| | 17 | import com.github.tomakehurst.wiremock.client.WireMock; |
| | 18 | |
| | 19 | /** |
| | 20 | * A plain color tile source |
| | 21 | * @since xxx |
| | 22 | */ |
| | 23 | public class ColorSource extends ConstSource { |
| | 24 | protected final Color color; |
| | 25 | protected final String label; |
| | 26 | protected final int tileSize; |
| | 27 | |
| | 28 | /** |
| | 29 | * Create a new ColorSource |
| | 30 | * @param colorTileSource The tile source to use |
| | 31 | */ |
| | 32 | public ColorSource(final FakeImagery.ColorTileSource colorTileSource) { |
| | 33 | this(colorTileSource.colors().getColor(), colorTileSource.name(), colorTileSource.size()); |
| | 34 | } |
| | 35 | |
| | 36 | /** |
| | 37 | * @param color Color for these tiles |
| | 38 | * @param label text label/name for this source if displayed in JOSM menus |
| | 39 | * @param tileSize Pixel dimension of tiles (usually 256) |
| | 40 | */ |
| | 41 | public ColorSource(Color color, String label, int tileSize) { |
| | 42 | this.color = color; |
| | 43 | this.label = label; |
| | 44 | this.tileSize = tileSize; |
| | 45 | } |
| | 46 | |
| | 47 | @Override |
| | 48 | public int hashCode() { |
| | 49 | return Objects.hash(this.color, this.label, this.tileSize, this.getClass()); |
| | 50 | } |
| | 51 | |
| | 52 | @Override |
| | 53 | public byte[] generatePayloadBytes() { |
| | 54 | BufferedImage image = new BufferedImage(this.tileSize, this.tileSize, BufferedImage.TYPE_INT_RGB); |
| | 55 | Graphics2D g = image.createGraphics(); |
| | 56 | g.setBackground(this.color); |
| | 57 | g.clearRect(0, 0, image.getWidth(), image.getHeight()); |
| | 58 | |
| | 59 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | 60 | try { |
| | 61 | ImageIO.write(image, "png", outputStream); |
| | 62 | } catch (IOException e) { |
| | 63 | Logging.trace(e); |
| | 64 | } |
| | 65 | return outputStream.toByteArray(); |
| | 66 | } |
| | 67 | |
| | 68 | @Override |
| | 69 | public MappingBuilder getMappingBuilder() { |
| | 70 | return WireMock.get(WireMock.urlMatching(String.format("/%h/(\\d+)/(\\d+)/(\\d+)\\.png", this.hashCode()))); |
| | 71 | } |
| | 72 | |
| | 73 | @Override |
| | 74 | public ImageryInfo getImageryInfo(int port) { |
| | 75 | return new ImageryInfo(this.label, |
| | 76 | String.format("tms[20]:http://localhost:%d/%h/{z}/{x}/{y}.png", port, this.hashCode()), "tms", |
| | 77 | (String) null, (String) null); |
| | 78 | } |
| | 79 | |
| | 80 | @Override |
| | 81 | public String getLabel() { |
| | 82 | return this.label; |
| | 83 | } |
| | 84 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/fake_imagery/ConstSource.java b/test/unit/org/openstreetmap/josm/testutils/annotations/fake_imagery/ConstSource.java
new file mode 100644
index 0000000000..cd3fa37e0c
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.testutils.annotations.fake_imagery; |
| | 3 | |
| | 4 | import org.openstreetmap.josm.data.imagery.ImageryInfo; |
| | 5 | import org.openstreetmap.josm.testutils.TileSourceRule; |
| | 6 | |
| | 7 | import com.github.tomakehurst.wiremock.WireMockServer; |
| | 8 | |
| | 9 | /** |
| | 10 | * Class defining a tile source for TileSourceRule to mock. Due to the way WireMock is designed, it is far more |
| | 11 | * straightforward to serve a single image in all tile positions |
| | 12 | * |
| | 13 | * Please note that this extends {@link TileSourceRule.ConstSource} for compatibility reasons. |
| | 14 | * {@link TileSourceRule} may be removed in the future. |
| | 15 | * @since xxx |
| | 16 | */ |
| | 17 | public abstract class ConstSource extends TileSourceRule.ConstSource { |
| | 18 | // This class should have the same body as {@link TileSourceRule.ConstSource} |
| | 19 | // For now, this class solely exists for transitioning off of JUnit 4 (the assumption is that JOSM will |
| | 20 | // eventually remove all JUnit 4 dependent classes, at which point the parent class will be deleted, and its |
| | 21 | // body moved here). |
| | 22 | |
| | 23 | /** |
| | 24 | * Get the imagery info object for the specified wiremock server (use this instead of the port-based method) |
| | 25 | * @param wireMockServer The wiremock server to use |
| | 26 | * @return The URL for the object |
| | 27 | */ |
| | 28 | public ImageryInfo getImageryInfo(final WireMockServer wireMockServer) { |
| | 29 | // When main body is moved here, mark getImageryInfo(int port) as deprecated |
| | 30 | return this.getImageryInfo(wireMockServer.port()); |
| | 31 | } |
| | 32 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java b/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java
index 77bef7ea66..a7d9c5e351 100644
|
a
|
b
|
import org.openstreetmap.josm.io.OsmApiException;
|
| 22 | 22 | import org.openstreetmap.josm.io.OsmApiInitializationException; |
| 23 | 23 | import org.openstreetmap.josm.io.auth.CredentialsManager; |
| 24 | 24 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 25 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 25 | 26 | import org.openstreetmap.josm.tools.date.DateUtils; |
| 26 | 27 | import org.openstreetmap.josm.tools.date.DateUtilsTest; |
| 27 | 28 | |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 30 | 31 | /** |
| 31 | 32 | * Unit tests of {@link ExceptionUtil} class. |
| 32 | 33 | */ |
| | 34 | @BasicPreferences |
| 33 | 35 | class ExceptionUtilTest { |
| 34 | 36 | |
| 35 | 37 | /** |
| … |
… |
class ExceptionUtilTest {
|
| 37 | 39 | */ |
| 38 | 40 | @RegisterExtension |
| 39 | 41 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 40 | | public JOSMTestRules test = new JOSMTestRules().preferences().fakeAPI(); |
| | 42 | public JOSMTestRules test = new JOSMTestRules().fakeAPI(); |
| 41 | 43 | |
| 42 | 44 | private static String baseUrl; |
| 43 | 45 | private static String serverUrl; |
-
diff --git a/test/unit/org/openstreetmap/josm/tools/GeometryTest.java b/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
index b58c6d24e2..67ef2a94cb 100644
|
a
|
b
|
import org.openstreetmap.josm.data.projection.ProjectionRegistry;
|
| 36 | 36 | import org.openstreetmap.josm.data.projection.Projections; |
| 37 | 37 | import org.openstreetmap.josm.io.OsmReader; |
| 38 | 38 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 39 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 39 | 40 | |
| 40 | 41 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 41 | 42 | |
| 42 | 43 | /** |
| 43 | 44 | * Unit tests of {@link Geometry} class. |
| 44 | 45 | */ |
| | 46 | @BasicPreferences |
| 45 | 47 | class GeometryTest { |
| 46 | 48 | /** |
| 47 | 49 | * Primitives need preferences and projection. |
| 48 | 50 | */ |
| 49 | 51 | @RegisterExtension |
| 50 | 52 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 51 | | public JOSMTestRules test = new JOSMTestRules().preferences().projection(); |
| | 53 | public JOSMTestRules test = new JOSMTestRules().projection(); |
| 52 | 54 | |
| 53 | 55 | /** |
| 54 | 56 | * Test of {@link Geometry#getLineLineIntersection} method. |
-
diff --git a/test/unit/org/openstreetmap/josm/tools/OsmPrimitiveImageProviderTest.java b/test/unit/org/openstreetmap/josm/tools/OsmPrimitiveImageProviderTest.java
index 87830b2d75..eaaae8f40f 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.OsmUtils;
|
| 19 | 19 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; |
| 20 | 20 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetsTest; |
| 21 | 21 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 22 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 22 | 23 | import org.openstreetmap.josm.tools.OsmPrimitiveImageProvider.Options; |
| 23 | 24 | |
| 24 | 25 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| … |
… |
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
| 26 | 27 | /** |
| 27 | 28 | * Unit tests of {@link OsmPrimitiveImageProvider} |
| 28 | 29 | */ |
| | 30 | @BasicPreferences |
| 29 | 31 | class OsmPrimitiveImageProviderTest { |
| 30 | 32 | |
| 31 | 33 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/tools/PlatformHookTestIT.java b/test/unit/org/openstreetmap/josm/tools/PlatformHookTestIT.java
index 7e4b5169de..8181596e02 100644
|
a
|
b
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
| 14 | 14 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 15 | 15 | |
| 16 | 16 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 17 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Integration tests of {@link PlatformHook} class. |
| 20 | 21 | */ |
| | 22 | @IntegrationTest |
| 21 | 23 | class PlatformHookTestIT { |
| 22 | 24 | |
| 23 | 25 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java b/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java
index a77f57e97d..361f5e7e23 100644
|
a
|
b
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
| 20 | 20 | import org.openstreetmap.josm.TestUtils; |
| 21 | 21 | import org.openstreetmap.josm.spi.preferences.Config; |
| 22 | 22 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 23 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 23 | 24 | |
| 24 | 25 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 25 | 26 | import mockit.Expectations; |
| … |
… |
import mockit.Mocked;
|
| 28 | 29 | /** |
| 29 | 30 | * Unit tests of {@link PlatformHookWindows} class. |
| 30 | 31 | */ |
| | 32 | @BasicPreferences |
| 31 | 33 | class PlatformHookWindowsTest { |
| 32 | 34 | |
| 33 | 35 | /** |
| … |
… |
class PlatformHookWindowsTest {
|
| 35 | 37 | */ |
| 36 | 38 | @RegisterExtension |
| 37 | 39 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 38 | | public JOSMTestRules test = new JOSMTestRules().preferences().https(); |
| | 40 | public JOSMTestRules test = new JOSMTestRules().https(); |
| 39 | 41 | |
| 40 | 42 | static PlatformHookWindows hook; |
| 41 | 43 | |
-
diff --git a/test/unit/org/openstreetmap/josm/tools/TerritoriesTestIT.java b/test/unit/org/openstreetmap/josm/tools/TerritoriesTestIT.java
index f0c25d8c7f..b88d82569a 100644
|
a
|
b
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
| 11 | 11 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 12 | 12 | |
| 13 | 13 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| | 14 | import org.openstreetmap.josm.testutils.annotations.IntegrationTest; |
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * Integration tests of {@link Territories} class. |
| 17 | 18 | */ |
| | 19 | @IntegrationTest |
| 18 | 20 | class TerritoriesTestIT { |
| 19 | 21 | |
| 20 | 22 | /** |
-
diff --git a/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java b/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
index bc3d94c3d8..c2a5ade9fb 100644
|
a
|
b
|
import org.junit.jupiter.api.Disabled;
|
| 20 | 20 | import org.junit.jupiter.api.Test; |
| 21 | 21 | import org.junit.jupiter.api.extension.RegisterExtension; |
| 22 | 22 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 23 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| | 24 | import org.openstreetmap.josm.testutils.annotations.I18n; |
| 23 | 25 | import org.openstreetmap.josm.tools.UncheckedParseException; |
| 24 | 26 | |
| 25 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 26 | 27 | import net.trajano.commons.testing.UtilityClassTestUtil; |
| 27 | 28 | |
| 28 | 29 | /** |
| 29 | 30 | * Unit tests of {@link DateUtils} class. |
| 30 | 31 | */ |
| | 32 | @I18n |
| | 33 | @BasicPreferences |
| 31 | 34 | public class DateUtilsTest { |
| 32 | | |
| 33 | | /** |
| 34 | | * Set the timezone and timeout. |
| 35 | | * <p> |
| 36 | | * Timeouts need to be disabled because we change the time zone. |
| 37 | | */ |
| | 35 | // Solely needed for setting clock to UTC. To be replaced with @TimeZoneAnnotation |
| 38 | 36 | @RegisterExtension |
| 39 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 40 | | public JOSMTestRules test = new JOSMTestRules().i18n().preferences(); |
| 41 | | |
| | 37 | JOSMTestRules josmTestRules = new JOSMTestRules(); |
| 42 | 38 | /** |
| 43 | 39 | * Tests that {@code DateUtils} satisfies utility class criteria. |
| 44 | 40 | * @throws ReflectiveOperationException if an error occurs |
-
diff --git a/test/unit/org/openstreetmap/josm/tools/date/IntervalTest.java b/test/unit/org/openstreetmap/josm/tools/date/IntervalTest.java
index fe59d460cf..4b8bbe18f1 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.tools.date; |
| 3 | 3 | |
| 4 | | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 5 | | import org.junit.jupiter.api.BeforeEach; |
| 6 | | import org.junit.jupiter.api.Test; |
| 7 | | import org.junit.jupiter.api.extension.RegisterExtension; |
| 8 | | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 4 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 9 | 5 | |
| 10 | 6 | import java.time.Instant; |
| 11 | 7 | import java.util.Locale; |
| 12 | 8 | |
| 13 | | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | 9 | import org.junit.jupiter.api.BeforeEach; |
| | 10 | import org.junit.jupiter.api.Test; |
| | 11 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
| 14 | 12 | |
| | 13 | @BasicPreferences |
| 15 | 14 | class IntervalTest { |
| 16 | | |
| 17 | | /** |
| 18 | | * Setup test. |
| 19 | | */ |
| 20 | | @RegisterExtension |
| 21 | | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 22 | | public JOSMTestRules test = new JOSMTestRules().preferences(); |
| 23 | | |
| 24 | 15 | /** |
| 25 | 16 | * Setup test. |
| 26 | 17 | */ |