Ticket #16567: 16567.initial_extensions.3.patch
| File 16567.initial_extensions.3.patch, 189.1 KB (added by , 5 years ago) |
|---|
-
src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java
47 47 rlCache = new GeoPropertyIndex<>(geoProperty, 24); 48 48 } 49 49 50 /** 51 * Uninitialize RightAndLefthandTraffic. This should <i>only</i> be used in tests, 52 * and only by the Territories extension. Calling this in production code 53 * <i>is an error</i> and will break stuff. 54 */ 55 static void uninitialize() { 56 rlCache = null; 57 } 58 50 59 static void appendLeftDrivingBoundaries(OsmPrimitive osm, Collection<Way> ways) { 51 60 // Find all outer ways of left-driving countries. Many of them are adjacent (African and Asian states) 52 61 if (LEFT.equals(osm.get(DRIVING_SIDE))) { -
src/org/openstreetmap/josm/tools/Territories.java
125 125 } 126 126 127 127 /** 128 * Uninitialize territories. This should <i>only</i> be used in tests, 129 * and only by the Territories extension. Calling this in production code 130 * <i>is an error</i> and will break stuff. 131 */ 132 public static synchronized void uninitialize() { 133 iso3166Cache = null; 134 taginfoCache = null; 135 customTagsCache = null; 136 dataSet = null; 137 taginfoGeofabrikCache = null; 138 customTagsCache = null; 139 RightAndLefthandTraffic.uninitialize(); 140 } 141 142 /** 128 143 * Initializes territories using the internal data only. 129 144 */ 130 145 public static synchronized void initializeInternalData() { -
test/functional/org/openstreetmap/josm/data/BoundariesTestIT.java
11 11 import java.util.stream.Collectors; 12 12 13 13 import org.junit.jupiter.api.Test; 14 import org.junit.jupiter.api.extension.RegisterExtension;15 14 import org.openstreetmap.josm.data.osm.DataSet; 16 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 16 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 18 17 import org.openstreetmap.josm.io.OsmReader; 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 18 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 19 import org.openstreetmap.josm.testutils.annotations.IntegrationTest; 20 20 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;22 23 21 /** 24 22 * Test of boundaries OSM file. 25 23 */ 24 @BasicPreferences 25 @IntegrationTest 26 26 class BoundariesTestIT { 27 27 28 28 private static final List<String> RETIRED_ISO3166_1_CODES = Arrays.asList( … … 47 47 "US-WY"); 48 48 49 49 /** 50 * Setup test.51 */52 @RegisterExtension53 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")54 public JOSMTestRules test = new JOSMTestRules().preferences();55 56 /**57 50 * Test of boundaries OSM file. 58 51 * @throws Exception if an error occurs 59 52 */ -
test/functional/org/openstreetmap/josm/data/osm/TaginfoTestIT.java
22 22 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException; 23 23 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 24 24 import org.openstreetmap.josm.testutils.JOSMTestRules; 25 import org.openstreetmap.josm.testutils.annotations.IntegrationTest; 25 26 import org.openstreetmap.josm.tools.HttpClient; 26 27 import org.xml.sax.SAXException; 27 28 … … 30 31 /** 31 32 * Various integration tests with Taginfo. 32 33 */ 34 @IntegrationTest 33 35 class TaginfoTestIT { 34 36 35 37 /** -
test/functional/org/openstreetmap/josm/tools/ImageProviderTest.java
24 24 25 25 import javax.swing.ImageIcon; 26 26 27 import org.junit.jupiter.api.BeforeAll;28 27 import org.junit.jupiter.api.BeforeEach; 29 28 import org.junit.jupiter.api.Test; 30 import org.junit.jupiter.api.extension.RegisterExtension;31 29 import org.junit.jupiter.params.ParameterizedTest; 32 30 import org.junit.jupiter.params.provider.ValueSource; 33 import org.openstreetmap.josm.JOSMFixture;34 31 import org.openstreetmap.josm.TestUtils; 35 32 import org.openstreetmap.josm.data.coor.LatLon; 36 33 import org.openstreetmap.josm.data.osm.Node; … … 37 34 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 38 35 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 39 36 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 40 import org.openstreetmap.josm.testutils. JOSMTestRules;37 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 41 38 import org.xml.sax.SAXException; 42 39 43 40 import com.kitfox.svg.SVGConst; … … 47 44 /** 48 45 * Unit tests of {@link ImageProvider} class. 49 46 */ 47 @BasicPreferences 50 48 class ImageProviderTest { 51 52 /**53 * Setup test.54 */55 @RegisterExtension56 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")57 public JOSMTestRules test = new JOSMTestRules();58 59 49 private static final class LogHandler14319 extends Handler { 60 50 boolean failed; 61 51 … … 75 65 } 76 66 } 77 67 78 /**79 * Setup test.80 */81 @BeforeAll82 public static void setUp() {83 JOSMFixture.createUnitTestFixture().init();84 }85 86 68 @BeforeEach 87 69 public void resetPixelDensity() { 88 70 GuiSizesHelper.setPixelDensity(1.0f); -
test/performance/org/openstreetmap/josm/data/osm/KeyValuePerformanceTest.java
16 16 import org.junit.Before; 17 17 import org.junit.jupiter.api.Test; 18 18 import org.junit.jupiter.api.Timeout; 19 import org.junit.jupiter.api.extension.RegisterExtension;20 19 import org.openstreetmap.josm.PerformanceTestUtils; 21 20 import org.openstreetmap.josm.PerformanceTestUtils.PerformanceTestTimer; 22 21 import org.openstreetmap.josm.data.osm.OsmDataGenerator.KeyValueDataGenerator; 23 import org.openstreetmap.josm.testutils. JOSMTestRules;22 import org.openstreetmap.josm.testutils.annotations.Projection; 24 23 25 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 26 25 … … 28 27 * This test measures the performance of {@link OsmPrimitive#get(String)} and related. 29 28 * @author Michael Zangl 30 29 */ 30 @Projection 31 31 @Timeout(value = 15*60, unit = TimeUnit.SECONDS) 32 32 class KeyValuePerformanceTest { 33 33 private static final int PUT_RUNS = 10000; … … 39 39 private Random random; 40 40 41 41 /** 42 * Prepare the test.43 */44 @RegisterExtension45 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")46 public JOSMTestRules test = new JOSMTestRules().projection();47 48 /**49 42 * See if there is a big difference between Strings that are interned and those that are not. 50 43 */ 51 44 @Test -
test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java
9 9 import org.junit.jupiter.api.AfterAll; 10 10 import org.junit.jupiter.api.BeforeAll; 11 11 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 12 import org.openstreetmap.josm.testutils.annotations.SlowTest; 12 13 13 14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 14 15 … … 15 16 /** 16 17 * Performance test of {@code StyledMapRenderer}. 17 18 */ 19 @SlowTest 18 20 class StyledMapRendererPerformanceTest extends AbstractMapRendererPerformanceTestParent { 19 21 20 22 @BeforeAll -
test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterTest.java
17 17 * Tests how fast {@link MapCSSStyleSource} finds the right style candidates for one object. 18 18 * @author Michael Zangl 19 19 */ 20 @Timeout(value = 15 *60, unit = TimeUnit.SECONDS)20 @Timeout(value = 15, unit = TimeUnit.MINUTES) 21 21 class MapCSSStyleSourceFilterTest { 22 22 23 23 private static final int TEST_RULE_COUNT = 10000; -
test/unit/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTaskTestParent.java
8 8 9 9 import org.junit.Rule; 10 10 import org.openstreetmap.josm.TestUtils; 11 import org.openstreetmap.josm.testutils. JOSMTestRules;11 import org.openstreetmap.josm.testutils.annotations.HTTPS; 12 12 13 13 import com.github.tomakehurst.wiremock.junit.WireMockRule; 14 14 15 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;16 17 15 /** 18 16 * Superclass of {@link DownloadGpsTaskTest}, {@link DownloadOsmTaskTest} and {@link DownloadNotesTaskTest}. 19 17 */ 18 @HTTPS 20 19 public abstract class AbstractDownloadTaskTestParent { 21 22 20 /** 23 * Setup test.24 */25 @Rule26 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")27 public JOSMTestRules test = new JOSMTestRules().https();28 29 /**30 21 * HTTP mock. 31 22 */ 32 23 @Rule -
test/unit/org/openstreetmap/josm/actions/downloadtasks/PluginDownloadTaskTest.java
11 11 import java.nio.charset.StandardCharsets; 12 12 import java.util.Collections; 13 13 14 import org.junit.Rule;15 14 import org.junit.Test; 16 15 import org.openstreetmap.josm.TestUtils; 17 16 import org.openstreetmap.josm.data.Preferences; … … 18 17 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 19 18 import org.openstreetmap.josm.plugins.PluginDownloadTask; 20 19 import org.openstreetmap.josm.plugins.PluginInformation; 21 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 import org.openstreetmap.josm.testutils.annotations.AssumeRevision; 21 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 22 import org.openstreetmap.josm.testutils.annotations.HTTPS; 22 23 import org.openstreetmap.josm.tools.Utils; 23 24 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;25 26 25 /** 27 26 * Unit tests for class {@link PluginDownloadTask}. 28 27 */ 28 @HTTPS 29 @AssumeRevision("Revision: 8000\n") 30 @FullPreferences 29 31 public class PluginDownloadTaskTest extends AbstractDownloadTaskTestParent { 30 32 protected String pluginPath; 31 33 32 /**33 * Setup test.34 */35 @Rule36 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")37 public JOSMTestRules testRule = new JOSMTestRules().https().assumeRevision(38 "Revision: 8000\n"39 ).preferences();40 41 34 @Override 42 35 protected String getRemoteContentType() { 43 36 return "application/java-archive"; -
test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java
10 10 import java.util.Collection; 11 11 12 12 import org.junit.jupiter.api.Test; 13 import org.junit.jupiter.api.extension.RegisterExtension;14 13 import org.openstreetmap.josm.command.PseudoCommand; 15 14 import org.openstreetmap.josm.command.SequenceCommand; 16 15 import org.openstreetmap.josm.data.APIDataSet; … … 19 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 19 import org.openstreetmap.josm.data.osm.Relation; 21 20 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.testutils. JOSMTestRules;21 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 23 22 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;25 26 23 /** 27 24 * Unit tests for class {@link FixDataHook}. 28 25 */ 26 @BasicPreferences 29 27 class FixDataHookTest { 30 31 28 /** 32 * Setup test.33 */34 @RegisterExtension35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")36 public JOSMTestRules test = new JOSMTestRules().main();37 38 /**39 29 * Test of {@link FixDataHook#checkUpload} method. 40 30 */ 41 31 @Test -
test/unit/org/openstreetmap/josm/actions/upload/ValidateUploadHookTest.java
3 3 4 4 import static org.junit.jupiter.api.Assertions.assertTrue; 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.APIDataSet; 9 import org.openstreetmap.josm.testutils. JOSMTestRules;9 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 10 10 11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;12 13 11 /** 14 12 * Unit tests for class {@link ValidateUploadHook}. 15 13 */ 14 @Timeout(30) 15 @OsmApiType(apiType = OsmApiType.APIType.FAKE) 16 16 class ValidateUploadHookTest { 17 18 17 /** 19 * Setup test.20 */21 @RegisterExtension22 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")23 public JOSMTestRules test = new JOSMTestRules().fakeAPI().timeout(30000);24 25 /**26 18 * Test of {@link ValidateUploadHook#checkUpload} method. 27 19 */ 28 20 @Test -
test/unit/org/openstreetmap/josm/command/AddPrimitivesCommandTest.java
12 12 import java.util.List; 13 13 14 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension;16 15 import org.openstreetmap.josm.TestUtils; 17 16 import org.openstreetmap.josm.data.coor.LatLon; 18 17 import org.openstreetmap.josm.data.osm.DataSet; … … 24 23 import org.openstreetmap.josm.data.osm.Way; 25 24 import org.openstreetmap.josm.data.osm.WayData; 26 25 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 import org.openstreetmap.josm.testutils. JOSMTestRules;26 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 28 27 29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;30 28 import nl.jqno.equalsverifier.EqualsVerifier; 31 29 import nl.jqno.equalsverifier.Warning; 32 30 … … 33 31 /** 34 32 * Unit tests of {@link AddPrimitivesCommand} class. 35 33 */ 34 @BasicPreferences // for Nodes 36 35 class AddPrimitivesCommandTest { 37 38 36 /** 39 * We need prefs for nodes.40 */41 @RegisterExtension42 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")43 public JOSMTestRules test = new JOSMTestRules().preferences().i18n();44 45 /**46 37 * Test if the add command is executed correctly and does not set the modified flag. 47 38 */ 48 39 @Test -
test/unit/org/openstreetmap/josm/command/ChangeCommandTest.java
4 4 import static org.junit.jupiter.api.Assertions.assertArrayEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertThrows; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; 8 import static org.junit.jupiter.api.Assertions.assertThrows;9 9 10 10 import java.util.ArrayList; 11 11 import java.util.Collections; … … 13 13 14 14 import org.junit.jupiter.api.BeforeEach; 15 15 import org.junit.jupiter.api.Test; 16 import org.junit.jupiter.api.extension.RegisterExtension;17 16 import org.openstreetmap.josm.TestUtils; 18 17 import org.openstreetmap.josm.command.CommandTest.CommandTestData; 19 18 import org.openstreetmap.josm.data.coor.LatLon; … … 25 24 import org.openstreetmap.josm.data.osm.User; 26 25 import org.openstreetmap.josm.data.osm.Way; 27 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 28 import org.openstreetmap.josm.testutils.JOSMTestRules; 27 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 28 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 29 29 30 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;31 30 import nl.jqno.equalsverifier.EqualsVerifier; 32 31 import nl.jqno.equalsverifier.Warning; 33 32 … … 34 33 /** 35 34 * Unit tests of {@link ChangeCommand} class. 36 35 */ 36 @LayerEnvironment 37 @BasicPreferences // Preferences are needed for Nodes 37 38 class ChangeCommandTest { 38 39 /**40 * We need prefs for nodes.41 */42 @RegisterExtension43 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")44 public JOSMTestRules test = new JOSMTestRules().preferences().i18n();45 39 private CommandTestData testData; 46 40 47 41 /** -
test/unit/org/openstreetmap/josm/command/ChangeMembersCommandTest.java
9 9 10 10 import org.junit.jupiter.api.BeforeEach; 11 11 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api.extension.RegisterExtension;13 12 import org.openstreetmap.josm.TestUtils; 14 13 import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation; 15 14 import org.openstreetmap.josm.data.osm.DataSet; … … 18 17 import org.openstreetmap.josm.data.osm.RelationMember; 19 18 import org.openstreetmap.josm.data.osm.User; 20 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 21 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 21 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 22 22 23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;24 23 import nl.jqno.equalsverifier.EqualsVerifier; 25 24 import nl.jqno.equalsverifier.Warning; 26 25 … … 27 26 /** 28 27 * Unit tests of {@link ChangeMembersCommand} class. 29 28 */ 29 @LayerEnvironment 30 @BasicPreferences // For nodes 30 31 class ChangeMembersCommandTest { 31 32 /**33 * We need prefs for nodes.34 */35 @RegisterExtension36 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")37 public JOSMTestRules test = new JOSMTestRules().preferences().i18n();38 32 private CommandTestDataWithRelation testData; 39 33 40 34 /** -
test/unit/org/openstreetmap/josm/command/ChangePropertyCommandTest.java
15 15 16 16 import org.junit.jupiter.api.BeforeEach; 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.command.CommandTest.CommandTestData; 21 20 import org.openstreetmap.josm.data.osm.DataSet; … … 26 25 import org.openstreetmap.josm.data.osm.User; 27 26 import org.openstreetmap.josm.data.osm.Way; 28 27 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 29 import org.openstreetmap.josm.testutils.JOSMTestRules; 28 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 29 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 30 30 31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;32 31 import nl.jqno.equalsverifier.EqualsVerifier; 33 32 import nl.jqno.equalsverifier.Warning; 34 33 … … 35 34 /** 36 35 * Unit tests of {@link ChangePropertyCommand} class. 37 36 */ 37 @BasicPreferences 38 @LayerEnvironment 38 39 class ChangePropertyCommandTest { 39 40 40 /**41 * We need prefs for nodes.42 */43 @RegisterExtension44 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")45 public JOSMTestRules test = new JOSMTestRules().preferences().i18n();46 41 private CommandTestData testData; 47 42 48 43 /** -
test/unit/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommandTest.java
11 11 12 12 import org.junit.jupiter.api.BeforeEach; 13 13 import org.junit.jupiter.api.Test; 14 import org.junit.jupiter.api.extension.RegisterExtension;15 14 import org.openstreetmap.josm.TestUtils; 16 15 import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation; 17 16 import org.openstreetmap.josm.data.osm.DataSet; … … 19 18 import org.openstreetmap.josm.data.osm.Relation; 20 19 import org.openstreetmap.josm.data.osm.User; 21 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 22 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 23 23 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;25 24 import nl.jqno.equalsverifier.EqualsVerifier; 26 25 import nl.jqno.equalsverifier.Warning; 27 26 … … 28 27 /** 29 28 * Unit tests of {@link ChangeRelationMemberRoleCommand} class. 30 29 */ 30 @LayerEnvironment 31 @BasicPreferences // For nodes 31 32 class ChangeRelationMemberRoleCommandTest { 32 33 /**34 * We need prefs for nodes.35 */36 @RegisterExtension37 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")38 public JOSMTestRules test = new JOSMTestRules().preferences().i18n();39 33 private CommandTestDataWithRelation testData; 40 34 41 35 /** -
test/unit/org/openstreetmap/josm/command/CommandTest.java
4 4 import java.util.Arrays; 5 5 6 6 import org.junit.jupiter.api.Test; 7 import org.junit.jupiter.api.extension.RegisterExtension;8 7 import org.openstreetmap.josm.TestUtils; 9 8 import org.openstreetmap.josm.data.coor.LatLon; 10 9 import org.openstreetmap.josm.data.osm.DataSet; … … 15 14 import org.openstreetmap.josm.data.osm.Way; 16 15 import org.openstreetmap.josm.gui.MainApplication; 17 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 import org.openstreetmap.josm.testutils. JOSMTestRules;17 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 19 18 20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;21 19 import nl.jqno.equalsverifier.EqualsVerifier; 22 20 import nl.jqno.equalsverifier.Warning; 23 21 … … 24 22 /** 25 23 * Unit tests of {@link Command} class. 26 24 */ 25 @BasicPreferences // Needed for nodes 27 26 public class CommandTest { 28 29 27 /** 30 * We need prefs for nodes / data sets.31 */32 @RegisterExtension33 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")34 public JOSMTestRules test = new JOSMTestRules().preferences().i18n();35 36 /**37 28 * Unit test of methods {@link Command#equals} and {@link Command#hashCode}. 38 29 */ 39 30 @Test -
test/unit/org/openstreetmap/josm/command/DeleteCommandTest.java
4 4 import static org.junit.jupiter.api.Assertions.assertArrayEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 import static org.junit.jupiter.api.Assertions.assertThrows; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; 8 import static org.junit.jupiter.api.Assertions.assertThrows;9 9 10 10 import java.util.ArrayList; 11 11 import java.util.Arrays; … … 15 15 16 16 import org.junit.jupiter.api.BeforeEach; 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.command.CommandTest.CommandTestDataWithRelation; 21 20 import org.openstreetmap.josm.data.osm.DataSet; … … 26 25 import org.openstreetmap.josm.data.osm.Way; 27 26 import org.openstreetmap.josm.data.osm.WaySegment; 28 27 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 29 import org.openstreetmap.josm.testutils.JOSMTestRules; 28 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 29 import org.openstreetmap.josm.testutils.annotations.DeleteCommandCallback; 30 30 31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;32 31 import nl.jqno.equalsverifier.EqualsVerifier; 33 32 import nl.jqno.equalsverifier.Warning; 34 33 … … 35 34 /** 36 35 * Unit tests of {@link DeleteCommand} class. 37 36 */ 37 @BasicPreferences 38 @DeleteCommandCallback 38 39 class DeleteCommandTest { 39 40 /**41 * We need prefs for nodes.42 */43 @RegisterExtension44 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")45 public JOSMTestRules test = new JOSMTestRules().preferences().i18n();46 40 private CommandTestDataWithRelation testData; 47 41 48 42 /** -
test/unit/org/openstreetmap/josm/command/MoveCommandTest.java
13 13 14 14 import org.junit.jupiter.api.BeforeEach; 15 15 import org.junit.jupiter.api.Test; 16 import org.junit.jupiter.api.extension.RegisterExtension;17 16 import org.openstreetmap.josm.TestUtils; 18 17 import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation; 19 18 import org.openstreetmap.josm.data.coor.EastNorth; … … 24 23 import org.openstreetmap.josm.data.osm.User; 25 24 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 26 25 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 import org.openstreetmap.josm.testutils.JOSMTestRules; 26 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 27 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 28 import org.openstreetmap.josm.testutils.annotations.Projection; 28 29 29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;30 30 import nl.jqno.equalsverifier.EqualsVerifier; 31 31 import nl.jqno.equalsverifier.Warning; 32 32 … … 33 33 /** 34 34 * Unit tests of {@link MoveCommand} class. 35 35 */ 36 @Projection 37 @BasicPreferences // Needed for nodes 38 @LayerEnvironment 36 39 class MoveCommandTest { 37 /**38 * We need prefs for nodes.39 */40 @RegisterExtension41 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")42 public JOSMTestRules test = new JOSMTestRules().preferences().i18n().projection();43 40 private CommandTestDataWithRelation testData; 44 41 45 42 /** -
test/unit/org/openstreetmap/josm/command/PurgeCommandTest.java
14 14 15 15 import org.junit.jupiter.api.BeforeEach; 16 16 import org.junit.jupiter.api.Test; 17 import org.junit.jupiter.api.extension.RegisterExtension;18 17 import org.openstreetmap.josm.TestUtils; 19 18 import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation; 20 19 import org.openstreetmap.josm.data.conflict.Conflict; … … 27 26 import org.openstreetmap.josm.data.osm.Storage; 28 27 import org.openstreetmap.josm.data.osm.User; 29 28 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 30 import org.openstreetmap.josm.testutils.JOSMTestRules; 29 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 30 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 31 31 32 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;33 32 import nl.jqno.equalsverifier.EqualsVerifier; 34 33 import nl.jqno.equalsverifier.Warning; 35 34 … … 36 35 /** 37 36 * Unit tests of {@link PurgeCommand} class. 38 37 */ 38 @BasicPreferences // For nodes 39 @LayerEnvironment 39 40 class PurgeCommandTest { 40 /**41 * We need prefs for nodes.42 */43 @RegisterExtension44 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")45 public JOSMTestRules test = new JOSMTestRules().preferences();46 41 private CommandTestDataWithRelation testData; 47 42 48 43 /** -
test/unit/org/openstreetmap/josm/command/RotateCommandTest.java
9 9 10 10 import org.junit.jupiter.api.BeforeEach; 11 11 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api.extension.RegisterExtension;13 12 import org.openstreetmap.josm.TestUtils; 14 13 import org.openstreetmap.josm.command.CommandTest.CommandTestData; 15 14 import org.openstreetmap.josm.data.coor.EastNorth; … … 19 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 19 import org.openstreetmap.josm.data.osm.User; 21 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 22 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 23 import org.openstreetmap.josm.testutils.annotations.Projection; 23 24 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;25 25 import nl.jqno.equalsverifier.EqualsVerifier; 26 26 import nl.jqno.equalsverifier.Warning; 27 27 … … 28 28 /** 29 29 * Unit tests of {@link RotateCommand} class. 30 30 */ 31 @Projection 32 @BasicPreferences 33 @LayerEnvironment 31 34 class RotateCommandTest { 32 33 /**34 * We need prefs for nodes.35 */36 @RegisterExtension37 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")38 public JOSMTestRules test = new JOSMTestRules().preferences().projection();39 35 private CommandTestData testData; 40 36 41 37 /** -
test/unit/org/openstreetmap/josm/command/SelectCommandTest.java
3 3 4 4 import static org.junit.jupiter.api.Assertions.assertArrayEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.junit.jupiter.api.Assertions.assertThrows;8 8 9 9 import java.util.ArrayList; 10 10 import java.util.Arrays; … … 12 12 13 13 import org.junit.jupiter.api.BeforeEach; 14 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension;16 15 import org.openstreetmap.josm.TestUtils; 17 16 import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation; 18 17 import org.openstreetmap.josm.data.osm.DataSet; … … 19 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 19 import org.openstreetmap.josm.data.osm.User; 21 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 22 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 23 23 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;25 24 import nl.jqno.equalsverifier.EqualsVerifier; 26 25 import nl.jqno.equalsverifier.Warning; 27 26 … … 28 27 /** 29 28 * Unit tests of {@link SelectCommand} class. 30 29 */ 30 @LayerEnvironment 31 @BasicPreferences // Needed for nodes 31 32 class SelectCommandTest { 32 33 /**34 * We need prefs for nodes.35 */36 @RegisterExtension37 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")38 public JOSMTestRules test = new JOSMTestRules().preferences();39 33 private CommandTestDataWithRelation testData; 40 34 41 35 /** -
test/unit/org/openstreetmap/josm/command/SequenceCommandTest.java
20 20 21 21 import org.junit.jupiter.api.BeforeEach; 22 22 import org.junit.jupiter.api.Test; 23 import org.junit.jupiter.api.extension.RegisterExtension;24 23 import org.openstreetmap.josm.TestUtils; 25 24 import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation; 26 25 import org.openstreetmap.josm.data.osm.DataSet; … … 28 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; 29 28 import org.openstreetmap.josm.data.osm.User; 30 29 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 31 import org.openstreetmap.josm.testutils.JOSMTestRules; 30 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 31 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 32 32 import org.openstreetmap.josm.tools.bugreport.ReportedException; 33 33 34 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;35 34 import nl.jqno.equalsverifier.EqualsVerifier; 36 35 import nl.jqno.equalsverifier.Warning; 37 36 … … 38 37 /** 39 38 * Unit tests of {@link SequenceCommand} class. 40 39 */ 40 @LayerEnvironment 41 @BasicPreferences // For nodes 41 42 class SequenceCommandTest { 42 43 /**44 * We need prefs for nodes.45 */46 @RegisterExtension47 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")48 public JOSMTestRules test = new JOSMTestRules().preferences();49 43 private CommandTestDataWithRelation testData; 50 44 51 45 /** -
test/unit/org/openstreetmap/josm/command/conflict/CoordinateConflictResolveCommandTest.java
7 7 8 8 import org.junit.jupiter.api.BeforeEach; 9 9 import org.junit.jupiter.api.Test; 10 import org.junit.jupiter.api.extension.RegisterExtension;11 10 import org.openstreetmap.josm.TestUtils; 12 11 import org.openstreetmap.josm.command.CommandTest.CommandTestData; 13 12 import org.openstreetmap.josm.data.conflict.Conflict; … … 18 17 import org.openstreetmap.josm.data.osm.Way; 19 18 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType; 20 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 21 import org.openstreetmap.josm.testutils. JOSMTestRules;20 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 22 21 23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;24 22 import nl.jqno.equalsverifier.EqualsVerifier; 25 23 import nl.jqno.equalsverifier.Warning; 26 24 … … 27 25 /** 28 26 * Unit tests of {@link CoordinateConflictResolveCommand} class. 29 27 */ 28 @BasicPreferences 30 29 class CoordinateConflictResolveCommandTest { 31 30 32 31 private CommandTestData testData; 33 34 32 /** 35 33 * Setup test. 36 34 */ 37 @RegisterExtension38 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")39 public JOSMTestRules test = new JOSMTestRules();40 41 /**42 * Setup test.43 */44 35 @BeforeEach 45 36 public void setUp() { 46 37 testData = new CommandTestData(); -
test/unit/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommandTest.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.command.conflict; 3 3 4 import org.junit.jupiter.api.extension.RegisterExtension;5 4 import org.junit.jupiter.api.Test; 6 5 import org.openstreetmap.josm.TestUtils; 7 6 import org.openstreetmap.josm.data.conflict.Conflict; … … 10 9 import org.openstreetmap.josm.data.osm.Relation; 11 10 import org.openstreetmap.josm.data.osm.User; 12 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 13 import org.openstreetmap.josm.testutils. JOSMTestRules;12 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 14 13 15 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;16 14 import nl.jqno.equalsverifier.EqualsVerifier; 17 15 import nl.jqno.equalsverifier.Warning; 18 16 … … 19 17 /** 20 18 * Unit tests of {@link RelationMemberConflictResolverCommand} class. 21 19 */ 20 @BasicPreferences // Needed for OsmPrimitive 22 21 class RelationMemberConflictResolverCommandTest { 23 24 22 /** 25 * Setup test.26 */27 @RegisterExtension28 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")29 public JOSMTestRules test = new JOSMTestRules();30 31 /**32 23 * Unit test of methods {@link RelationMemberConflictResolverCommand#equals} and {@link RelationMemberConflictResolverCommand#hashCode}. 33 24 */ 34 25 @Test -
test/unit/org/openstreetmap/josm/command/conflict/VersionConflictResolveCommandTest.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.command.conflict; 3 3 4 import org.junit.jupiter.api.Test; 4 5 import org.junit.jupiter.api.extension.RegisterExtension; 5 import org.junit.jupiter.api.Test;6 6 import org.openstreetmap.josm.TestUtils; 7 7 import org.openstreetmap.josm.data.conflict.Conflict; 8 8 import org.openstreetmap.josm.data.osm.DataSet; -
test/unit/org/openstreetmap/josm/data/UserIdentityManagerTest.java
6 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 7 import static org.junit.jupiter.api.Assertions.assertNull; 8 8 import static org.junit.jupiter.api.Assertions.assertSame; 9 import static org.junit.jupiter.api.Assertions.assertThrows; 9 10 import static org.junit.jupiter.api.Assertions.assertTrue; 10 import static org.junit.jupiter.api.Assertions.assertThrows;11 11 12 12 import org.junit.jupiter.api.Test; 13 13 import org.junit.jupiter.api.extension.RegisterExtension; -
test/unit/org/openstreetmap/josm/data/cache/HostLimitQueueTest.java
12 12 13 13 import org.apache.commons.jcs3.access.behavior.ICacheAccess; 14 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api. extension.RegisterExtension;15 import org.junit.jupiter.api.Timeout; 16 16 import org.openstreetmap.josm.data.imagery.TMSCachedTileLoader; 17 17 import org.openstreetmap.josm.data.imagery.TileJobOptions; 18 import org.openstreetmap.josm.testutils. JOSMTestRules;18 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 19 19 import org.openstreetmap.josm.tools.Logging; 20 20 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;22 23 21 /** 24 22 * Simple tests for ThreadPoolExecutor / HostLimitQueue veryfing, that this pair works OK 25 23 * @author Wiktor Niesiobedzki 26 24 */ 25 @FullPreferences 26 @Timeout(20) 27 27 class HostLimitQueueTest { 28 28 /** 29 * Setup test.30 */31 @RegisterExtension32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")33 public JOSMTestRules test = new JOSMTestRules().preferences().timeout(20 * 1000);34 35 /**36 29 * Mock class for tests 37 30 */ 38 31 static class Task extends JCSCachedTileLoaderJob<String, CacheEntry> { -
test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java
10 10 import java.util.List; 11 11 12 12 import org.junit.jupiter.api.Test; 13 import org.junit.jupiter.api.extension.RegisterExtension;14 13 import org.openstreetmap.josm.TestUtils; 15 14 import org.openstreetmap.josm.data.Bounds; 16 import org.openstreetmap.josm.testutils. JOSMTestRules;15 import org.openstreetmap.josm.testutils.annotations.Projection; 17 16 18 17 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 19 18 import nl.jqno.equalsverifier.EqualsVerifier; … … 21 20 /** 22 21 * Unit tests for class {@link LatLon}. 23 22 */ 23 @Projection 24 24 public class LatLonTest { 25 26 /**27 * Setup test.28 */29 @RegisterExtension30 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")31 public JOSMTestRules test = new JOSMTestRules().projection();32 33 25 private static final double EPSILON = 1e-6; 34 26 35 27 /** -
test/unit/org/openstreetmap/josm/data/coor/PolarCoorTest.java
6 6 7 7 import java.text.DecimalFormat; 8 8 9 import org.junit.jupiter.api.extension.RegisterExtension;10 9 import org.junit.jupiter.api.Test; 11 10 import org.openstreetmap.josm.TestUtils; 12 import org.openstreetmap.josm.testutils. JOSMTestRules;11 import org.openstreetmap.josm.testutils.annotations.Projection; 13 12 14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;15 13 import nl.jqno.equalsverifier.EqualsVerifier; 16 14 17 15 /** 18 16 * Test the {@link PolarCoor} class. 19 17 */ 18 @Projection 20 19 class PolarCoorTest { 21 22 20 /** 23 * Setup test.24 */25 @RegisterExtension26 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")27 public JOSMTestRules test = new JOSMTestRules().projection();28 29 /**30 21 * Test {@link PolarCoor#PolarCoor} 31 22 */ 32 23 @Test -
test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java
20 20 21 21 import org.junit.jupiter.api.BeforeEach; 22 22 import org.junit.jupiter.api.Test; 23 import org.junit.jupiter.api.extension.RegisterExtension;24 23 import org.openstreetmap.josm.TestUtils; 25 24 import org.openstreetmap.josm.data.Bounds; 26 25 import org.openstreetmap.josm.data.DataSource; … … 30 29 import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeListener; 31 30 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 32 31 import org.openstreetmap.josm.io.GpxReaderTest; 33 import org.openstreetmap.josm.testutils.JOSMTestRules; 32 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 33 import org.openstreetmap.josm.testutils.annotations.Projection; 34 34 import org.openstreetmap.josm.tools.ListenerList; 35 35 import org.xml.sax.SAXException; 36 36 37 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;38 37 import nl.jqno.equalsverifier.EqualsVerifier; 39 38 import nl.jqno.equalsverifier.Warning; 40 39 … … 41 40 /** 42 41 * Unit tests for class {@link GpxData}. 43 42 */ 43 @BasicPreferences 44 @Projection 44 45 class GpxDataTest { 45 46 /**47 * Setup test.48 */49 @RegisterExtension50 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")51 public JOSMTestRules test = new JOSMTestRules().projection();52 53 46 private GpxData data; 54 47 55 48 /** -
test/unit/org/openstreetmap/josm/data/oauth/SignpostAdaptersTest.java
11 11 import java.net.URL; 12 12 13 13 import org.junit.jupiter.api.Test; 14 import org.junit.jupiter.api.extension.RegisterExtension;15 14 import org.openstreetmap.josm.data.oauth.SignpostAdapters.HttpRequest; 16 15 import org.openstreetmap.josm.data.oauth.SignpostAdapters.HttpResponse; 17 16 import org.openstreetmap.josm.data.oauth.SignpostAdapters.OAuthConsumer; 18 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 import org.openstreetmap.josm.testutils.annotations.HTTP; 18 import org.openstreetmap.josm.testutils.annotations.HTTPS; 19 19 import org.openstreetmap.josm.tools.HttpClient; 20 20 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;22 21 import net.trajano.commons.testing.UtilityClassTestUtil; 23 22 24 23 /** 25 24 * Unit tests for class {@link SignpostAdapters}. 26 25 */ 26 @HTTP 27 @HTTPS 27 28 class SignpostAdaptersTest { 28 29 /**30 * Setup test.31 */32 @RegisterExtension33 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")34 public JOSMTestRules test = new JOSMTestRules().https();35 36 29 private static HttpClient newClient() throws MalformedURLException { 37 30 return HttpClient.create(new URL("https://www.openstreetmap.org")); 38 31 } -
test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
18 18 import org.junit.jupiter.api.AfterEach; 19 19 import org.junit.jupiter.api.BeforeEach; 20 20 import org.junit.jupiter.api.Test; 21 import org.junit.jupiter.api.extension.RegisterExtension;22 21 import org.openstreetmap.josm.data.coor.LatLon; 23 import org.openstreetmap.josm.data.projection.ProjectionRegistry;24 import org.openstreetmap.josm.data.projection.Projections;25 22 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 26 import org.openstreetmap.josm.testutils.JOSMTestRules; 23 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 24 import org.openstreetmap.josm.testutils.annotations.Projection; 27 25 import org.openstreetmap.josm.tools.date.DateUtils; 28 26 29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;30 31 27 /** 32 28 * Unit tests for class {@link DataSetMerger}. 33 29 */ 30 @BasicPreferences // Needed for OsmPrimitive 31 @Projection 34 32 class DataSetMergerTest { 35 33 36 /**37 * Setup test.38 */39 @RegisterExtension40 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")41 public JOSMTestRules test = new JOSMTestRules();42 43 34 private DataSet my; 44 35 private DataSet their; 45 36 … … 52 43 my.setVersion("0.6"); 53 44 their = new DataSet(); 54 45 their.setVersion("0.6"); 55 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator56 46 } 57 47 58 48 private void runConsistencyTests(DataSet ds) { -
test/unit/org/openstreetmap/josm/data/osm/DataSetTest.java
12 12 13 13 import org.junit.Assert; 14 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension;16 15 import org.openstreetmap.josm.TestUtils; 17 16 import org.openstreetmap.josm.data.Bounds; 18 17 import org.openstreetmap.josm.data.DataSource; … … 19 18 import org.openstreetmap.josm.data.coor.LatLon; 20 19 import org.openstreetmap.josm.data.osm.event.DataSourceAddedEvent; 21 20 import org.openstreetmap.josm.data.osm.event.DataSourceRemovedEvent; 22 import org.openstreetmap.josm.testutils. JOSMTestRules;21 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 23 22 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;25 26 23 /** 27 24 * Unit tests for class {@link DataSet}. 28 25 */ 26 @BasicPreferences // Needed for OsmPrimitive 29 27 class DataSetTest { 30 31 28 /** 32 * Setup test.33 */34 @RegisterExtension35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")36 public JOSMTestRules test = new JOSMTestRules();37 38 /**39 29 * Unit test of method {@link DataSet#searchRelations}. 40 30 */ 41 31 @Test -
test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandlingTest.java
5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 7 8 import org.junit.jupiter.api.extension.RegisterExtension;9 8 import org.junit.jupiter.api.Test; 10 9 import org.openstreetmap.josm.data.coor.LatLon; 11 import org.openstreetmap.josm.testutils. JOSMTestRules;10 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 12 11 13 12 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 14 13 … … 16 15 * Some unit test cases for basic tag management on {@link OsmPrimitive}. Uses 17 16 * {@link Node} for the tests, {@link OsmPrimitive} is abstract. 18 17 */ 18 @BasicPreferences // Needed for OsmPrimitive 19 19 class OsmPrimitiveKeyHandlingTest { 20 21 20 /** 22 * Setup test.23 */24 @RegisterExtension25 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")26 public JOSMTestRules test = new JOSMTestRules();27 28 /**29 21 * test query and get methods on a node withouth keys 30 22 */ 31 23 @Test -
test/unit/org/openstreetmap/josm/data/osm/TagCollectionTest.java
17 17 import java.util.stream.Stream; 18 18 19 19 import org.junit.jupiter.api.Test; 20 import org.junit.jupiter.api.extension.RegisterExtension; 21 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 22 21 23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;24 25 22 /** 26 23 * Tests of {@link TagCollection}. 27 24 * @author Michael Zangl 28 25 */ 26 @FullPreferences // primitives require prefs 29 27 class TagCollectionTest { 30 28 private final Tag tagA = new Tag("k", "v"); 31 29 private final Tag tagB = new Tag("k", "b"); … … 35 33 private final Tag tagNullKey = new Tag(null, "b"); 36 34 private final Tag tagNullValue = new Tag("k2", null); 37 35 38 /**39 * We need prefs for using primitives40 */41 @RegisterExtension42 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")43 public JOSMTestRules test = new JOSMTestRules().preferences();44 45 36 private void assertTagCounts(TagCollection collection, int a, int b, int c, int d) { 46 37 assertEquals(a, collection.getTagOccurrence(tagA)); 47 38 assertEquals(b, collection.getTagOccurrence(tagB)); -
test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java
19 19 20 20 import org.junit.Assert; 21 21 import org.junit.jupiter.api.Test; 22 import org.junit.jupiter.api. extension.RegisterExtension;22 import org.junit.jupiter.api.Timeout; 23 23 import org.openstreetmap.josm.TestUtils; 24 24 import org.openstreetmap.josm.data.coor.LatLon; 25 25 import org.openstreetmap.josm.data.osm.DataSet; … … 41 41 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 42 42 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 43 43 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 44 import org.openstreetmap.josm.testutils. JOSMTestRules;44 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 45 45 import org.openstreetmap.josm.tools.Logging; 46 46 import org.openstreetmap.josm.tools.date.DateUtils; 47 47 48 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;49 48 import nl.jqno.equalsverifier.EqualsVerifier; 50 49 import nl.jqno.equalsverifier.Warning; 51 50 … … 52 51 /** 53 52 * Unit tests for class {@link SearchCompiler}. 54 53 */ 54 @BasicPreferences // For OSM Primitives 55 @Timeout(30) 55 56 class SearchCompilerTest { 56 57 /**58 * We need prefs for this. We access preferences when creating OSM primitives.59 */60 @RegisterExtension61 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")62 public JOSMTestRules test = new JOSMTestRules().preferences().timeout(30000);63 64 57 private static final class SearchContext { 65 58 final DataSet ds = new DataSet(); 66 59 final Node n1 = new Node(LatLon.ZERO); -
test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java
8 8 9 9 import java.util.Collection; 10 10 11 import org.junit.jupiter.api.extension.RegisterExtension;12 11 import org.junit.jupiter.api.Test; 13 12 import org.openstreetmap.josm.data.coor.LatLon; 14 13 import org.openstreetmap.josm.data.osm.DataSet; … … 18 17 import org.openstreetmap.josm.data.osm.Relation; 19 18 import org.openstreetmap.josm.data.osm.RelationMember; 20 19 import org.openstreetmap.josm.data.osm.Way; 21 import org.openstreetmap.josm.testutils. JOSMTestRules;20 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 22 21 23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;24 25 22 /** 26 23 * Unit tests for class {@link MergeSourceBuildingVisitor}. 27 24 */ 25 @BasicPreferences // Due to OSM primitives 28 26 class MergeSourceBuildingVisitorTest { 29 27 30 28 protected OsmPrimitive lookupByName(Collection<? extends OsmPrimitive> primitives, String name) { … … 35 33 .findFirst().orElse(null); 36 34 } 37 35 38 /**39 * Setup test.40 */41 @RegisterExtension42 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")43 public JOSMTestRules test = new JOSMTestRules();44 45 36 @Test 46 37 void testNodes() { 47 38 DataSet source = new DataSet(); -
test/unit/org/openstreetmap/josm/data/preferences/JosmUrlsTest.java
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; 8 7 import org.openstreetmap.josm.spi.preferences.Config; 9 import org.openstreetmap.josm.testutils. JOSMTestRules;8 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 10 9 11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;12 13 10 /** 14 11 * Unit tests of {@link JosmUrls} class. 15 12 */ 13 @OsmApiType(apiType = OsmApiType.APIType.DEV) 16 14 class JosmUrlsTest { 17 18 15 /** 19 * Setup test.20 */21 @RegisterExtension22 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")23 public JOSMTestRules test = new JOSMTestRules().devAPI();24 25 /**26 16 * Unit test of {@link JosmUrls#getBaseUserUrl}. 27 17 */ 28 18 @Test -
test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java
31 31 import java.util.regex.Matcher; 32 32 import java.util.regex.Pattern; 33 33 34 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;35 34 import org.junit.Assert; 36 import org.junit.jupiter.api.extension.RegisterExtension;37 35 import org.junit.jupiter.api.Test; 36 import org.junit.jupiter.api.Timeout; 38 37 import org.openstreetmap.josm.data.Bounds; 39 38 import org.openstreetmap.josm.data.coor.EastNorth; 40 39 import org.openstreetmap.josm.data.coor.LatLon; 41 40 import org.openstreetmap.josm.gui.preferences.projection.CodeProjectionChoice; 42 import org.openstreetmap.josm.testutils.JOSMTestRules; 41 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 42 import org.openstreetmap.josm.testutils.annotations.HTTP; 43 import org.openstreetmap.josm.testutils.annotations.ProjectionNadGrids; 43 44 import org.openstreetmap.josm.tools.Pair; 44 45 import org.openstreetmap.josm.tools.PlatformManager; 45 46 47 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 48 46 49 /** 47 50 * Test projections using reference data from external program. 48 51 * … … 58 61 * This means the test does not verify our definitions, but the correctness 59 62 * of the algorithm, given a certain definition. 60 63 */ 64 @Timeout(90) 65 @ProjectionNadGrids 66 @BasicPreferences 67 @HTTP 61 68 class ProjectionRefTest { 62 69 63 70 private static final String CS2CS_EXE = "cs2cs"; … … 83 90 static List<String> forcedCodes; 84 91 85 92 /** 86 * Setup test.87 */88 @RegisterExtension89 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")90 public JOSMTestRules test = new JOSMTestRules().projectionNadGrids().timeout(90_000);91 92 /**93 93 * Program entry point. 94 94 * @param args optional comma-separated list of projections to update. If set, only these projections will be updated 95 95 * @throws IOException in case of I/O error -
test/unit/org/openstreetmap/josm/data/projection/proj/LonLatTest.java
3 3 4 4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 5 6 import org.junit.jupiter.api.extension.RegisterExtension;7 6 import org.junit.jupiter.api.Test; 8 import org.openstreetmap.josm.testutils.JOSMTestRules;9 7 10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;11 12 8 /** 13 9 * Tests for {@link LonLat}. 14 10 */ 15 11 class LonLatTest { 16 12 /** 17 * Setup rule.18 */19 @RegisterExtension20 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")21 public JOSMTestRules test = new JOSMTestRules();22 23 /**24 13 * Test {@link LonLat#lonIsLinearToEast} 25 14 */ 26 15 @Test -
test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java
46 46 import java.util.regex.Matcher; 47 47 import java.util.regex.Pattern; 48 48 49 import org.junit.jupiter.api.extension.RegisterExtension;50 49 import org.junit.jupiter.api.Test; 51 import org.openstreetmap.josm.testutils. JOSMTestRules;50 import org.openstreetmap.josm.testutils.annotations.HTTPS; 52 51 import org.openstreetmap.josm.tools.Logging; 53 52 54 53 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 58 57 * 59 58 * @version $Revision: 1723861 $ 60 59 */ 60 @HTTPS 61 61 class DomainValidatorTestIT { 62 63 62 /** 64 * Setup rule65 */66 @RegisterExtension67 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")68 public JOSMTestRules test = new JOSMTestRules().https();69 70 /**71 63 * Download and process local copy of http://data.iana.org/TLD/tlds-alpha-by-domain.txt 72 64 * Check if the internal TLD table is up to date 73 65 * Check if the internal TLD tables have any spurious entries -
test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
17 17 18 18 import org.junit.jupiter.api.BeforeEach; 19 19 import org.junit.jupiter.api.Test; 20 import org.junit.jupiter.api.extension.RegisterExtension;21 20 import org.openstreetmap.josm.TestUtils; 22 21 import org.openstreetmap.josm.command.ChangePropertyCommand; 23 22 import org.openstreetmap.josm.command.ChangePropertyKeyCommand; … … 42 41 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 43 42 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException; 44 43 import org.openstreetmap.josm.io.OsmReader; 45 import org.openstreetmap.josm.testutils.JOSMTestRules; 44 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 45 import org.openstreetmap.josm.testutils.annotations.Territories; 46 46 import org.openstreetmap.josm.tools.Logging; 47 47 48 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;49 50 48 /** 51 49 * JUnit Test of {@link MapCSSTagChecker}. 52 50 */ 51 @BasicPreferences 52 @Territories 53 53 class MapCSSTagCheckerTest { 54 55 54 /** 56 55 * Setup test. 57 56 */ 58 @RegisterExtension59 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")60 public JOSMTestRules test = new JOSMTestRules().projection().territories().preferences();61 62 /**63 * Setup test.64 */65 57 @BeforeEach 66 58 public void setUp() { 67 59 MapCSSTagCheckerAsserts.clear(); -
test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
13 13 import org.junit.Assert; 14 14 import org.junit.jupiter.api.Disabled; 15 15 import org.junit.jupiter.api.Test; 16 import org.junit.jupiter.api.extension.RegisterExtension;17 16 import org.openstreetmap.josm.TestUtils; 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.Tag; 21 20 import org.openstreetmap.josm.data.validation.Severity; 22 21 import org.openstreetmap.josm.data.validation.TestError; 23 import org.openstreetmap.josm.testutils.JOSMTestRules; 22 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 23 import org.openstreetmap.josm.testutils.annotations.Presets; 24 24 25 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;26 27 25 /** 28 26 * JUnit Test of {@link TagChecker}. 29 27 */ 28 @BasicPreferences 29 @Presets 30 30 class TagCheckerTest { 31 32 /**33 * Setup test.34 */35 @RegisterExtension36 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")37 public JOSMTestRules rule = new JOSMTestRules().presets();38 39 31 List<TestError> test(OsmPrimitive primitive) throws IOException { 40 32 final TagChecker checker = new TagChecker() { 41 33 @Override -
test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui; 3 3 4 import static org.junit.Assume.assumeFalse; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertFalse; 6 7 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 8 import static org.junit.jupiter.api.Assertions.assertNull; 8 9 import static org.junit.jupiter.api.Assertions.assertTrue; 9 import static org.junit.Assume.assumeFalse;10 10 11 11 import java.awt.BorderLayout; 12 12 import java.awt.event.KeyEvent; … … 27 27 import javax.swing.UIManager; 28 28 29 29 import org.junit.jupiter.api.Test; 30 import org.junit.jupiter.api. extension.RegisterExtension;30 import org.junit.jupiter.api.Timeout; 31 31 import org.openstreetmap.josm.TestUtils; 32 32 import org.openstreetmap.josm.actions.JosmAction; 33 33 import org.openstreetmap.josm.actions.OpenLocationAction; … … 42 42 import org.openstreetmap.josm.plugins.PluginListParseException; 43 43 import org.openstreetmap.josm.plugins.PluginListParser; 44 44 import org.openstreetmap.josm.spi.preferences.Config; 45 import org.openstreetmap.josm.testutils.JOSMTestRules; 45 import org.openstreetmap.josm.testutils.annotations.HTTPS; 46 import org.openstreetmap.josm.testutils.annotations.Main; 47 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 48 import org.openstreetmap.josm.testutils.annotations.Projection; 46 49 import org.openstreetmap.josm.tools.Logging; 47 50 import org.openstreetmap.josm.tools.PlatformManager; 48 51 import org.openstreetmap.josm.tools.Shortcut; … … 52 55 /** 53 56 * Unit tests of {@link MainApplication} class. 54 57 */ 58 @Main 59 @Projection 60 @HTTPS 61 @OsmApiType(apiType = OsmApiType.APIType.DEV) 62 @Timeout(20) 55 63 public class MainApplicationTest { 56 57 64 /** 58 * Setup test.59 */60 @RegisterExtension61 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")62 public JOSMTestRules test = new JOSMTestRules().main().projection().https().devAPI().timeout(20000);63 64 /**65 65 * Make sure {@link MainApplication#contentPanePrivate} is initialized. 66 66 */ 67 67 public static void initContentPane() { -
test/unit/org/openstreetmap/josm/gui/bbox/SizeButtonTest.java
5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 7 8 import org.junit.jupiter.api.extension.RegisterExtension;9 8 import org.junit.jupiter.api.Test; 10 9 import org.openstreetmap.josm.TestUtils; 11 10 import org.openstreetmap.josm.gui.bbox.SizeButton.AccessibleSizeButton; 12 import org.openstreetmap.josm.testutils. JOSMTestRules;11 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 13 12 14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;15 16 13 /** 17 14 * Unit tests of {@link SizeButton} class. 18 15 */ 16 @BasicPreferences 19 17 class SizeButtonTest { 20 18 21 /**22 * Setup tests23 */24 @RegisterExtension25 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")26 public JOSMTestRules test = new JOSMTestRules().preferences();27 19 28 20 /** 29 21 * Unit test of {@link SizeButton#SizeButton}. -
test/unit/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModelTest.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.conflict.pair.nodes; 3 3 4 import static org.junit.jupiter.api.Assertions.fail;5 4 import static org.junit.jupiter.api.Assertions.assertEquals; 6 5 import static org.junit.jupiter.api.Assertions.assertFalse; 7 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.junit.jupiter.api.Assertions.fail; 8 8 9 9 import java.beans.PropertyChangeEvent; 10 10 import java.beans.PropertyChangeListener; … … 19 19 import javax.swing.DefaultListSelectionModel; 20 20 21 21 import org.junit.jupiter.api.Test; 22 import org.junit.jupiter.api.extension.RegisterExtension;23 22 import org.openstreetmap.josm.TestUtils; 24 23 import org.openstreetmap.josm.data.osm.Node; 25 24 import org.openstreetmap.josm.data.osm.Way; 26 25 import org.openstreetmap.josm.gui.conflict.pair.AbstractListMergeModel; 27 26 import org.openstreetmap.josm.testutils.DatasetFactory; 28 import org.openstreetmap.josm.testutils. JOSMTestRules;27 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 29 28 import org.openstreetmap.josm.tools.Logging; 30 29 31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;32 33 30 /** 34 31 * Unit tests of {@link NodeListMergeModel}. 35 32 */ 33 @BasicPreferences 36 34 class NodeListMergeModelTest { 37 35 38 36 private final DatasetFactory my = new DatasetFactory(); 39 37 private final DatasetFactory their = new DatasetFactory(); 40 38 41 /**42 * Setup test.43 */44 @RegisterExtension45 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")46 public JOSMTestRules test = new JOSMTestRules();47 48 39 @SuppressWarnings("unchecked") 49 40 protected List<Node> inspectNodeList(NodeListMergeModel model, String name) { 50 41 try { -
test/unit/org/openstreetmap/josm/gui/datatransfer/ClipboardUtilsTest.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.datatransfer; 3 3 4 import static org.junit.Assume.assumeTrue; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 7 import static org.junit.jupiter.api.Assertions.assertNull; 7 8 import static org.junit.jupiter.api.Assertions.assertSame; 8 9 import static org.junit.jupiter.api.Assertions.assertTrue; 9 import static org.junit.Assume.assumeTrue;10 10 11 11 import java.awt.GraphicsEnvironment; 12 12 import java.awt.datatransfer.Clipboard; … … 16 16 import java.awt.datatransfer.UnsupportedFlavorException; 17 17 import java.io.IOException; 18 18 19 import org.junit.jupiter.api.extension.RegisterExtension;20 19 import org.junit.jupiter.api.Test; 21 import org.openstreetmap.josm.testutils.JOSMTestRules;22 20 23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;24 21 import net.trajano.commons.testing.UtilityClassTestUtil; 25 22 26 23 /** … … 67 64 } 68 65 69 66 /** 70 * No dependencies71 */72 @RegisterExtension73 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")74 public JOSMTestRules test = new JOSMTestRules();75 76 /**77 67 * Test {@link ClipboardUtils#getClipboard()} 78 68 */ 79 69 @Test -
test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java
6 6 7 7 import java.util.Collections; 8 8 9 import org.junit.jupiter.api.extension.RegisterExtension;10 9 import org.junit.jupiter.api.Test; 11 10 import org.openstreetmap.josm.actions.CopyAction; 12 11 import org.openstreetmap.josm.data.coor.LatLon; … … 15 14 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 16 15 import org.openstreetmap.josm.gui.MainApplication; 17 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 18 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 19 import org.openstreetmap.josm.testutils.annotations.Main; 20 import org.openstreetmap.josm.testutils.annotations.Projection; 19 21 20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;21 22 22 /** 23 23 * Unit tests of {@link OsmTransferHandler} class. 24 24 */ 25 @FullPreferences 26 @Projection 27 @Main 28 @LayerEnvironment 25 29 class OsmTransferHandlerTest { 26 /**27 * Prefs to use OSM primitives28 */29 @RegisterExtension30 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")31 public JOSMTestRules test = new JOSMTestRules().preferences().projection().main();32 33 30 private final OsmTransferHandler transferHandler = new OsmTransferHandler(); 34 31 35 32 /** -
test/unit/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferableTest.java
3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.junit.jupiter.api.Assertions.assertThrows;8 8 9 9 import java.awt.datatransfer.DataFlavor; 10 10 import java.awt.datatransfer.UnsupportedFlavorException; … … 14 14 import java.util.List; 15 15 16 16 import org.junit.jupiter.api.Test; 17 import org.junit.jupiter.api.extension.RegisterExtension;18 17 import org.openstreetmap.josm.data.osm.Node; 19 18 import org.openstreetmap.josm.data.osm.NodeData; 20 19 import org.openstreetmap.josm.data.osm.PrimitiveData; 21 20 import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData; 22 21 import org.openstreetmap.josm.gui.datatransfer.data.TagTransferData; 23 import org.openstreetmap.josm.testutils. JOSMTestRules;22 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 24 23 25 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;26 27 24 /** 28 25 * Unit tests of {@link PrimitiveTransferable} class. 29 26 */ 27 @BasicPreferences 30 28 class PrimitiveTransferableTest { 31 29 /** 32 * Prefs to use OSM primitives33 */34 @RegisterExtension35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")36 public JOSMTestRules test = new JOSMTestRules().preferences();37 38 /**39 30 * Test of {@link PrimitiveTransferable#getTransferDataFlavors()} method response order 40 31 */ 41 32 @Test -
test/unit/org/openstreetmap/josm/gui/datatransfer/RelationMemberTransferableTest.java
3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.junit.jupiter.api.Assertions.assertThrows;8 8 import static org.openstreetmap.josm.gui.datatransfer.RelationMemberTransferable.RELATION_MEMBER_DATA; 9 9 10 10 import java.awt.datatransfer.DataFlavor; … … 13 13 import java.util.Collections; 14 14 15 15 import org.junit.jupiter.api.Test; 16 import org.junit.jupiter.api.extension.RegisterExtension;17 16 import org.openstreetmap.josm.data.osm.Node; 18 17 import org.openstreetmap.josm.data.osm.PrimitiveData; 19 18 import org.openstreetmap.josm.data.osm.RelationMember; 20 19 import org.openstreetmap.josm.data.osm.RelationMemberData; 21 20 import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData; 22 import org.openstreetmap.josm.testutils. JOSMTestRules;21 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 23 22 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;25 26 23 /** 27 24 * Unit tests of {@link RelationMemberTransferable} class. 28 25 */ 26 @BasicPreferences 29 27 class RelationMemberTransferableTest { 30 31 28 /** 32 * Setup tests33 */34 @RegisterExtension35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")36 public JOSMTestRules test = new JOSMTestRules();37 38 /**39 29 * Test of {@link RelationMemberTransferable#getTransferDataFlavors()} method. 40 30 */ 41 31 @Test -
test/unit/org/openstreetmap/josm/gui/datatransfer/TagTransferableTest.java
3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.junit.jupiter.api.Assertions.assertThrows;8 8 9 9 import java.awt.datatransfer.DataFlavor; 10 10 import java.awt.datatransfer.UnsupportedFlavorException; … … 12 12 import java.util.Map; 13 13 14 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension;16 15 import org.openstreetmap.josm.gui.datatransfer.data.TagTransferData; 17 import org.openstreetmap.josm.testutils.JOSMTestRules;18 16 19 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;20 21 17 /** 22 18 * Unit tests of {@link TagTransferable} class. 23 19 */ 24 20 class TagTransferableTest { 25 26 21 /** 27 * Setup tests28 */29 @RegisterExtension30 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")31 public JOSMTestRules test = new JOSMTestRules();32 33 /**34 22 * Test of {@link TagTransferable#isDataFlavorSupported} method. 35 23 */ 36 24 @Test -
test/unit/org/openstreetmap/josm/gui/dialogs/CommandStackDialogTest.java
4 4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 6 7 import org.junit.jupiter.api.extension.RegisterExtension;8 7 import org.junit.jupiter.api.Test; 9 8 import org.openstreetmap.josm.TestUtils; 10 9 import org.openstreetmap.josm.command.Command; … … 13 12 import org.openstreetmap.josm.gui.MainApplication; 14 13 import org.openstreetmap.josm.gui.MapFrame; 15 14 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 15 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 16 import org.openstreetmap.josm.testutils.annotations.Main; 17 import org.openstreetmap.josm.testutils.annotations.Projection; 17 18 18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;19 20 19 /** 21 20 * Unit tests of {@link CommandStackDialog} class. 22 21 */ 22 @FullPreferences 23 @Projection 24 @Main 23 25 class CommandStackDialogTest { 24 25 26 /** 26 * Setup tests27 */28 @RegisterExtension29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")30 public JOSMTestRules test = new JOSMTestRules().main().projection().preferences();31 32 /**33 27 * Unit test of {@link CommandStackDialog} class - empty case. 34 28 */ 35 29 @Test -
test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java
7 7 import java.awt.Color; 8 8 import java.awt.image.BufferedImage; 9 9 10 import org.junit.jupiter.api.extension.RegisterExtension;11 10 import org.junit.jupiter.api.Test; 12 11 import org.openstreetmap.josm.data.coor.LatLon; 13 12 import org.openstreetmap.josm.data.osm.DataSet; … … 18 17 import org.openstreetmap.josm.gui.MainApplication; 19 18 import org.openstreetmap.josm.gui.dialogs.ConflictDialog.ConflictPainter; 20 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 21 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 import org.openstreetmap.josm.testutils.annotations.Main; 21 import org.openstreetmap.josm.testutils.annotations.Projection; 22 22 23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;24 25 23 /** 26 24 * Unit tests of {@link ConflictDialog} class. 27 25 */ 26 @Main 27 @Projection 28 28 class ConflictDialogTest { 29 30 29 /** 31 * Setup tests32 */33 @RegisterExtension34 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")35 public JOSMTestRules test = new JOSMTestRules().main().projection();36 37 /**38 30 * Unit test of {@link ConflictDialog#ConflictDialog}. 39 31 */ 40 32 @Test -
test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorActionTest.java
7 7 8 8 import org.junit.jupiter.api.BeforeEach; 9 9 import org.junit.jupiter.api.Disabled; 10 import org.junit.jupiter.api.extension.RegisterExtension;11 10 import org.openstreetmap.josm.data.osm.DataSet; 12 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 12 import org.openstreetmap.josm.data.osm.Relation; … … 22 21 import org.openstreetmap.josm.gui.tagging.TagEditorModel; 23 22 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 24 23 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; 25 import org.openstreetmap.josm.testutils.JOSMTestRules; 24 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 25 import org.openstreetmap.josm.testutils.annotations.Main; 26 26 27 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;28 29 27 /** 30 28 * This class provides the basic test environment for relation editor actions. 31 29 * @author Michael Zangl 32 30 */ 33 31 @Disabled 32 @FullPreferences 33 @Main 34 34 public abstract class AbstractRelationEditorActionTest { 35 /**36 * Platform for tooltips.37 */38 @RegisterExtension39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")40 public JOSMTestRules test = new JOSMTestRules().preferences().main();41 42 35 protected OsmDataLayer layer; 43 36 44 37 private SelectionTableModel selectionTableModel; -
test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
10 10 import org.junit.Assert; 11 11 import org.junit.jupiter.api.BeforeEach; 12 12 import org.junit.jupiter.api.Test; 13 import org.junit.jupiter.api.extension.RegisterExtension;14 13 import org.openstreetmap.josm.data.osm.DataSet; 15 14 import org.openstreetmap.josm.data.osm.Relation; 16 15 import org.openstreetmap.josm.data.osm.RelationMember; … … 17 16 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 18 17 import org.openstreetmap.josm.io.IllegalDataException; 19 18 import org.openstreetmap.josm.io.OsmReader; 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 19 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 20 import org.openstreetmap.josm.testutils.annotations.Projection; 21 21 22 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;23 24 22 /** 25 23 * Unit tests of {@link RelationSorter} class. 26 24 */ 25 @FullPreferences 26 @Projection // defaults to Mercator projection 27 27 class RelationSorterTest { 28 28 29 29 private final RelationSorter sorter = new RelationSorter(); … … 30 30 private DataSet testDataset; 31 31 32 32 /** 33 * Use Mercator projection34 */35 @RegisterExtension36 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")37 public JOSMTestRules test = new JOSMTestRules().preferences().projection();38 39 /**40 33 * Load the test data set 41 34 * @throws IllegalDataException if an error was found while parsing the data 42 35 * @throws IOException in case of I/O error -
test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java
9 9 import javax.swing.JOptionPane; 10 10 11 11 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api.extension.RegisterExtension;13 12 import org.openstreetmap.josm.TestUtils; 14 import org.openstreetmap.josm.testutils.JOSMTestRules; 13 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 14 import org.openstreetmap.josm.testutils.annotations.HTTPS; 15 15 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 16 16 import org.openstreetmap.josm.tools.LanguageInfo.LocaleType; 17 17 import org.openstreetmap.josm.tools.PlatformHook; 18 18 import org.openstreetmap.josm.tools.PlatformManager; 19 19 20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;21 20 import mockit.Expectations; 22 21 import mockit.Injectable; 23 22 import mockit.Mocked; … … 25 24 /** 26 25 * Unit tests of {@link HelpBrowser} class. 27 26 */ 27 @FullPreferences 28 @HTTPS 28 29 class HelpBrowserTest { 29 30 30 31 static final String URL_1 = "https://josm.openstreetmap.de/wiki/Help"; … … 31 32 static final String URL_2 = "https://josm.openstreetmap.de/wiki/Introduction"; 32 33 static final String URL_3 = "https://josm.openstreetmap.de/javadoc"; 33 34 34 /**35 * Setup tests36 */37 @RegisterExtension38 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")39 static JOSMTestRules test = new JOSMTestRules().preferences().https();40 41 35 static IHelpBrowser newHelpBrowser() { 42 36 return new IHelpBrowser() { 43 37 -
test/unit/org/openstreetmap/josm/gui/help/HyperlinkHandlerTest.java
10 10 import javax.swing.text.html.HTMLDocument; 11 11 import javax.swing.text.html.HTMLEditorKit; 12 12 13 import org.junit.jupiter.api.extension.RegisterExtension;14 13 import org.junit.jupiter.api.Test; 15 14 import org.openstreetmap.josm.gui.widgets.JosmEditorPane; 16 import org.openstreetmap.josm.testutils. JOSMTestRules;15 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 17 16 18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;19 20 17 /** 21 18 * Unit tests of {@link HyperlinkHandler} class. 22 19 */ 20 @BasicPreferences // Needed for OsmPrimitive 23 21 class HyperlinkHandlerTest { 24 25 22 /** 26 * Setup tests27 */28 @RegisterExtension29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")30 public JOSMTestRules test = new JOSMTestRules().preferences();31 32 /**33 23 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/17338">#17338</a>. 34 24 * @throws Exception if an error occurs 35 25 */ -
test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserModelTest.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.history; 3 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertNotEquals; 6 7 import static org.junit.jupiter.api.Assertions.assertNotNull; … … 7 8 import static org.junit.jupiter.api.Assertions.assertNull; 8 9 import static org.junit.jupiter.api.Assertions.assertTrue; 9 10 10 import org.junit.jupiter.api.extension.RegisterExtension;11 11 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api.Timeout; 12 13 import org.openstreetmap.josm.data.osm.Node; 13 14 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 14 15 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; … … 16 17 import org.openstreetmap.josm.data.osm.history.History; 17 18 import org.openstreetmap.josm.data.osm.history.HistoryDataSet; 18 19 import org.openstreetmap.josm.data.osm.history.HistoryNode; 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 21 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 20 22 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;22 23 23 /** 24 24 * Unit tests of {@link HistoryBrowserModel} class. 25 25 */ 26 @FullPreferences 27 @OsmApiType(apiType = OsmApiType.APIType.DEV) 28 @Timeout(30) 26 29 class HistoryBrowserModelTest { 27 28 30 /** 29 * Setup test.30 */31 @RegisterExtension32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")33 public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(30000);34 35 /**36 31 * Test for {@link HistoryBrowserModel#HistoryBrowserModel}. 37 32 */ 38 33 @Test … … 98 93 void testSetPointsInTimeNullHistory() { 99 94 HistoryBrowserModel model = new HistoryBrowserModel(); 100 95 VersionTableModel tableModel = model.getVersionTableModel(); 101 tableModel.setValueAt(false, 0, 0); // code coverage102 tableModel.setValueAt(true, 0, 1); // reference point103 tableModel.setValueAt(true, 1, 2); // current point104 tableModel.setValueAt(true, 3, 3); // code coverage96 assertDoesNotThrow(() -> tableModel.setValueAt(false, 0, 0)); // code coverage 97 assertDoesNotThrow(() -> tableModel.setValueAt(true, 0, 1)); // reference point 98 assertDoesNotThrow(() -> tableModel.setValueAt(true, 1, 2)); // current point 99 assertDoesNotThrow(() -> tableModel.setValueAt(true, 3, 3)); // code coverage 105 100 } 106 101 107 102 /** -
test/unit/org/openstreetmap/josm/gui/history/HistoryLoadTaskTest.java
6 6 import java.io.IOException; 7 7 import java.io.InputStream; 8 8 9 import org.junit.jupiter.api.extension.RegisterExtension;10 9 import org.junit.jupiter.api.Test; 10 import org.junit.jupiter.api.Timeout; 11 11 import org.openstreetmap.josm.TestUtils; 12 12 import org.openstreetmap.josm.data.osm.Node; 13 13 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 21 21 import org.openstreetmap.josm.io.OsmHistoryReader; 22 22 import org.openstreetmap.josm.io.OsmServerHistoryReader; 23 23 import org.openstreetmap.josm.io.OsmTransferException; 24 import org.openstreetmap.josm.testutils.JOSMTestRules; 24 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 25 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 25 26 import org.xml.sax.SAXException; 26 27 27 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;28 29 28 /** 30 29 * Unit tests of {@link HistoryLoadTask} class. 31 30 */ 31 @FullPreferences 32 @OsmApiType(apiType = OsmApiType.APIType.DEV) 33 @Timeout(20) 32 34 class HistoryLoadTaskTest { 33 34 35 /** 35 * Setup test.36 */37 @RegisterExtension38 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")39 public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(20000);40 41 /**42 36 * Unit test of {@link HistoryLoadTask#getLoadingMessage} 43 37 */ 44 38 @Test -
test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java
13 13 import javax.swing.JOptionPane; 14 14 import javax.swing.JPanel; 15 15 16 import org.junit.jupiter.api.extension.RegisterExtension;17 16 import org.junit.jupiter.api.Test; 18 17 import org.openstreetmap.josm.TestUtils; 19 18 import org.openstreetmap.josm.data.UserIdentityManager; 20 19 import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard; 21 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 21 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 22 22 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 23 23 import org.openstreetmap.josm.testutils.mockers.WindowMocker; 24 24 import org.openstreetmap.josm.tools.UserCancelException; 25 25 26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;27 26 import mockit.Invocation; 28 27 import mockit.Mock; 29 28 import mockit.MockUp; … … 31 30 /** 32 31 * Unit tests of {@link DownloadOpenChangesetsTask} class. 33 32 */ 33 @FullPreferences 34 @OsmApiType(apiType = OsmApiType.APIType.DEV) 34 35 class DownloadOpenChangesetsTaskTest { 35 36 36 /** 37 * Setup tests38 */39 @RegisterExtension40 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")41 public JOSMTestRules test = new JOSMTestRules().preferences().devAPI();42 43 /**44 37 * OAuth wizard mocker. 45 38 */ 46 39 public static class OAuthWizardMocker extends MockUp<OAuthAuthorizationWizard> { -
test/unit/org/openstreetmap/josm/gui/io/DownloadPrimitivesTaskTest.java
7 7 8 8 import java.util.Arrays; 9 9 10 import org.junit.jupiter.api.extension.RegisterExtension;11 10 import org.junit.jupiter.api.Test; 11 import org.junit.jupiter.api.Timeout; 12 12 import org.openstreetmap.josm.data.osm.DataSet; 13 13 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 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 17 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 17 18 18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;19 20 19 /** 21 20 * Unit tests of {@link DownloadPrimitivesTask} class. 22 21 */ 22 @FullPreferences 23 @OsmApiType(apiType = OsmApiType.APIType.DEV) 24 @Timeout(20) 23 25 class DownloadPrimitivesTaskTest { 24 25 26 /** 26 * Setup tests27 */28 @RegisterExtension29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")30 public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(20000);31 32 /**33 27 * Test of {@link DownloadPrimitivesTask} class. 34 28 */ 35 29 @Test -
test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java
11 11 12 12 import org.junit.jupiter.api.BeforeEach; 13 13 import org.junit.jupiter.api.Test; 14 import org.junit.jupiter.api.extension.RegisterExtension;15 14 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 15 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 16 import org.openstreetmap.josm.testutils.annotations.LayerEnvironment; 17 import org.openstreetmap.josm.testutils.annotations.Projection; 17 18 18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;19 20 19 /** 21 20 * Test of the base {@link Layer} class 22 21 * @author Michael Zangl 23 22 */ 23 @BasicPreferences 24 @Projection 25 @LayerEnvironment 24 26 class LayerTest { 25 /**26 * We need projection27 */28 @RegisterExtension29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")30 public JOSMTestRules test = new JOSMTestRules().preferences().projection();31 32 27 private Layer testLayer; 33 28 34 29 /** -
test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
16 16 17 17 import org.junit.jupiter.api.BeforeEach; 18 18 import org.junit.jupiter.api.Test; 19 import org.junit.jupiter.api.extension.RegisterExtension;20 19 import org.openstreetmap.josm.TestUtils; 21 20 import org.openstreetmap.josm.actions.ExpertToggleAction; 22 21 import org.openstreetmap.josm.data.Bounds; … … 35 34 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 36 35 import org.openstreetmap.josm.io.IllegalDataException; 37 36 import org.openstreetmap.josm.io.OsmReader; 38 import org.openstreetmap.josm.testutils.JOSMTestRules; 37 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 38 import org.openstreetmap.josm.testutils.annotations.Main; 39 import org.openstreetmap.josm.testutils.annotations.Projection; 39 40 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; 40 41 import org.openstreetmap.josm.tools.Logging; 41 42 import org.openstreetmap.josm.tools.date.DateUtils; 42 43 43 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;44 45 44 /** 46 45 * Unit tests of {@link OsmDataLayer} class. 47 46 */ 47 @Projection 48 @Main 49 @BasicPreferences // for primitives 48 50 class OsmDataLayerTest { 49 50 /**51 * Setup tests52 */53 @RegisterExtension54 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")55 public JOSMTestRules test = new JOSMTestRules().projection().main();56 57 51 private DataSet ds; 58 52 private OsmDataLayer layer; 59 53 -
test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.java
12 12 import org.junit.jupiter.api.BeforeEach; 13 13 import org.junit.jupiter.api.Disabled; 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.DataSet; 18 17 import org.openstreetmap.josm.data.osm.Node; … … 24 23 import org.openstreetmap.josm.gui.mappaint.MultiCascade; 25 24 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.ChildOrParentSelector; 26 25 import org.openstreetmap.josm.io.OsmReader; 27 import org.openstreetmap.josm.testutils. JOSMTestRules;26 import org.openstreetmap.josm.testutils.annotations.Projection; 28 27 29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;30 31 28 /** 32 29 * Unit tests of {@link ChildOrParentSelector}. 33 30 */ 31 @Projection 34 32 class ChildOrParentSelectorTest { 35 33 36 34 private DataSet ds; 37 35 38 36 /** 39 * Setup rule40 */41 @RegisterExtension42 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")43 public JOSMTestRules test = new JOSMTestRules().projection();44 45 /**46 37 * Setup test 47 38 */ 48 39 @BeforeEach -
test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionTest.java
7 7 8 8 import org.junit.jupiter.api.BeforeEach; 9 9 import org.junit.jupiter.api.Test; 10 import org.junit.jupiter.api.extension.RegisterExtension;11 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 11 import org.openstreetmap.josm.data.osm.OsmUtils; 13 12 import org.openstreetmap.josm.gui.mappaint.Environment; … … 15 14 import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.ToTagConvertable; 16 15 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.Op; 17 16 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.SimpleKeyValueCondition; 18 import org.openstreetmap.josm.testutils. JOSMTestRules;17 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 19 18 20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;21 22 19 /** 23 20 * This test universally tests all {@link Condition}s. 24 21 * @author Michael Zangl 25 22 */ 23 @FullPreferences // Nodes require preferences 26 24 class ConditionTest { 27 /**28 * We need prefs for nodes.29 */30 @RegisterExtension31 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")32 public JOSMTestRules test = new JOSMTestRules().preferences();33 25 private OsmPrimitive node0; 34 26 private OsmPrimitive node1; 35 27 private OsmPrimitive node2; -
test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
16 16 17 17 import org.junit.Assert; 18 18 import org.junit.jupiter.api.Test; 19 import org.junit.jupiter.api.extension.RegisterExtension;20 19 import org.openstreetmap.josm.TestUtils; 21 20 import org.openstreetmap.josm.data.coor.LatLon; 22 21 import org.openstreetmap.josm.data.osm.DataSet; … … 38 37 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.ChildOrParentSelector; 39 38 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser; 40 39 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException; 41 import org.openstreetmap.josm.testutils. JOSMTestRules;40 import org.openstreetmap.josm.testutils.annotations.Projection; 42 41 import org.openstreetmap.josm.tools.ColorHelper; 43 42 44 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;45 46 43 /** 47 44 * Unit tests of {@link MapCSSParser}. 48 45 */ 46 @Projection 49 47 class MapCSSParserTest { 50 48 51 49 protected static Environment getEnvironment(String key, String value) { … … 56 54 return new MapCSSParser(new StringReader(stringToParse)); 57 55 } 58 56 59 /**60 * Setup rule61 */62 @RegisterExtension63 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")64 public JOSMTestRules test = new JOSMTestRules().projection();65 66 57 @Test 67 58 void testDeclarations() throws Exception { 68 59 getParser("{ opacity: 0.5; color: rgb(1.0, 0.0, 0.0); }").declaration(); -
test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
25 25 import org.apache.commons.jcs3.access.CacheAccess; 26 26 import org.junit.jupiter.api.AfterAll; 27 27 import org.junit.jupiter.api.BeforeAll; 28 import org.junit.jupiter.api. extension.RegisterExtension;28 import org.junit.jupiter.api.Timeout; 29 29 import org.junit.jupiter.params.ParameterizedTest; 30 30 import org.junit.jupiter.params.provider.Arguments; 31 31 import org.junit.jupiter.params.provider.MethodSource; … … 59 59 import org.openstreetmap.josm.data.projection.Projections; 60 60 import org.openstreetmap.josm.io.imagery.ApiKeyProvider; 61 61 import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException; 62 import org.openstreetmap.josm.testutils.JOSMTestRules; 62 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 63 import org.openstreetmap.josm.testutils.annotations.HTTP; 64 import org.openstreetmap.josm.testutils.annotations.HTTPS; 65 import org.openstreetmap.josm.testutils.annotations.I18n; 66 import org.openstreetmap.josm.testutils.annotations.IntegrationTest; 67 import org.openstreetmap.josm.testutils.annotations.ProjectionNadGrids; 68 import org.openstreetmap.josm.testutils.annotations.SlowTest; 63 69 import org.openstreetmap.josm.tools.HttpClient; 64 70 import org.openstreetmap.josm.tools.HttpClient.Response; 65 71 import org.openstreetmap.josm.tools.Logging; 66 72 import org.openstreetmap.josm.tools.Utils; 67 73 68 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;69 70 74 /** 71 75 * Integration tests of {@link ImageryPreference} class. 72 76 */ 77 @HTTP 78 @HTTPS 79 @I18n 80 @FullPreferences 81 @org.openstreetmap.josm.testutils.annotations.Projection 82 @ProjectionNadGrids 83 @Timeout(value = 40, unit = TimeUnit.MINUTES) 84 @IntegrationTest 85 @SlowTest 73 86 public class ImageryPreferenceTestIT { 74 87 75 88 private static final String ERROR_SEP = " -> "; … … 76 89 private static final LatLon GREENWICH = new LatLon(51.47810, -0.00170); 77 90 private static final int DEFAULT_ZOOM = 12; 78 91 79 /**80 * Setup rule81 */82 @RegisterExtension83 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")84 static JOSMTestRules test = new JOSMTestRules().https().i18n().preferences().projection().projectionNadGrids()85 .timeout((int) TimeUnit.MINUTES.toMillis(40));86 87 92 /** Entry to test */ 88 93 private final Map<String, Map<ImageryInfo, List<String>>> errors = Collections.synchronizedMap(new TreeMap<>()); 89 94 private final Map<String, Map<ImageryInfo, List<String>>> ignoredErrors = Collections.synchronizedMap(new TreeMap<>()); -
test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java
8 8 import java.io.IOException; 9 9 import java.util.ArrayList; 10 10 import java.util.List; 11 import java.util.concurrent.TimeUnit; 11 12 12 13 import org.junit.jupiter.api.BeforeAll; 13 import org.junit.jupiter.api. extension.RegisterExtension;14 import org.junit.jupiter.api.Timeout; 14 15 import org.junit.jupiter.params.ParameterizedTest; 15 16 import org.junit.jupiter.params.provider.MethodSource; 16 17 import org.openstreetmap.josm.TestUtils; … … 23 24 import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction.AssignmentInstruction; 24 25 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule; 25 26 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 26 import org.openstreetmap.josm.testutils.JOSMTestRules; 27 import org.openstreetmap.josm.testutils.annotations.HTTPS; 28 import org.openstreetmap.josm.testutils.annotations.IntegrationTest; 29 import org.openstreetmap.josm.testutils.annotations.SlowTest; 27 30 import org.openstreetmap.josm.tools.ImageProvider; 28 31 29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;30 31 32 /** 32 33 * Integration tests of {@link MapPaintPreference} class. 33 34 */ 35 @HTTPS 36 @Timeout(value = 15, unit = TimeUnit.MINUTES) 37 @IntegrationTest 38 @SlowTest 34 39 class MapPaintPreferenceTestIT extends AbstractExtendedSourceEntryTestCase { 35 36 40 /** 37 * Setup rule38 */39 @RegisterExtension40 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")41 public static JOSMTestRules test = new JOSMTestRules().https().timeout(15000*60).parameters();42 43 /**44 41 * Setup test 45 42 * @throws IOException in case of I/O error 46 43 */ -
test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java
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; 19 import org.junit.jupiter.api. extension.RegisterExtension;20 import org.junit.jupiter.api.Timeout; 20 21 import org.junit.jupiter.params.ParameterizedTest; 21 22 import org.junit.jupiter.params.provider.MethodSource; 22 23 import org.openstreetmap.josm.TestUtils; … … 26 27 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetsTest; 27 28 import org.openstreetmap.josm.gui.tagging.presets.items.Link; 28 29 import org.openstreetmap.josm.spi.preferences.Config; 29 import org.openstreetmap.josm.testutils.JOSMTestRules; 30 import org.openstreetmap.josm.testutils.annotations.HTTP; 31 import org.openstreetmap.josm.testutils.annotations.HTTPS; 32 import org.openstreetmap.josm.testutils.annotations.IntegrationTest; 33 import org.openstreetmap.josm.testutils.annotations.SlowTest; 30 34 import org.openstreetmap.josm.tools.HttpClient; 31 35 import org.openstreetmap.josm.tools.HttpClient.Response; 32 36 import org.openstreetmap.josm.tools.ImageProvider; … … 33 37 import org.openstreetmap.josm.tools.Logging; 34 38 import org.xml.sax.SAXException; 35 39 36 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;37 38 40 /** 39 41 * Integration tests of {@link TaggingPresetPreference} class. 40 42 */ 43 @HTTP 44 @HTTPS 45 @Timeout(value = 20, unit = TimeUnit.MINUTES) 46 @IntegrationTest 47 @SlowTest 41 48 class TaggingPresetPreferenceTestIT extends AbstractExtendedSourceEntryTestCase { 42 43 49 /** 44 * Setup rule45 */46 @RegisterExtension47 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")48 public static JOSMTestRules test = new JOSMTestRules().https().timeout(10000*120).parameters();49 50 /**51 50 * Setup test 52 51 * @throws IOException in case of I/O error 53 52 */ -
test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java
9 9 import java.util.Collection; 10 10 11 11 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api. extension.RegisterExtension;12 import org.junit.jupiter.api.Timeout; 13 13 import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry; 14 14 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 15 15 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.ParseResult; 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 import org.openstreetmap.josm.testutils.annotations.HTTP; 17 import org.openstreetmap.josm.testutils.annotations.HTTPS; 18 import org.openstreetmap.josm.testutils.annotations.IntegrationTest; 17 19 18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;19 20 20 /** 21 21 * Integration tests of {@link ValidatorTagCheckerRulesPreference} class. 22 22 */ 23 @HTTP 24 @HTTPS 25 @Timeout(20) 26 @IntegrationTest 23 27 class ValidatorTagCheckerRulesPreferenceTestIT { 24 25 28 /** 26 * Setup rule27 */28 @RegisterExtension29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")30 public JOSMTestRules test = new JOSMTestRules().https().timeout(20_000);31 32 /**33 29 * Test that available tag checker rules are valid. 34 30 * @throws Exception in case of error 35 31 */ -
test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java
14 14 15 15 import org.junit.Assert; 16 16 import org.junit.jupiter.api.Test; 17 import org.junit.jupiter.api.extension.RegisterExtension;18 17 import org.openstreetmap.josm.TestUtils; 19 18 import org.openstreetmap.josm.gui.tagging.presets.items.Check; 20 19 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 21 import org.openstreetmap.josm.testutils. JOSMTestRules;20 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 22 21 import org.xml.sax.SAXException; 23 22 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;25 26 23 /** 27 24 * Unit tests of {@link TaggingPresetReader} class. 28 25 */ 26 @BasicPreferences 29 27 class TaggingPresetReaderTest { 30 31 28 /** 32 * Setup rule33 */34 @RegisterExtension35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")36 public JOSMTestRules test = new JOSMTestRules();37 38 /**39 29 * #8954 - last checkbox in the preset is not added 40 30 * @throws SAXException if any XML error occurs 41 31 * @throws IOException if any I/O error occurs -
test/unit/org/openstreetmap/josm/io/CertificateAmendmentTestIT.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org.junit.Assume.assumeFalse;5 4 5 import static org.junit.jupiter.api.Assumptions.assumeFalse; 6 6 7 import java.io.IOException; 7 8 import java.net.URL; 8 9 import java.net.URLConnection; … … 11 12 12 13 import javax.net.ssl.SSLHandshakeException; 13 14 14 import org.junit.Assert; 15 import org.junit.ClassRule; 15 import org.junit.jupiter.api.Assertions; 16 16 import org.junit.jupiter.api.BeforeAll; 17 17 import org.junit.jupiter.api.Test; 18 import org.junit.jupiter.api.Timeout; 18 19 import org.openstreetmap.josm.TestUtils; 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 21 import org.openstreetmap.josm.testutils.annotations.HTTP; 22 import org.openstreetmap.josm.testutils.annotations.HTTPS; 23 import org.openstreetmap.josm.testutils.annotations.IntegrationTest; 20 24 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;22 23 25 /** 24 26 * Integration tests of {@link CertificateAmendment} class. 25 27 */ 28 @IntegrationTest 29 @Timeout(20) 30 @HTTP 31 @HTTPS 32 @BasicPreferences 26 33 class CertificateAmendmentTestIT { 27 28 /**29 * Setup rule30 */31 @ClassRule32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")33 public static JOSMTestRules test = new JOSMTestRules().https().preferences().timeout(20000);34 35 34 private static final List<String> errorsToIgnore = new ArrayList<>(); 36 35 37 36 /** … … 110 109 String error = "Expected error: " + url; 111 110 assumeFalse(errorsToIgnore.contains(error)); 112 111 if (!shouldWork) { 113 Assert .fail(error);112 Assertions.fail(error); 114 113 } 115 114 } 116 115 } -
test/unit/org/openstreetmap/josm/io/DiffResultProcessorTest.java
9 9 import java.util.Collections; 10 10 import java.util.Set; 11 11 12 import org.junit.jupiter.api.extension.RegisterExtension;13 12 import org.junit.jupiter.api.Test; 14 13 import org.openstreetmap.josm.data.coor.LatLon; 15 14 import org.openstreetmap.josm.data.osm.Changeset; … … 21 20 import org.openstreetmap.josm.data.osm.Way; 22 21 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 23 22 import org.openstreetmap.josm.io.DiffResultProcessor.DiffResultEntry; 24 import org.openstreetmap.josm.testutils. JOSMTestRules;23 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 25 24 import org.openstreetmap.josm.tools.Logging; 26 25 import org.openstreetmap.josm.tools.XmlParsingException; 27 26 28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;29 30 27 /** 31 28 * Unit tests of {@link DiffResultProcessor} 32 29 */ 30 @BasicPreferences 33 31 class DiffResultProcessorTest { 34 35 /**36 * Setup rule37 */38 @RegisterExtension39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")40 public JOSMTestRules test = new JOSMTestRules();41 42 32 private static void shouldFail(String s) { 43 33 try { 44 34 new DiffResultProcessor(null).parse(s, NullProgressMonitor.INSTANCE); -
test/unit/org/openstreetmap/josm/io/NetworkManagerTest.java
9 9 import java.net.URL; 10 10 import java.util.Map; 11 11 12 import org.junit.jupiter.api.extension.RegisterExtension;13 12 import org.junit.jupiter.api.Test; 14 import org.openstreetmap.josm.testutils.JOSMTestRules; 13 import org.openstreetmap.josm.testutils.annotations.HTTPS; 14 import org.openstreetmap.josm.testutils.annotations.Main; 15 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 16 import org.openstreetmap.josm.testutils.annotations.Projection; 15 17 16 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;17 18 18 /** 19 19 * Unit tests of {@link NetworkManager} class. 20 20 */ 21 @HTTPS 22 @Main 23 @Projection 24 @OsmApiType(apiType = OsmApiType.APIType.DEV) 21 25 class NetworkManagerTest { 22 23 26 /** 24 * Setup test.25 */26 @RegisterExtension27 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")28 public JOSMTestRules test = new JOSMTestRules().https().devAPI().main().projection();29 30 /**31 27 * Unit test of {@link NetworkManager#addNetworkError}, 32 28 * {@link NetworkManager#getNetworkErrors} and 33 29 * {@link NetworkManager#clearNetworkErrors}. -
test/unit/org/openstreetmap/josm/io/OsmReaderTest.java
17 17 import java.nio.file.Paths; 18 18 import java.util.Arrays; 19 19 20 import org.junit.jupiter.api.extension.RegisterExtension;21 20 import org.junit.jupiter.api.Test; 22 21 import org.openstreetmap.josm.TestUtils; 23 22 import org.openstreetmap.josm.data.osm.DataSet; … … 26 25 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 27 26 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 28 27 import org.openstreetmap.josm.io.OsmReader.Options; 29 import org.openstreetmap.josm.testutils. JOSMTestRules;28 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 30 29 31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;32 33 30 /** 34 31 * Unit tests of {@link OsmReader} class. 35 32 */ 33 @BasicPreferences // For primitives 36 34 class OsmReaderTest { 37 38 /**39 * Setup rule40 */41 @RegisterExtension42 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")43 public JOSMTestRules test = new JOSMTestRules();44 45 35 private static Options[][] options() { 46 36 return new Options[][]{ 47 37 new Options[]{}, -
test/unit/org/openstreetmap/josm/io/auth/CredentialsAgentExceptionTest.java
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; 8 import org.openstreetmap.josm.testutils.JOSMTestRules;9 7 10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;11 12 8 /** 13 9 * Unit tests of {@link CredentialsAgentException} class. 14 10 */ 15 11 class CredentialsAgentExceptionTest { 16 17 12 /** 18 * Setup test19 */20 @RegisterExtension21 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")22 public JOSMTestRules test = new JOSMTestRules();23 24 /**25 13 * Unit test of {@code CredentialsAgentException#CredentialsAgentException} 26 14 */ 27 15 @Test -
test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java
5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 7 8 import org.junit.jupiter.api.extension.RegisterExtension;9 8 import org.junit.jupiter.api.Test; 10 9 import org.openstreetmap.josm.data.osm.DataSet; 11 10 import org.openstreetmap.josm.gui.MainApplication; 12 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 13 12 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException; 14 import org.openstreetmap.josm.testutils.JOSMTestRules; 13 import org.openstreetmap.josm.testutils.annotations.AssertionsInEDT; 14 import org.openstreetmap.josm.testutils.annotations.Main; 15 import org.openstreetmap.josm.testutils.annotations.Projection; 15 16 16 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;17 18 17 /** 19 18 * Unit tests of {@link AddNodeHandler} class. 20 19 */ 20 @Main 21 @Projection 22 @AssertionsInEDT 21 23 class AddNodeHandlerTest { 22 /**23 * Setup test.24 */25 @RegisterExtension26 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")27 public JOSMTestRules test = new JOSMTestRules().main().assertionsInEDT().projection();28 29 24 private static AddNodeHandler newHandler(String url) throws RequestHandlerBadRequestException { 30 25 AddNodeHandler req = new AddNodeHandler(); 31 26 if (url != null) -
test/unit/org/openstreetmap/josm/plugins/PluginExceptionTest.java
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; 8 import org.openstreetmap.josm.testutils.JOSMTestRules;9 7 10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;11 12 8 /** 13 9 * Unit tests of {@link PluginException} class. 14 10 */ 15 11 class PluginExceptionTest { 16 17 12 /** 18 * Setup test.19 */20 @RegisterExtension21 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")22 public JOSMTestRules test = new JOSMTestRules();23 24 /**25 13 * Unit test of {@link PluginException#PluginException}. 26 14 */ 27 15 @Test -
test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java
16 16 import javax.swing.JOptionPane; 17 17 import javax.swing.JScrollPane; 18 18 19 import org.junit.jupiter.api.extension.RegisterExtension;20 19 import org.junit.jupiter.api.Test; 21 20 import org.openstreetmap.josm.TestUtils; 22 21 import org.openstreetmap.josm.gui.MainApplication; … … 24 23 import org.openstreetmap.josm.gui.widgets.JosmTextArea; 25 24 import org.openstreetmap.josm.plugins.PluginHandler.DeprecatedPlugin; 26 25 import org.openstreetmap.josm.plugins.PluginHandler.PluginInformationAction; 27 import org.openstreetmap.josm.testutils. JOSMTestRules;26 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 28 27 import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; 29 28 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 30 29 31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;32 30 import nl.jqno.equalsverifier.EqualsVerifier; 33 31 34 32 /** 35 33 * Unit tests of {@link PluginHandler} class. 36 34 */ 35 @BasicPreferences 37 36 class PluginHandlerTest { 38 39 37 /** 40 * Setup test.41 */42 @RegisterExtension43 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")44 public JOSMTestRules test = new JOSMTestRules();45 46 /**47 38 * Unit test of methods {@link DeprecatedPlugin#equals} and {@link DeprecatedPlugin#hashCode}. 48 39 */ 49 40 @Test -
test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java
17 17 import java.util.Map; 18 18 import java.util.Map.Entry; 19 19 import java.util.Set; 20 import java.util.concurrent.TimeUnit; 20 21 import java.util.function.Consumer; 21 22 import java.util.stream.Collectors; 22 23 23 24 import org.junit.jupiter.api.BeforeAll; 24 25 import org.junit.jupiter.api.Test; 25 import org.junit.jupiter.api. extension.RegisterExtension;26 import org.junit.jupiter.api.Timeout; 26 27 import org.openstreetmap.josm.TestUtils; 27 28 import org.openstreetmap.josm.data.Preferences; 28 29 import org.openstreetmap.josm.data.gpx.GpxData; … … 33 34 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 import org.openstreetmap.josm.testutils.JOSMTestRules; 37 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 38 import org.openstreetmap.josm.testutils.annotations.HTTP; 39 import org.openstreetmap.josm.testutils.annotations.HTTPS; 40 import org.openstreetmap.josm.testutils.annotations.IntegrationTest; 41 import org.openstreetmap.josm.testutils.annotations.Main; 42 import org.openstreetmap.josm.testutils.annotations.Projection; 37 43 import org.openstreetmap.josm.tools.Destroyable; 38 44 import org.openstreetmap.josm.tools.Logging; 39 45 import org.openstreetmap.josm.tools.Utils; 40 46 41 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;42 43 47 /** 44 48 * Integration tests of {@link PluginHandler} class. 45 49 */ 50 @FullPreferences 51 @Projection 52 @HTTP 53 @HTTPS 54 @Main 55 @Timeout(value = 10, unit = TimeUnit.MINUTES) 56 @IntegrationTest 46 57 public class PluginHandlerTestIT { 47 48 58 private static final List<String> errorsToIgnore = new ArrayList<>(); 49 /**50 * Setup test.51 */52 @RegisterExtension53 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")54 public static JOSMTestRules test = new JOSMTestRules().main().projection().preferences().https()55 .timeout(10 * 60 * 1000);56 59 57 60 /** 58 61 * Setup test -
test/unit/org/openstreetmap/josm/spi/lifecycle/LifecycleTest.java
4 4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 6 7 import org.junit.jupiter.api.extension.RegisterExtension;8 7 import org.junit.jupiter.api.Test; 9 import org.openstreetmap.josm.testutils.JOSMTestRules; 8 import org.openstreetmap.josm.testutils.annotations.HTTPS; 9 import org.openstreetmap.josm.testutils.annotations.Main; 10 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 11 import org.openstreetmap.josm.testutils.annotations.Projection; 10 12 11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;12 13 13 /** 14 14 * Unit tests of {@link Lifecycle} class. 15 15 */ 16 @HTTPS 17 @Main 18 @Projection 19 @OsmApiType(apiType = OsmApiType.APIType.DEV) 16 20 class LifecycleTest { 17 18 /**19 * Setup test.20 */21 @RegisterExtension22 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")23 public JOSMTestRules test = new JOSMTestRules().https().devAPI().main().projection();24 25 21 private static class InitStatusListenerStub implements InitStatusListener { 26 22 27 23 boolean updated; -
test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
60 60 import org.openstreetmap.josm.io.OsmTransferCanceledException; 61 61 import org.openstreetmap.josm.spi.preferences.Config; 62 62 import org.openstreetmap.josm.spi.preferences.Setting; 63 import org.openstreetmap.josm.testutils.annotations.AssertionsInEDT; 64 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 65 import org.openstreetmap.josm.testutils.annotations.HTTPS; 66 import org.openstreetmap.josm.testutils.annotations.JosmHome; 67 import org.openstreetmap.josm.testutils.annotations.Main; 68 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 69 import org.openstreetmap.josm.testutils.annotations.Presets; 70 import org.openstreetmap.josm.testutils.annotations.Projection; 71 import org.openstreetmap.josm.testutils.annotations.ProjectionNadGrids; 63 72 import org.openstreetmap.josm.testutils.mockers.EDTAssertionMocker; 64 73 import org.openstreetmap.josm.testutils.mockers.WindowlessMapViewStateMocker; 65 74 import org.openstreetmap.josm.testutils.mockers.WindowlessNavigatableComponentMocker; … … 134 143 /** 135 144 * Enable the use of default preferences. 136 145 * @return this instance, for easy chaining 146 * @deprecated Use {@link FullPreferences} instead. 137 147 */ 148 @Deprecated 138 149 public JOSMTestRules preferences() { 139 150 josmHome(); 140 151 usePreferences = true; … … 144 155 /** 145 156 * Set JOSM home to a valid, empty directory. 146 157 * @return this instance, for easy chaining 158 * @deprecated Use {@link JosmHome} instead. 147 159 */ 160 @Deprecated 148 161 private JOSMTestRules josmHome() { 149 162 josmHome = new TemporaryFolder(); 150 163 return this; … … 153 166 /** 154 167 * Enables the i18n module for this test in english. 155 168 * @return this instance, for easy chaining 169 * @deprecated Use {org.openstreetmap.josm.testutils.annotations.I18n} instead. 156 170 */ 171 @Deprecated 157 172 public JOSMTestRules i18n() { 158 173 return i18n("en"); 159 174 } … … 162 177 * Enables the i18n module for this test. 163 178 * @param language The language to use. 164 179 * @return this instance, for easy chaining 180 * @deprecated Use {org.openstreetmap.josm.testutils.annotations.I18n} instead. 165 181 */ 182 @Deprecated 166 183 public JOSMTestRules i18n(String language) { 167 184 i18n = language; 168 185 return this; … … 172 189 * Mock this test's assumed JOSM version (as reported by {@link Version}). 173 190 * @param revisionProperties mock contents of JOSM's {@code REVISION} properties file 174 191 * @return this instance, for easy chaining 192 * @deprecated Use {@link OverrideAssumeRevision} instead. 175 193 */ 194 @Deprecated 176 195 public JOSMTestRules assumeRevision(final String revisionProperties) { 177 196 this.assumeRevisionString = revisionProperties; 178 197 return this; … … 181 200 /** 182 201 * Enable the dev.openstreetmap.org API for this test. 183 202 * @return this instance, for easy chaining 203 * @deprecated Use {@link OsmApiType} instead. 184 204 */ 205 @Deprecated 185 206 public JOSMTestRules devAPI() { 186 207 preferences(); 187 208 useAPI = APIType.DEV; … … 191 212 /** 192 213 * Use the {@link FakeOsmApi} for testing. 193 214 * @return this instance, for easy chaining 215 * @deprecated Use {@link OsmApiType} instead. 194 216 */ 217 @Deprecated 195 218 public JOSMTestRules fakeAPI() { 196 219 useAPI = APIType.FAKE; 197 220 return this; … … 200 223 /** 201 224 * Set up default projection (Mercator) 202 225 * @return this instance, for easy chaining 226 * @deprecated Use {@link Projection} instead. 203 227 */ 228 @Deprecated 204 229 public JOSMTestRules projection() { 205 230 useProjection = true; 206 231 return this; … … 209 234 /** 210 235 * Set up loading of NTV2 grit shift files to support projections that need them. 211 236 * @return this instance, for easy chaining 237 * @deprecated Use {@link ProjectionNadGrids} instead. 212 238 */ 239 @Deprecated 213 240 public JOSMTestRules projectionNadGrids() { 214 241 useProjectionNadGrids = true; 215 242 return this; … … 218 245 /** 219 246 * Set up HTTPS certificates 220 247 * @return this instance, for easy chaining 248 * @deprecated Use {@link HTTPS} instead. 221 249 */ 250 @Deprecated 222 251 public JOSMTestRules https() { 223 252 useHttps = true; 224 253 return this; … … 257 286 * Use presets in this test. 258 287 * @return this instance, for easy chaining 259 288 * @since 12568 289 * @deprecated Use {@link Presets} instead. 260 290 */ 291 @Deprecated 261 292 public JOSMTestRules presets() { 262 293 preferences(); 263 294 usePresets = true; … … 268 299 * Use boundaries dataset in this test. 269 300 * @return this instance, for easy chaining 270 301 * @since 12545 302 * @deprecated Use {@link org.openstreetmap.josm.testutils.annotations.Territories} instead. 271 303 */ 304 @Deprecated 272 305 public JOSMTestRules territories() { 273 306 territories = true; 274 307 return this; … … 299 332 /** 300 333 * Re-raise AssertionErrors thrown in the EDT where they would have normally been swallowed. 301 334 * @return this instance, for easy chaining 335 * @deprecated Use {@link AssertionsInEDT} instead 302 336 */ 337 @Deprecated 303 338 public JOSMTestRules assertionsInEDT() { 304 339 return this.assertionsInEDT(EDTAssertionMocker::new); 305 340 } … … 309 344 * @param edtAssertionMockingRunnable Runnable for initializing this functionality 310 345 * 311 346 * @return this instance, for easy chaining 347 * @deprecated Use {@link AssertionsInEDT} instead 312 348 */ 349 @Deprecated 313 350 public JOSMTestRules assertionsInEDT(final Runnable edtAssertionMockingRunnable) { 314 351 this.edtAssertionMockingRunnable = edtAssertionMockingRunnable; 315 352 return this; … … 351 388 * global variables in this test. 352 389 * @return this instance, for easy chaining 353 390 * @since 12557 391 * @deprecated Use {@link Main} instead 354 392 */ 393 @Deprecated 355 394 public JOSMTestRules main() { 356 395 return this.main( 357 396 WindowlessMapViewStateMocker::new, … … 368 407 * of {@link org.openstreetmap.josm.gui.NavigatableComponent}, null to skip. 369 408 * 370 409 * @return this instance, for easy chaining 410 * @deprecated Use {@link Main} instead 371 411 */ 412 @Deprecated 372 413 public JOSMTestRules main( 373 414 final Runnable mapViewStateMockingRunnable, 374 415 final Runnable navigableComponentMockingRunnable … … 397 438 return this; 398 439 } 399 440 400 private static class MockVersion extends Version { 401 MockVersion(final String propertiesString) { 441 /* 442 * Mock the JOSM version. This should only be used in JOSM Core test extensions. 443 */ 444 public static class MockVersion extends Version { 445 public MockVersion(final String propertiesString) { 402 446 super.initFromRevisionInfo( 403 447 new ByteArrayInputStream(propertiesString.getBytes(StandardCharsets.UTF_8)) 404 448 ); … … 409 453 public Statement apply(Statement base, Description description) { 410 454 // First process any Override* annotations for per-test overrides. 411 455 // The following only work because "option" methods modify JOSMTestRules in-place 412 finalOverrideAssumeRevision overrideAssumeRevision = description.getAnnotation(OverrideAssumeRevision.class);456 OverrideAssumeRevision overrideAssumeRevision = description.getAnnotation(OverrideAssumeRevision.class); 413 457 if (overrideAssumeRevision != null) { 414 458 this.assumeRevision(overrideAssumeRevision.value()); 415 459 } … … 790 834 /** 791 835 * Override this test's assumed JOSM version (as reported by {@link Version}). 792 836 * @see JOSMTestRules#assumeRevision(String) 837 * @deprecated Use {@link org.openstreetmap.josm.testutils.annotations.AssumeRevision} 838 * when using JUnit 5 Extensions. 793 839 */ 794 840 @Documented 795 841 @Retention(RetentionPolicy.RUNTIME) 796 842 @Target(ElementType.METHOD) 843 @Deprecated 797 844 public @interface OverrideAssumeRevision { 798 845 /** 799 846 * Returns overridden assumed JOSM version. -
test/unit/org/openstreetmap/josm/testutils/annotations/AnnotationUtils.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.testutils.annotations; 3 4 import java.lang.annotation.Annotation; 5 import java.lang.reflect.Field; 6 import java.lang.reflect.Modifier; 7 import java.util.Optional; 8 9 import org.junit.jupiter.api.extension.ExtensionContext; 10 import org.junit.platform.commons.support.AnnotationSupport; 11 12 /** 13 * Useful methods for annotation extensions 14 * @author Taylor Smock 15 * @since xxx 16 */ 17 final class AnnotationUtils { 18 private AnnotationUtils() { 19 // Utils class 20 } 21 22 /** 23 * Find the first parent annotation 24 * @param <T> The annotation to find 25 * @param context The context to search 26 * @param annotation The annotation to find 27 * @return See {@link AnnotationSupport#findAnnotation} 28 */ 29 public static <T extends Annotation> Optional<T> findFirstParentAnnotation(ExtensionContext context, Class<T> annotation) { 30 ExtensionContext current = context; 31 do { 32 Optional<T> foundAnnotation = AnnotationSupport.findAnnotation(current.getElement(), annotation); 33 if (foundAnnotation.isPresent()) { 34 return foundAnnotation; 35 } 36 current = current.getParent().orElse(null); 37 } while (current != null); 38 return Optional.empty(); 39 } 40 41 /** 42 * Reset a static class (all static fields are unset). If they are initialized as part of a static block, please be aware of NPEs. 43 * @param clazz The class to reset 44 * @throws ReflectiveOperationException If reflection doesn't work, for whatever reason. 45 */ 46 public static void resetStaticClass(Class<?> clazz) throws ReflectiveOperationException { 47 for (Field field : clazz.getDeclaredFields()) { 48 // Only reset static fields, but not final static fields 49 if ((field.getModifiers() & Modifier.STATIC) != 0 && (field.getModifiers() & Modifier.FINAL) == 0) { 50 if (!field.isAccessible()) { 51 field.setAccessible(true); 52 } 53 field.set(null, null); 54 } 55 } 56 } 57 } -
test/unit/org/openstreetmap/josm/testutils/annotations/AssertionsInEDT.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.testutils.annotations; 3 4 import static java.lang.annotation.ElementType.TYPE; 5 import static java.lang.annotation.RetentionPolicy.RUNTIME; 6 7 import java.lang.annotation.Documented; 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.BeforeEachCallback; 13 import org.junit.jupiter.api.extension.ExtensionContext; 14 import org.junit.platform.commons.support.AnnotationSupport; 15 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 import org.openstreetmap.josm.testutils.mockers.EDTAssertionMocker; 17 18 import mockit.MockUp; 19 20 /** 21 * Raise assertions in the EDT. 22 * @author Taylor Smock 23 * @see JOSMTestRules#assertionsInEDT 24 * @since xxx 25 */ 26 @Documented 27 @Retention(RUNTIME) 28 @Target(TYPE) 29 public @interface AssertionsInEDT { 30 /** 31 * Get the mocker to use for the EDT 32 * @return The mock 33 */ 34 Class<? extends MockUp<?>> value() default EDTAssertionMocker.class; 35 /** 36 * Initialize the mocker for the EDT 37 * @author Taylor Smock 38 * 39 */ 40 class AssertionsInEDTExtension implements BeforeEachCallback { 41 @Override 42 public void beforeEach(ExtensionContext context) throws Exception { 43 Optional<AssertionsInEDT> annotation = AnnotationSupport.findAnnotation(context.getElement(), AssertionsInEDT.class); 44 if (annotation.isPresent()) { 45 Class<? extends MockUp<?>> clazz = annotation.get().value(); 46 clazz.getConstructor().newInstance(); 47 } 48 } 49 } 50 } -
test/unit/org/openstreetmap/josm/testutils/annotations/AssumeRevision.java
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.junit.platform.commons.support.AnnotationSupport; 18 import org.openstreetmap.josm.TestUtils; 19 import org.openstreetmap.josm.data.Version; 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 22 23 /** 24 * Override this test's assumed JOSM version (as reported by {@link Version}). 25 * @author Taylor Smock 26 * @see JOSMTestRules#assumeRevision(String) 27 * @since xxx 28 */ 29 @Documented 30 @Retention(RetentionPolicy.RUNTIME) 31 @Target({ElementType.METHOD, ElementType.TYPE}) 32 @ExtendWith(AssumeRevision.AssumeRevisionExtension.class) 33 public @interface AssumeRevision { 34 /** 35 * Returns overridden assumed JOSM version. 36 * @return overridden assumed JOSM version 37 */ 38 String value(); 39 40 /** 41 * Override the JOSM revision information. Use {@link AssumeRevision} instead of directly using this extension. 42 * @author Taylor Smock 43 * @since xxx 44 */ 45 class AssumeRevisionExtension implements BeforeEachCallback, AfterEachCallback { 46 47 @Override 48 public void afterEach(ExtensionContext context) throws Exception { 49 Store store = context.getStore(Namespace.create(AssumeRevisionExtension.class)); 50 String originalVersion = store.getOrDefault(store, String.class, null); 51 if (originalVersion != null) { 52 TestUtils.setPrivateStaticField(Version.class, "instance", originalVersion); 53 } 54 } 55 56 @Override 57 public void beforeEach(ExtensionContext context) throws Exception { 58 Optional<AssumeRevision> annotation = AnnotationSupport.findAnnotation(context.getElement(), AssumeRevision.class); 59 if (annotation.isPresent()) { 60 Store store = context.getStore(Namespace.create(AssumeRevisionExtension.class)); 61 store.put("originalVersion", Version.getInstance()); 62 final Version replacementVersion = new JOSMTestRules.MockVersion(annotation.get().value()); 63 TestUtils.setPrivateStaticField(Version.class, "instance", replacementVersion); 64 } 65 } 66 } 67 } -
test/unit/org/openstreetmap/josm/testutils/annotations/BasicPreferences.java
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 10 import org.junit.jupiter.api.extension.AfterAllCallback; 11 import org.junit.jupiter.api.extension.BeforeAllCallback; 12 import org.junit.jupiter.api.extension.ExtendWith; 13 import org.junit.jupiter.api.extension.ExtensionContext; 14 import org.junit.jupiter.api.extension.ExtensionContext.Namespace; 15 import org.openstreetmap.josm.data.Preferences; 16 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 17 import org.openstreetmap.josm.data.preferences.JosmUrls; 18 import org.openstreetmap.josm.spi.preferences.Config; 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 21 /** 22 * Allow tests to use JOSM preferences (see {@link JOSMTestRules#preferences()}) 23 * @author Taylor Smock 24 * @see FullPreferences 25 * @since xxx 26 */ 27 @Documented 28 @Retention(RetentionPolicy.RUNTIME) 29 @Target(ElementType.TYPE) 30 @ExtendWith(BasicPreferences.BasicPreferencesExtension.class) 31 public @interface BasicPreferences { 32 33 /** 34 * Initialize basic preferences. This is often more than enough for basic tests. 35 * @author Taylor Smock 36 * 37 */ 38 class BasicPreferencesExtension implements BeforeAllCallback, AfterAllCallback { 39 @Override 40 public void afterAll(ExtensionContext context) throws Exception { 41 AnnotationUtils.resetStaticClass(Config.class); 42 } 43 44 @Override 45 public void beforeAll(ExtensionContext context) throws Exception { 46 Preferences pref = Preferences.main(); 47 Config.setPreferencesInstance(pref); 48 Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()); 49 Config.setUrlsProvider(JosmUrls.getInstance()); 50 context.getStore(Namespace.create(BasicPreferencesExtension.class)).put("preferences", pref); 51 } 52 } 53 } -
test/unit/org/openstreetmap/josm/testutils/annotations/DeleteCommandCallback.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.testutils.annotations; 3 4 import static java.lang.annotation.ElementType.TYPE; 5 import static java.lang.annotation.RetentionPolicy.RUNTIME; 6 7 import java.lang.annotation.Documented; 8 import java.lang.annotation.Retention; 9 import java.lang.annotation.Target; 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.openstreetmap.josm.actions.DeleteAction; 16 import org.openstreetmap.josm.command.DeleteCommand; 17 18 /** 19 * Initialize the DeleteCommand callback with the default callback. 20 * @author Taylor Smock 21 * @since xxx 22 */ 23 @Documented 24 @Retention(RUNTIME) 25 @Target(TYPE) 26 @ExtendWith(DeleteCommandCallback.DeleteCommandCallbackExtension.class) 27 public @interface DeleteCommandCallback { 28 /** 29 * Initialize and reset the DeleteCommand callback 30 * @author Taylor Smock 31 * 32 */ 33 class DeleteCommandCallbackExtension implements BeforeAllCallback, AfterAllCallback { 34 @Override 35 public void afterAll(ExtensionContext context) throws Exception { 36 AnnotationUtils.resetStaticClass(DeleteCommand.class); 37 } 38 39 @Override 40 public void beforeAll(ExtensionContext context) throws Exception { 41 DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback); 42 } 43 } 44 } -
test/unit/org/openstreetmap/josm/testutils/annotations/FullPreferences.java
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.Map; 10 11 import org.junit.jupiter.api.extension.BeforeEachCallback; 12 import org.junit.jupiter.api.extension.ExtendWith; 13 import org.junit.jupiter.api.extension.ExtensionContext; 14 import org.junit.jupiter.api.extension.ExtensionContext.Namespace; 15 import org.openstreetmap.josm.TestUtils; 16 import org.openstreetmap.josm.data.Preferences; 17 import org.openstreetmap.josm.spi.preferences.Config; 18 import org.openstreetmap.josm.spi.preferences.Setting; 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 import org.openstreetmap.josm.testutils.annotations.BasicPreferences.BasicPreferencesExtension; 21 22 /** 23 * Allow tests to use JOSM preferences (see {@link JOSMTestRules#preferences()}) 24 * @author Taylor Smock 25 * @see BasicPreferences (often enough for simple tests). 26 * @since xxx 27 */ 28 @Documented 29 @Retention(RetentionPolicy.RUNTIME) 30 @Target(ElementType.TYPE) 31 @JosmHome 32 @BasicPreferences 33 @ExtendWith(FullPreferences.UsePreferencesExtension.class) 34 public @interface FullPreferences { 35 /** 36 * Initialize preferences. 37 */ 38 class UsePreferencesExtension implements BeforeEachCallback { 39 @Override 40 public void beforeEach(ExtensionContext context) throws Exception { 41 Preferences pref = context.getStore(Namespace.create(BasicPreferencesExtension.class)).get("preferences", Preferences.class); 42 @SuppressWarnings("unchecked") 43 final Map<String, Setting<?>> defaultsMap = (Map<String, Setting<?>>) TestUtils.getPrivateField(pref, "defaultsMap"); 44 defaultsMap.clear(); 45 pref.resetToInitialState(); 46 pref.enableSaveOnPut(false); 47 // No pref init -> that would only create the preferences file. 48 // We force the use of a wrong API server, just in case anyone attempts an upload 49 Config.getPref().put("osm-server.url", "http://invalid"); 50 } 51 52 } 53 } -
test/unit/org/openstreetmap/josm/testutils/annotations/HTTP.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.testutils.annotations; 3 4 import static java.lang.annotation.ElementType.TYPE; 5 import static java.lang.annotation.RetentionPolicy.RUNTIME; 6 7 import java.lang.annotation.Documented; 8 import java.lang.annotation.Retention; 9 import java.lang.annotation.Target; 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.openstreetmap.josm.tools.Http1Client; 16 import org.openstreetmap.josm.tools.HttpClient; 17 18 /** 19 * Set up the HttpClient factory 20 * @author Taylor Smock 21 * @since xxx 22 */ 23 @Documented 24 @Retention(RUNTIME) 25 @Target(TYPE) 26 @ExtendWith(HTTP.HTTPExtension.class) 27 public @interface HTTP { 28 /** 29 * Initialize and reset HttpClient 30 * @author Taylor Smock 31 * 32 */ 33 class HTTPExtension implements BeforeAllCallback, AfterAllCallback { 34 @Override 35 public void afterAll(ExtensionContext context) throws Exception { 36 AnnotationUtils.resetStaticClass(HttpClient.class); 37 } 38 39 @Override 40 public void beforeAll(ExtensionContext context) throws Exception { 41 HttpClient.setFactory(Http1Client::new); 42 } 43 } 44 } -
test/unit/org/openstreetmap/josm/testutils/annotations/HTTPS.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.testutils.annotations; 3 4 import static java.lang.annotation.ElementType.TYPE; 5 import static java.lang.annotation.RetentionPolicy.RUNTIME; 6 7 import java.lang.annotation.Documented; 8 import java.lang.annotation.Retention; 9 import java.lang.annotation.Target; 10 11 import org.junit.jupiter.api.extension.BeforeAllCallback; 12 import org.junit.jupiter.api.extension.ExtendWith; 13 import org.junit.jupiter.api.extension.ExtensionContext; 14 import org.openstreetmap.josm.io.CertificateAmendment; 15 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 17 /** 18 * Set up HTTPS certificates 19 * 20 * @author Taylor Smock 21 * @see JOSMTestRules#https 22 * @since xxx 23 */ 24 @Documented 25 @Retention(RUNTIME) 26 @Target(TYPE) 27 @BasicPreferences 28 @ExtendWith(HTTPS.HTTPSExtension.class) 29 public @interface HTTPS { 30 31 /** 32 * Set up HTTPS certificates. Only run once. 33 * @author Taylor Smock 34 */ 35 class HTTPSExtension implements BeforeAllCallback { 36 private static boolean initialized; 37 @Override 38 public void beforeAll(ExtensionContext context) throws Exception { 39 if (!initialized) { 40 synchronized (HTTPSExtension.class) { 41 CertificateAmendment.addMissingCertificates(); 42 initialized = true; 43 } 44 } 45 } 46 47 } 48 } -
test/unit/org/openstreetmap/josm/testutils/annotations/I18n.java
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.BeforeAllCallback; 12 import org.junit.jupiter.api.extension.ExtendWith; 13 import org.junit.jupiter.api.extension.ExtensionContext; 14 import org.junit.platform.commons.support.AnnotationSupport; 15 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 17 /** 18 * Enables the i18n module for this test. 19 * @author Taylor Smock 20 * @see JOSMTestRules#i18n(String) 21 * 22 */ 23 @Documented 24 @Retention(RetentionPolicy.RUNTIME) 25 @Target(ElementType.TYPE) 26 @ExtendWith(I18n.I18nExtension.class) 27 public @interface I18n { 28 /** 29 * Get the language to use for i18n 30 * @return The language (default "en"). 31 */ 32 String language() default "en"; 33 34 /** 35 * Enables the i18n module for this test. 36 * @author Taylor Smock 37 * @see JOSMTestRules#i18n(String) 38 * 39 */ 40 class I18nExtension implements BeforeAllCallback { 41 @Override 42 public void beforeAll(ExtensionContext context) throws Exception { 43 Optional<I18n> annotation = AnnotationSupport.findAnnotation(context.getElement(), I18n.class); 44 String language = "en"; 45 if (annotation.isPresent()) { 46 language = annotation.get().language(); 47 } 48 org.openstreetmap.josm.tools.I18n.set(language); 49 } 50 } 51 } -
test/unit/org/openstreetmap/josm/testutils/annotations/IntegrationTest.java
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 } -
test/unit/org/openstreetmap/josm/testutils/annotations/JosmHome.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.testutils.annotations; 3 4 import java.io.File; 5 import java.io.IOException; 6 import java.lang.annotation.Documented; 7 import java.lang.annotation.ElementType; 8 import java.lang.annotation.Retention; 9 import java.lang.annotation.RetentionPolicy; 10 import java.lang.annotation.Target; 11 import java.nio.file.FileVisitResult; 12 import java.nio.file.Files; 13 import java.nio.file.Path; 14 import java.nio.file.SimpleFileVisitor; 15 import java.nio.file.attribute.BasicFileAttributes; 16 import java.util.UUID; 17 18 import org.junit.jupiter.api.extension.AfterAllCallback; 19 import org.junit.jupiter.api.extension.BeforeAllCallback; 20 import org.junit.jupiter.api.extension.ExtendWith; 21 import org.junit.jupiter.api.extension.ExtensionContext; 22 import org.junit.jupiter.api.extension.ExtensionContext.Namespace; 23 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 24 import org.openstreetmap.josm.testutils.JOSMTestRules; 25 26 /** 27 * Use the JOSM home directory. See {@link JOSMTestRules}. 28 * Typically only used by {@link FullPreferences}. 29 * 30 * @author Taylor Smock 31 * 32 */ 33 @Documented 34 @Retention(RetentionPolicy.RUNTIME) 35 @Target(ElementType.TYPE) 36 @ExtendWith(JosmHome.JosmHomeExtension.class) 37 public @interface JosmHome { 38 /** 39 * Create a JOSM home directory. Prefer using {@link JosmHome}. 40 * @author Taylor Smock 41 */ 42 class JosmHomeExtension implements BeforeAllCallback, AfterAllCallback { 43 @Override 44 public void afterAll(ExtensionContext context) throws Exception { 45 Path tempDir = context.getStore(Namespace.create(JosmHome.class)).get("home", Path.class); 46 Files.walkFileTree(tempDir, new SimpleFileVisitor<Path>() { 47 @Override 48 public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { 49 Files.delete(dir); 50 return FileVisitResult.CONTINUE; 51 } 52 53 @Override 54 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { 55 Files.delete(file); 56 return FileVisitResult.CONTINUE; 57 } 58 }); 59 } 60 61 @Override 62 public void beforeAll(ExtensionContext context) throws Exception { 63 Path tempDir = Files.createTempDirectory(UUID.randomUUID().toString()); 64 context.getStore(Namespace.create(JosmHome.class)).put("home", tempDir); 65 File home = tempDir.toFile(); 66 System.setProperty("josm.home", home.getAbsolutePath()); 67 JosmBaseDirectories.getInstance().clearMemos(); 68 } 69 } 70 } -
test/unit/org/openstreetmap/josm/testutils/annotations/LayerEnvironment.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.testutils.annotations; 3 4 import static java.lang.annotation.ElementType.TYPE; 5 import static java.lang.annotation.RetentionPolicy.RUNTIME; 6 7 import java.lang.annotation.Documented; 8 import java.lang.annotation.Retention; 9 import java.lang.annotation.Target; 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.openstreetmap.josm.testutils.JOSMTestRules; 16 17 /** 18 * Clean up layers before/after the tests 19 * @author Taylor Smock 20 * @see JOSMTestRules#cleanLayerEnvironment() 21 * @since xxx 22 */ 23 @Documented 24 @Retention(RUNTIME) 25 @Target(TYPE) 26 @ExtendWith(LayerEnvironment.LayerEnvironmentExtension.class) 27 public @interface LayerEnvironment { 28 /** 29 * Clean up layers 30 * @author Taylor Smock 31 * 32 */ 33 class LayerEnvironmentExtension implements BeforeEachCallback, AfterEachCallback { 34 @Override 35 public void afterEach(ExtensionContext context) throws Exception { 36 beforeEach(context); 37 } 38 39 @Override 40 public void beforeEach(ExtensionContext context) throws Exception { 41 JOSMTestRules.cleanLayerEnvironment(); 42 } 43 } 44 } -
test/unit/org/openstreetmap/josm/testutils/annotations/Main.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.testutils.annotations; 3 4 import static java.lang.annotation.ElementType.TYPE; 5 import static java.lang.annotation.RetentionPolicy.RUNTIME; 6 7 import java.lang.annotation.Documented; 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.AfterAllCallback; 13 import org.junit.jupiter.api.extension.BeforeAllCallback; 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(TYPE) 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 * Get the class to use for the navigable component 43 * @return The class to use for the navigable component. 44 */ 45 Class<?> navigableComponentMocker() default WindowlessNavigatableComponentMocker.class; 46 47 /** 48 * Initialize the MainApplication 49 * @author Taylor Smock 50 */ 51 class MainExtension implements BeforeAllCallback, AfterAllCallback { 52 @Override 53 public void afterAll(ExtensionContext context) throws Exception { 54 MainApplication.getLayerManager().resetState();; 55 AnnotationUtils.resetStaticClass(MainApplication.class); 56 } 57 58 @Override 59 public void beforeAll(ExtensionContext context) throws Exception { 60 Optional<Main> annotation = AnnotationSupport.findAnnotation(context.getElement(), Main.class); 61 Class<?> mapViewStateMocker = null; 62 Class<?> navigableComponentMocker = null; 63 if (annotation.isPresent()) { 64 mapViewStateMocker = annotation.get().mapViewStateMocker(); 65 navigableComponentMocker = annotation.get().navigableComponentMocker(); 66 } 67 68 // apply mockers to MapViewState and NavigableComponent whether we're headless or not 69 // as we generally don't create the josm main window even in non-headless mode. 70 if (mapViewStateMocker != null) { 71 mapViewStateMocker.getConstructor().newInstance(); 72 } 73 if (navigableComponentMocker != null) { 74 navigableComponentMocker.getConstructor().newInstance(); 75 } 76 77 new MainApplication(); 78 JOSMFixture.initContentPane(); 79 JOSMFixture.initMainPanel(true); 80 JOSMFixture.initToolbar(); 81 JOSMFixture.initMainMenu(); 82 } 83 } 84 } -
test/unit/org/openstreetmap/josm/testutils/annotations/OsmApiType.java
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.BeforeAllCallback; 14 import org.junit.jupiter.api.extension.BeforeEachCallback; 15 import org.junit.jupiter.api.extension.ExtendWith; 16 import org.junit.jupiter.api.extension.ExtensionContext; 17 import org.openstreetmap.josm.io.OsmApi; 18 import org.openstreetmap.josm.spi.preferences.Config; 19 import org.openstreetmap.josm.testutils.FakeOsmApi; 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 22 /** 23 * Specify the OSM API to use for the test. {@link APIType#NONE} has no effect. 24 * 25 * @author Taylor Smock 26 * @see JOSMTestRules#devAPI() 27 * @see JOSMTestRules#fakeAPI() 28 * @since xxx 29 */ 30 @Documented 31 @Retention(RUNTIME) 32 @Target({ TYPE, METHOD }) 33 @FullPreferences 34 @HTTP 35 @ExtendWith(OsmApiType.OsmApiTypeExtension.class) 36 public @interface OsmApiType { 37 /** 38 * API types to initialize 39 * @author Taylor Smock 40 * 41 */ 42 enum APIType { 43 NONE, FAKE, DEV; 44 } 45 46 /** 47 * The API type to use 48 * @return The API type to use (default NONE) 49 */ 50 APIType apiType() default APIType.NONE; 51 52 /** 53 * Initialize the OSM api 54 * @author Taylor Smock 55 * 56 */ 57 class OsmApiTypeExtension implements BeforeAllCallback, BeforeEachCallback { 58 59 @Override 60 public void beforeEach(ExtensionContext context) throws Exception { 61 Optional<OsmApiType> annotation = AnnotationUtils.findFirstParentAnnotation(context, OsmApiType.class); 62 APIType useAPI = APIType.NONE; 63 if (annotation.isPresent()) { 64 useAPI = annotation.get().apiType(); 65 } 66 // Set API 67 if (useAPI == APIType.DEV) { 68 Config.getPref().put("osm-server.url", "https://api06.dev.openstreetmap.org/api"); 69 } else if (useAPI == APIType.FAKE) { 70 FakeOsmApi api = FakeOsmApi.getInstance(); 71 Config.getPref().put("osm-server.url", api.getServerUrl()); 72 } 73 74 // Initialize API 75 if (useAPI != APIType.NONE) { 76 OsmApi.getOsmApi().initialize(null); 77 } 78 } 79 80 @Override 81 public void beforeAll(ExtensionContext context) throws Exception { 82 beforeEach(context); 83 } 84 85 } 86 } -
test/unit/org/openstreetmap/josm/testutils/annotations/Presets.java
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 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.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 17 import org.openstreetmap.josm.testutils.JOSMTestRules; 18 19 /** 20 * Use presets in this test. 21 * 22 * @author Taylor Smock 23 * @see JOSMTestRules#presets() 24 * @since xxx 25 */ 26 @Documented 27 @Retention(RUNTIME) 28 @Target({ TYPE, METHOD }) 29 @ExtendWith(Presets.PresetsExtension.class) 30 public @interface Presets { 31 /** 32 * Initialize the presets 33 * @author Taylor Smock 34 * 35 */ 36 class PresetsExtension implements BeforeAllCallback, BeforeEachCallback { 37 @Override 38 public void beforeAll(ExtensionContext context) throws Exception { 39 TaggingPresets.readFromPreferences(); 40 } 41 42 @Override 43 public void beforeEach(ExtensionContext context) throws Exception { 44 // TODO only run if method level 45 beforeAll(context); 46 } 47 } 48 } -
test/unit/org/openstreetmap/josm/testutils/annotations/Projection.java
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 } -
test/unit/org/openstreetmap/josm/testutils/annotations/ProjectionNadGrids.java
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 10 import org.junit.jupiter.api.extension.BeforeAllCallback; 11 import org.junit.jupiter.api.extension.ExtendWith; 12 import org.junit.jupiter.api.extension.ExtensionContext; 13 import org.openstreetmap.josm.gui.MainApplication; 14 import org.openstreetmap.josm.testutils.JOSMTestRules; 15 16 /** 17 * Set up loading of NTV2 grit shift files to support projections that need them. 18 * @author Taylor Smock 19 * @see JOSMTestRules#projectionNadGrids() 20 * @since xxx 21 */ 22 @Documented 23 @Retention(RetentionPolicy.RUNTIME) 24 @Target(ElementType.TYPE) 25 @ExtendWith(ProjectionNadGrids.ProjectionNadGridsExtension.class) 26 public @interface ProjectionNadGrids { 27 /** 28 * Set up loading of NTV2 grit shift files to support projections that need them. 29 * Use {@link ProjectionNadGrids} instead. 30 * @author Taylor Smock 31 * @see JOSMTestRules#projectionNadGrids() 32 */ 33 class ProjectionNadGridsExtension implements BeforeAllCallback { 34 @Override 35 public void beforeAll(ExtensionContext context) throws Exception { 36 MainApplication.setupNadGridSources(); 37 } 38 } 39 } -
test/unit/org/openstreetmap/josm/testutils/annotations/SlowTest.java
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 * Use for any test which takes longer than 1 minute 15 * @author Taylor Smock 16 * @since xxx 17 */ 18 @Documented 19 @Retention(RUNTIME) 20 @Target({ElementType.TYPE, ElementType.METHOD}) 21 @Tag("slowTest") 22 public @interface SlowTest { 23 24 } -
test/unit/org/openstreetmap/josm/testutils/annotations/Territories.java
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 @ExtendWith(Territories.TerritoriesExtension.class) 29 public @interface Territories { 30 /** 31 * Initialization states. Please note that the highest initialization state holds. 32 * @author Taylor Smock 33 */ 34 enum Initialize { 35 /** Don't initialize */ 36 NONE, 37 /** Initialize only internal data */ 38 INTERNAL, 39 /** Initialize internal and external data */ 40 ALL 41 } 42 43 /** 44 * The way to initialize Territories 45 * @return The value to use 46 */ 47 Initialize value() default Initialize.INTERNAL; 48 49 /** 50 * Initialize boundaries prior to use 51 * @author Taylor Smock 52 * 53 */ 54 class TerritoriesExtension implements BeforeAllCallback, AfterAllCallback { 55 @Override 56 public void afterAll(ExtensionContext context) throws Exception { 57 synchronized (TerritoriesExtension.class) { 58 org.openstreetmap.josm.tools.Territories.uninitialize(); 59 } 60 } 61 62 @Override 63 public void beforeAll(ExtensionContext context) throws Exception { 64 Optional<Territories> annotation = AnnotationSupport.findAnnotation(context.getElement(), Territories.class); 65 if (annotation.isPresent()) { 66 Initialize current = annotation.get().value(); 67 // Avoid potential race conditions if tests are parallelized 68 synchronized (TerritoriesExtension.class) { 69 if (current == Initialize.INTERNAL) { 70 org.openstreetmap.josm.tools.Territories.initializeInternalData(); 71 } else if (current == Initialize.ALL) { 72 org.openstreetmap.josm.tools.Territories.initialize(); 73 } 74 } 75 } 76 } 77 } 78 } -
test/unit/org/openstreetmap/josm/testutils/annotations/TimeZoneAnnotation.java
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.TimeZone; 11 12 import org.junit.jupiter.api.extension.AfterAllCallback; 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.openstreetmap.josm.tools.date.DateUtils; 17 18 /** 19 * Set the default timezone 20 * @author Taylor Smock 21 * @since xxx 22 */ 23 @Documented 24 @Retention(RUNTIME) 25 @Target({ElementType.TYPE, ElementType.METHOD}) 26 @ExtendWith(TimeZoneAnnotation.TimeZoneExtension.class) 27 public @interface TimeZoneAnnotation { 28 /** 29 * Set the default timezone 30 * @author Taylor Smock 31 */ 32 class TimeZoneExtension implements BeforeEachCallback, AfterAllCallback { 33 @Override 34 public void afterAll(ExtensionContext context) { 35 TimeZone.setDefault(null); 36 TimeZone.getDefault().getDisplayName(); 37 } 38 39 @Override 40 public void beforeEach(ExtensionContext context) throws Exception { 41 TimeZone.setDefault(DateUtils.UTC); 42 } 43 } 44 } -
test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java
12 12 13 13 import org.junit.jupiter.api.BeforeEach; 14 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension;16 15 import org.openstreetmap.josm.io.ChangesetClosedException; 17 16 import org.openstreetmap.josm.io.IllegalDataException; 18 17 import org.openstreetmap.josm.io.MissingOAuthAccessTokenException; … … 21 20 import org.openstreetmap.josm.io.OsmApiException; 22 21 import org.openstreetmap.josm.io.OsmApiInitializationException; 23 22 import org.openstreetmap.josm.io.auth.CredentialsManager; 24 import org.openstreetmap.josm.testutils.JOSMTestRules; 23 import org.openstreetmap.josm.testutils.annotations.FullPreferences; 24 import org.openstreetmap.josm.testutils.annotations.OsmApiType; 25 25 import org.openstreetmap.josm.tools.date.DateUtils; 26 26 import org.openstreetmap.josm.tools.date.DateUtilsTest; 27 27 28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;29 30 28 /** 31 29 * Unit tests of {@link ExceptionUtil} class. 32 30 */ 31 @FullPreferences 32 @OsmApiType(apiType = OsmApiType.APIType.FAKE) 33 33 class ExceptionUtilTest { 34 35 /**36 * Setup rule.37 */38 @RegisterExtension39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")40 public JOSMTestRules test = new JOSMTestRules().preferences().fakeAPI();41 42 34 private static String baseUrl; 43 35 private static String serverUrl; 44 36 private static String host; -
test/unit/org/openstreetmap/josm/tools/GeometryTest.java
14 14 import java.util.List; 15 15 16 16 import org.junit.Assert; 17 import org.junit.jupiter.api.extension.RegisterExtension;18 17 import org.junit.jupiter.api.Test; 19 18 import org.openstreetmap.josm.TestUtils; 20 19 import org.openstreetmap.josm.data.coor.EastNorth; … … 27 26 import org.openstreetmap.josm.data.osm.Way; 28 27 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 29 28 import org.openstreetmap.josm.io.OsmReader; 30 import org.openstreetmap.josm.testutils.JOSMTestRules; 29 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 30 import org.openstreetmap.josm.testutils.annotations.Projection; 31 31 32 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;33 34 32 /** 35 33 * Unit tests of {@link Geometry} class. 36 34 */ 35 @BasicPreferences // For primitives 36 @Projection // For primitives 37 37 class GeometryTest { 38 38 /** 39 * Primitives need preferences and projection.40 */41 @RegisterExtension42 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")43 public JOSMTestRules test = new JOSMTestRules().preferences().projection();44 45 /**46 39 * Test of {@link Geometry#getLineLineIntersection} method. 47 40 */ 48 41 @Test -
test/unit/org/openstreetmap/josm/tools/OptionParserTest.java
3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.junit.jupiter.api.Assertions.assertThrows;8 8 9 9 import java.util.ArrayList; 10 10 import java.util.Arrays; … … 12 12 import java.util.concurrent.atomic.AtomicBoolean; 13 13 import java.util.concurrent.atomic.AtomicReference; 14 14 15 import org.junit.jupiter.api.extension.RegisterExtension;16 15 import org.junit.jupiter.api.Test; 17 import org.openstreetmap.josm.testutils.JOSMTestRules;18 16 import org.openstreetmap.josm.tools.OptionParser.OptionCount; 19 17 import org.openstreetmap.josm.tools.OptionParser.OptionParseException; 20 18 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;22 23 19 /** 24 20 * Test for {@link OptionParser} 25 21 * @author Michael Zangl 26 22 */ 27 23 class OptionParserTest { 28 /**29 * Setup test.30 */31 @RegisterExtension32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")33 public JOSMTestRules test = new JOSMTestRules().i18n();34 35 24 // A reason for moving to jupiter... 36 25 @Test 37 26 void testEmptyParserRejectsLongopt() { -
test/unit/org/openstreetmap/josm/tools/SearchCompilerQueryWizardTest.java
6 6 7 7 import org.junit.jupiter.api.Disabled; 8 8 import org.junit.jupiter.api.Test; 9 import org.junit.jupiter.api.extension.RegisterExtension; 10 import org.openstreetmap.josm.testutils.JOSMTestRules; 9 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 11 10 12 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;13 14 11 /** 15 12 * Unit tests of {@link SearchCompilerQueryWizard} class. 16 13 */ 14 @org.openstreetmap.josm.testutils.annotations.I18n(language = "de") 15 @BasicPreferences // Due to OsmPrimitives being used 17 16 class SearchCompilerQueryWizardTest { 18 /**19 * Base test environment is enough20 */21 @RegisterExtension22 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")23 public JOSMTestRules test = new JOSMTestRules().i18n("de");24 25 17 private static String constructQuery(String s) { 26 18 return SearchCompilerQueryWizard.constructQuery(s); 27 19 } -
test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java
10 10 import java.util.List; 11 11 import java.util.Map; 12 12 13 import org.junit.jupiter.api.extension.RegisterExtension;14 13 import org.junit.jupiter.api.Test; 15 import org.openstreetmap.josm.testutils. JOSMTestRules;14 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 16 15 17 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;18 19 16 /** 20 17 * Unit tests of {@link TextTagParser} class. 21 18 */ 19 @BasicPreferences 22 20 class TextTagParserTest { 23 21 /** 24 * Some of this depends on preferences.25 */26 @RegisterExtension27 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")28 public JOSMTestRules test = new JOSMTestRules().preferences();29 30 /**31 22 * Test of {@link TextTagParser#unescape} method. 32 23 */ 33 24 @Test -
test/unit/org/openstreetmap/josm/tools/UtilsTest.java
22 22 import java.util.regex.Pattern; 23 23 24 24 import org.junit.jupiter.api.Test; 25 import org.junit.jupiter.api.extension.RegisterExtension;26 import org.openstreetmap.josm.testutils.JOSMTestRules;27 25 28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;29 26 import net.trajano.commons.testing.UtilityClassTestUtil; 30 27 31 28 /** … … 33 30 */ 34 31 class UtilsTest { 35 32 /** 36 * Use default, basic test rules.37 */38 @RegisterExtension39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")40 public JOSMTestRules rules = new JOSMTestRules();41 42 /**43 33 * Tests that {@code Utils} satisfies utility class criteria. 44 34 * @throws ReflectiveOperationException if an error occurs 45 35 */ -
test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
16 16 17 17 import org.junit.jupiter.api.Disabled; 18 18 import org.junit.jupiter.api.Test; 19 import org. junit.jupiter.api.extension.RegisterExtension;20 import org.openstreetmap.josm.testutils. JOSMTestRules;19 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 20 import org.openstreetmap.josm.testutils.annotations.TimeZoneAnnotation; 21 21 import org.openstreetmap.josm.tools.UncheckedParseException; 22 22 23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;24 23 import net.trajano.commons.testing.UtilityClassTestUtil; 25 24 26 25 /** 27 26 * Unit tests of {@link DateUtils} class. 28 27 */ 28 @TimeZoneAnnotation 29 @BasicPreferences 29 30 public class DateUtilsTest { 30 31 31 /** 32 * Set the timezone and timeout.33 * <p>34 * Timeouts need to be disabled because we change the time zone.35 */36 @RegisterExtension37 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")38 public JOSMTestRules test = new JOSMTestRules().i18n().preferences();39 40 /**41 32 * Tests that {@code DateUtils} satisfies utility class criteria. 42 33 * @throws ReflectiveOperationException if an error occurs 43 34 */
