Changeset 18799 in josm
- Timestamp:
- 2023-08-08T21:24:36+02:00 (16 months ago)
- Location:
- trunk/test
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/performance/org/openstreetmap/josm/data/validation/ValidationTaskPerformanceTest.java
r17617 r18799 2 2 package org.openstreetmap.josm.data.validation; 3 3 4 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 4 import static org.junit.jupiter.api.Assertions.assertTrue; 5 6 import java.util.Collection; 7 import java.util.List; 8 import java.util.stream.Collectors; 9 5 10 import org.junit.jupiter.api.BeforeEach; 6 11 import org.junit.jupiter.api.Test; 7 import org.junit.jupiter.api.extension.RegisterExtension;8 12 import org.openstreetmap.josm.PerformanceTestUtils; 9 13 import org.openstreetmap.josm.data.osm.DataSet; … … 13 17 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 14 18 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 15 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 17 import java.util.Collection; 18 import java.util.List; 19 import java.util.stream.Collectors; 20 21 import static org.junit.jupiter.api.Assertions.assertTrue; 19 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 20 import org.openstreetmap.josm.testutils.annotations.Projection; 21 import org.openstreetmap.josm.testutils.annotations.Territories; 22 22 23 23 /** 24 24 * Performance test of {@code ValidationTask}. 25 25 */ 26 @BasicPreferences 27 @Projection 28 @Territories 26 29 class ValidationTaskPerformanceTest { 27 30 28 31 private List<org.openstreetmap.josm.data.validation.Test> tests; 29 30 /**31 * Setup test.32 */33 @RegisterExtension34 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")35 public JOSMTestRules test = new JOSMTestRules().projection().territories().preferences();36 32 37 33 /** -
trunk/test/performance/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerPerformanceTest.java
r17617 r18799 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;5 4 import org.junit.jupiter.api.BeforeEach; 6 5 import org.junit.jupiter.api.Test; 7 import org.junit.jupiter.api.extension.RegisterExtension;8 6 import org.openstreetmap.josm.PerformanceTestUtils; 9 7 import org.openstreetmap.josm.data.osm.DataSet; 10 import org.openstreetmap.josm.testutils.JOSMTestRules; 8 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 9 import org.openstreetmap.josm.testutils.annotations.Projection; 10 import org.openstreetmap.josm.testutils.annotations.Territories; 11 11 12 12 /** 13 13 * Performance test of {@code MapCSSTagChecker}. 14 14 */ 15 @BasicPreferences 16 @Projection 17 @Territories 15 18 class MapCSSTagCheckerPerformanceTest { 16 19 17 20 private MapCSSTagChecker tagChecker; 18 21 private DataSet dsCity; 19 20 /**21 * Setup test.22 */23 @RegisterExtension24 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")25 public JOSMTestRules test = new JOSMTestRules().projection().territories().preferences();26 22 27 23 /** -
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r18562 r18799 8 8 import static org.junit.jupiter.api.Assertions.fail; 9 9 import static org.junit.jupiter.api.Assumptions.assumeFalse; 10 import static org.junit.jupiter.api.Assumptions.assumeTrue; 10 11 11 12 import java.awt.Component; … … 75 76 */ 76 77 public final class TestUtils { 78 private static Boolean workingJMockit; 77 79 78 80 private TestUtils() { … … 515 517 @SuppressWarnings("null") 516 518 public static void assumeWorkingJMockit() { 517 try { 518 // Workaround to https://github.com/jmockit/jmockit1/issues/534 519 // Inspired by https://issues.apache.org/jira/browse/SOLR-11606 520 new WindowMocker(); 521 new JOptionPaneSimpleMocker(); 522 } catch (UnsupportedOperationException e) { 523 assumeFalse(e != null); 524 } finally { 525 TestRunnerDecorator.cleanUpAllMocks(); 526 } 519 if (workingJMockit == null) { 520 try { 521 // Workaround to https://github.com/jmockit/jmockit1/issues/534 522 // Inspired by https://issues.apache.org/jira/browse/SOLR-11606 523 new WindowMocker(); 524 new JOptionPaneSimpleMocker(); 525 workingJMockit = true; 526 } catch (UnsupportedOperationException e) { 527 workingJMockit = false; 528 } finally { 529 TestRunnerDecorator.cleanUpAllMocks(); 530 } 531 } 532 assumeTrue(workingJMockit); 527 533 } 528 534 -
trunk/test/unit/org/openstreetmap/josm/actions/SessionSaveActionTest.java
r18690 r18799 12 12 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.gui.MainApplication; … … 18 17 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 19 18 import org.openstreetmap.josm.io.session.SessionWriterTest; 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 19 import org.openstreetmap.josm.testutils.annotations.Main; 20 import org.openstreetmap.josm.testutils.annotations.Projection; 21 21 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 22 23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;24 22 25 23 /** 26 24 * Unit tests for class {@link SessionSaveAsAction}. 27 25 */ 26 @Main 27 @Projection 28 28 class SessionSaveActionTest { 29 /**30 * Setup test.31 */32 @RegisterExtension33 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")34 public JOSMTestRules test = new JOSMTestRules().main().projection();35 36 29 /** 37 30 * Unit test of {@link SessionSaveAction} -
trunk/test/unit/org/openstreetmap/josm/actions/UploadActionTest.java
r18485 r18799 10 10 import java.util.concurrent.TimeUnit; 11 11 12 import org.junit.jupiter.api.BeforeAll;13 12 import org.junit.jupiter.api.Test; 14 13 import org.junit.jupiter.api.extension.RegisterExtension; … … 25 24 import org.openstreetmap.josm.testutils.JOSMTestRules; 26 25 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 26 import org.openstreetmap.josm.testutils.annotations.Main; 27 import org.openstreetmap.josm.testutils.annotations.Projection; 28 import org.openstreetmap.josm.testutils.annotations.Territories; 27 29 import org.openstreetmap.josm.testutils.mockers.WindowMocker; 28 30 import org.openstreetmap.josm.tools.Logging; 29 import org.openstreetmap.josm.tools.Territories;30 31 31 32 import mockit.Invocation; … … 38 39 */ 39 40 @BasicPreferences 41 @Main 42 @Projection 43 // Territories is needed due to test pollution. One of the listeners 44 // that may get registered on SelectionEventManager requires 45 // Territories. Rather unfortunately, we also need the external data to 46 // avoid the NPE. 47 @Territories(Territories.Initialize.ALL) 40 48 class UploadActionTest { 41 49 // Only needed for layer cleanup. And user identity cleanup. And ensuring that data isn't accidentally uploaded. 42 50 // Note that the setUp method can be replaced by the @Territories extension, when that is merged. 43 51 @RegisterExtension 44 static JOSMTestRules josmTestRules = new JOSMTestRules().main().projection().fakeAPI(); 45 46 @BeforeAll 47 static void setUp() { 48 // Territories is needed due to test pollution. One of the listeners 49 // that may get registered on SelectionEventManager requires 50 // Territories. Rather unfortunately, we also need the external data to 51 // avoid the NPE. 52 Territories.initialize(); 53 } 52 static JOSMTestRules josmTestRules = new JOSMTestRules().fakeAPI(); 54 53 55 54 /** -
trunk/test/unit/org/openstreetmap/josm/data/validation/ValidatorCLITest.java
r18723 r18799 67 67 68 68 TestHandler handler; 69 private ValidatorCLI validatorCLI; 69 70 70 71 @BeforeEach … … 74 75 this.handler = new TestHandler(); 75 76 Logging.getLogger().addHandler(this.handler); 77 validatorCLI = new ValidatorCLI(); 76 78 } 77 79 … … 86 88 @ValueSource(strings = {"resources/styles/standard/elemstyles.mapcss", "resources/styles/standard/potlatch2.mapcss"}) 87 89 void testInternalMapcss(final String resourceLocation) { 88 new ValidatorCLI().processArguments(new String[]{"--input", resourceLocation});90 validatorCLI.processArguments(new String[]{"--input", resourceLocation}); 89 91 assertEquals(2, this.handler.logRecordList.size()); 90 92 assertEquals(resourceLocation + " had no errors", this.handler.logRecordList.get(0).getMessage()); … … 111 113 void testInternalValidatorMapcss(final String resourceLocation) { 112 114 final String path = Paths.get(temporaryDirectory.getPath(), resourceLocation).toString(); 113 new ValidatorCLI().processArguments(new String[]{"--input", path});115 validatorCLI.processArguments(new String[]{"--input", path}); 114 116 assertEquals(2, this.handler.logRecordList.size(), this.handler.logRecordList.stream().map(LogRecord::getMessage).collect( 115 117 Collectors.joining(",\n"))); … … 123 125 final String dataPath = TestUtils.getRegressionDataFile(13165, "13165.osm"); 124 126 final String outputPath = Paths.get(temporaryDirectory.getPath(), "testBadDataTicket13165.geojson").toString(); 125 new ValidatorCLI().processArguments(new String[]{"--input", dataPath, "--output", outputPath});127 validatorCLI.processArguments(new String[]{"--input", dataPath, "--output", outputPath}); 126 128 final File outputFile = new File(outputPath); 127 129 assertTrue(outputFile.exists()); … … 134 136 @Test 135 137 void testBadDataPlusChangeFile() throws IOException { 136 final ValidatorCLI validatorCLI = new ValidatorCLI();137 138 // Write test data out 138 139 final String osmPath = Paths.get(temporaryDirectory.getPath(), "testBadDataPlusChangeFile.osm").toString(); … … 172 173 void testNonRegression22898(final @TempDir Path preferencesLocation) throws IOException, ReflectiveOperationException { 173 174 AnnotationUtils.resetStaticClass(Config.class); 174 final ValidatorCLI validatorCLI = new ValidatorCLI();175 175 final Path preferences = preferencesLocation.resolve("preferences.xml"); 176 176 try (OutputStream fos = Files.newOutputStream(preferences)) { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r18761 r18799 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.TestUtils; 23 22 import org.openstreetmap.josm.command.ChangePropertyCommand; … … 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;46 44 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 47 45 import org.openstreetmap.josm.testutils.annotations.Projection; 46 import org.openstreetmap.josm.testutils.annotations.Territories; 48 47 import org.openstreetmap.josm.tools.Logging; 49 50 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;51 48 52 49 /** … … 55 52 @BasicPreferences 56 53 @Projection 54 @Territories 57 55 class MapCSSTagCheckerTest { 58 59 /**60 * Setup test.61 */62 @RegisterExtension63 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")64 public JOSMTestRules test = new JOSMTestRules().territories();65 66 56 /** 67 57 * Setup test. -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UntaggedNodeTest.java
r17275 r18799 8 8 import java.io.InputStream; 9 9 10 import org.junit.jupiter.api.extension.RegisterExtension;11 10 import org.junit.jupiter.api.Test; 12 11 import org.openstreetmap.josm.TestUtils; … … 14 13 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 15 14 import org.openstreetmap.josm.io.OsmReader; 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 15 import org.openstreetmap.josm.testutils.annotations.Projection; 19 16 20 17 /** 21 18 * Unit tests of {@code UntaggedNode} class. 22 19 */ 20 @Projection 23 21 class UntaggedNodeTest { 24 22 25 23 private final UntaggedNode test = new UntaggedNode(); 26 27 /**28 * Setup test.29 */30 @RegisterExtension31 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")32 public JOSMTestRules rules = new JOSMTestRules();33 24 34 25 /** -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelperTest.java
r17275 r18799 21 21 import javax.swing.table.DefaultTableModel; 22 22 23 import org.junit.jupiter.api.extension.RegisterExtension;24 23 import org.junit.jupiter.api.Test; 25 24 import org.openstreetmap.josm.TestUtils; … … 36 35 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 37 36 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 38 import org.openstreetmap.josm.testutils.JOSMTestRules; 37 import org.openstreetmap.josm.testutils.annotations.Projection; 38 import org.openstreetmap.josm.testutils.annotations.Territories; 39 39 import org.openstreetmap.josm.testutils.mockers.WindowMocker; 40 41 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;42 40 43 41 /** 44 42 * Unit tests of {@link TagEditHelper} class. 45 43 */ 44 @Projection 45 @Territories 46 46 class TagEditHelperTest { 47 48 /**49 * Setup tests50 */51 @RegisterExtension52 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")53 public JOSMTestRules test = new JOSMTestRules().territories().projection();54 55 47 private static TagEditHelper newTagEditHelper() { 56 48 DefaultTableModel propertyData = new DefaultTableModel(); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java
r18793 r18799 32 32 import org.openstreetmap.josm.testutils.annotations.Main; 33 33 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 34 import org.openstreetmap.josm.testutils.mockers.WindowMocker; 34 35 35 36 /** … … 142 143 } 143 144 }; 145 new WindowMocker(); 144 146 145 147 DataSet ds = new DataSet(); -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/RenderingCLIAreaTest.java
r18494 r18799 12 12 import org.hamcrest.CoreMatchers; 13 13 import org.hamcrest.Matcher; 14 import org.junit.jupiter.api.extension.RegisterExtension;15 14 import org.junit.jupiter.params.ParameterizedTest; 16 15 import org.junit.jupiter.params.provider.MethodSource; … … 18 17 import org.openstreetmap.josm.data.coor.ILatLon; 19 18 import org.openstreetmap.josm.data.coor.LatLon; 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 22 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 19 import org.openstreetmap.josm.testutils.annotations.Projection; 20 import org.openstreetmap.josm.testutils.annotations.Territories; 23 21 24 22 /** 25 23 * Tests the method {@link RenderingCLI#determineRenderingArea(org.openstreetmap.josm.data.osm.DataSet)}. 26 24 */ 25 @Projection 26 @Territories 27 27 class RenderingCLIAreaTest { 28 /**29 * Setup rule30 */31 @RegisterExtension32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")33 public JOSMTestRules test = new JOSMTestRules().projection().territories();34 35 28 public static Collection<Object[]> runs() { 36 29 Collection<Object[]> runs = new ArrayList<>(); -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java
r18637 r18799 20 20 import java.util.Objects; 21 21 import java.util.Set; 22 import java.util.concurrent.TimeUnit; 22 23 import java.util.function.Consumer; 23 24 import java.util.logging.Handler; … … 27 28 import org.junit.jupiter.api.BeforeAll; 28 29 import org.junit.jupiter.api.Test; 30 import org.junit.jupiter.api.Timeout; 29 31 import org.junit.jupiter.api.extension.RegisterExtension; 30 32 import org.junit.platform.commons.util.ReflectionUtils; … … 40 42 import org.openstreetmap.josm.spi.preferences.Config; 41 43 import org.openstreetmap.josm.testutils.JOSMTestRules; 44 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 45 import org.openstreetmap.josm.testutils.annotations.Main; 46 import org.openstreetmap.josm.testutils.annotations.Projection; 47 import org.openstreetmap.josm.testutils.annotations.Territories; 42 48 import org.openstreetmap.josm.tools.Destroyable; 43 49 import org.openstreetmap.josm.tools.Logging; … … 49 55 * Integration tests of {@link PluginHandler} class. 50 56 */ 57 @BasicPreferences 58 @Main 59 @Projection 60 @Territories 61 @Timeout(value = 10, unit = TimeUnit.MINUTES) 51 62 public class PluginHandlerTestIT { 52 63 … … 57 68 @RegisterExtension 58 69 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 59 public static JOSMTestRules test = new JOSMTestRules().main().projection().preferences().https() 60 .territories().timeout(10 * 60 * 1000); 70 public static JOSMTestRules test = new JOSMTestRules().https(); 61 71 62 72 /** -
trunk/test/unit/org/openstreetmap/josm/tools/JosmDecimalFormatSymbolsProviderTest.java
r18051 r18799 15 15 import org.junit.jupiter.api.BeforeAll; 16 16 import org.junit.jupiter.api.Test; 17 import org.junit.jupiter.api.extension.RegisterExtension;18 import org.openstreetmap.josm.testutils.JOSMTestRules;19 20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;21 17 22 18 /** 23 19 * Unit tests of {@link JosmDecimalFormatSymbolsProvider}. 24 20 */ 21 @org.openstreetmap.josm.testutils.annotations.I18n 25 22 class JosmDecimalFormatSymbolsProviderTest { 26 27 /**28 * Setup rule.29 */30 @RegisterExtension31 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")32 public JOSMTestRules test = new JOSMTestRules();33 34 23 @BeforeAll 35 24 static void beforeAll() throws IOException { -
trunk/test/unit/org/openstreetmap/josm/tools/RightAndLefthandTrafficTest.java
r17275 r18799 4 4 import static org.junit.jupiter.api.Assertions.fail; 5 5 6 import org.junit.jupiter.api.extension.RegisterExtension;7 6 import org.junit.jupiter.api.Test; 8 7 import org.openstreetmap.josm.data.coor.LatLon; 9 import org.openstreetmap.josm.testutils.JOSMTestRules; 8 import org.openstreetmap.josm.testutils.annotations.Projection; 9 import org.openstreetmap.josm.testutils.annotations.Territories; 10 10 11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;12 11 import net.trajano.commons.testing.UtilityClassTestUtil; 13 12 … … 15 14 * Unit tests of {@link RightAndLefthandTraffic} class. 16 15 */ 16 @Projection 17 @Territories 17 18 class RightAndLefthandTrafficTest { 18 /**19 * Test rules.20 */21 @RegisterExtension22 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")23 public JOSMTestRules rules = new JOSMTestRules().projection().territories();24 25 19 /** 26 20 * Tests that {@code RightAndLefthandTraffic} satisfies utility class criteria. -
trunk/test/unit/org/openstreetmap/josm/tools/TerritoriesTest.java
r17275 r18799 14 14 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.coor.LatLon; 19 import org.openstreetmap.josm.testutils. JOSMTestRules;18 import org.openstreetmap.josm.testutils.annotations.Projection; 20 19 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;22 20 import net.trajano.commons.testing.UtilityClassTestUtil; 23 21 … … 25 23 * Unit tests of {@link Territories} class. 26 24 */ 25 @Projection 26 @org.openstreetmap.josm.testutils.annotations.Territories 27 27 class TerritoriesTest { 28 /**29 * Test rules.30 */31 @RegisterExtension32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")33 public JOSMTestRules rules = new JOSMTestRules().projection().territories();34 35 28 /** 36 29 * Tests that {@code Territories} satisfies utility class criteria.
Note:
See TracChangeset
for help on using the changeset viewer.