- Timestamp:
- 2020-06-28T19:08:21+02:00 (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ivy.xml
r16617 r16727 61 61 <dependency conf="test->default" org="org.junit.platform" name="junit-platform-launcher" rev="1.6.2"/> 62 62 <dependency conf="test->default" org="org.junit.vintage" name="junit-vintage-engine" rev="5.6.2"/> 63 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-params" rev="5.6.2"/> 63 64 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-api" rev="5.6.2"/> 64 65 <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-engine" rev="5.6.2"/> -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
r16643 r16727 2 2 package org.openstreetmap.josm.gui.preferences.imagery; 3 3 4 import static org.junit. Assert.assertFalse;5 import static org.junit. Assert.assertTrue;6 import static org.junit. Assume.assumeTrue;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 import static org.junit.jupiter.api.Assumptions.assumeTrue; 7 7 8 8 import java.io.ByteArrayInputStream; … … 15 15 import java.util.Locale; 16 16 import java.util.Map; 17 import java.util.Objects;18 17 import java.util.Optional; 19 18 import java.util.TreeMap; … … 25 24 26 25 import org.apache.commons.jcs3.access.CacheAccess; 27 import org.junit. AfterClass;28 import org.junit. BeforeClass;29 import org.junit. ClassRule;30 import org.junit. Test;31 import org.junit. runner.RunWith;32 import org.junit. runners.Parameterized.Parameters;26 import org.junit.jupiter.api.AfterAll; 27 import org.junit.jupiter.api.BeforeAll; 28 import org.junit.jupiter.api.extension.RegisterExtension; 29 import org.junit.jupiter.params.ParameterizedTest; 30 import org.junit.jupiter.params.provider.Arguments; 31 import org.junit.jupiter.params.provider.MethodSource; 33 32 import org.openstreetmap.gui.jmapviewer.Coordinate; 34 33 import org.openstreetmap.gui.jmapviewer.FeatureAdapter; … … 62 61 import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException; 63 62 import org.openstreetmap.josm.testutils.JOSMTestRules; 64 import org.openstreetmap.josm.testutils.ParallelParameterized;65 63 import org.openstreetmap.josm.tools.HttpClient; 66 64 import org.openstreetmap.josm.tools.HttpClient.Response; … … 73 71 * Integration tests of {@link ImageryPreference} class. 74 72 */ 75 @RunWith(ParallelParameterized.class)76 73 public class ImageryPreferenceTestIT { 77 74 … … 83 80 * Setup rule 84 81 */ 85 @ ClassRule82 @RegisterExtension 86 83 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 87 publicstatic JOSMTestRules test = new JOSMTestRules().https().i18n().preferences().projection().projectionNadGrids()88 .timeout((int) TimeUnit.MINUTES.toMillis(40)) .parameters();84 static JOSMTestRules test = new JOSMTestRules().https().i18n().preferences().projection().projectionNadGrids() 85 .timeout((int) TimeUnit.MINUTES.toMillis(40)); 89 86 90 87 /** Entry to test */ 91 private final ImageryInfo info;92 88 private final Map<String, Map<ImageryInfo, List<String>>> errors = Collections.synchronizedMap(new TreeMap<>()); 93 89 private final Map<String, Map<ImageryInfo, List<String>>> ignoredErrors = Collections.synchronizedMap(new TreeMap<>()); … … 102 98 * @throws IOException in case of I/O error 103 99 */ 104 @Before Class100 @BeforeAll 105 101 public static void beforeClass() throws IOException { 106 102 FeatureAdapter.registerApiKeyAdapter(ApiKeyProvider::retrieveApiKey); … … 113 109 * Cleanup test 114 110 */ 115 @After Class111 @AfterAll 116 112 public static void afterClass() { 117 113 for (String e : notIgnoredErrors) { … … 124 120 * @return list of imagery entries to test 125 121 */ 126 @Parameters(name = "{0}") 127 public static List<Object[]> data() { 122 public static List<Arguments> data() { 128 123 ImageryLayerInfo.instance.load(false); 129 124 return ImageryLayerInfo.instance.getDefaultLayers() 130 125 .stream() 131 .map( x -> new Object[] {x.getId(), x})126 .map(i -> Arguments.of(i.getId(), i)) 132 127 .collect(Collectors.toList()); 133 }134 135 /**136 * Constructs a new {@code ImageryPreferenceTestIT} instance.137 * @param id entry ID, used only to name tests138 * @param info entry to test139 */140 public ImageryPreferenceTestIT(String id, ImageryInfo info) {141 this.info = Objects.requireNonNull(info);142 128 } 143 129 … … 405 391 /** 406 392 * Test that available imagery entry is valid. 393 * 394 * @param id The id of the imagery info to show as the test name 395 * @param info The imagery info to test 407 396 */ 408 @Test 409 public void testImageryEntryValidity() { 397 @ParameterizedTest(name = "{0}") 398 @MethodSource("data") 399 public void testImageryEntryValidity(String id, ImageryInfo info) { 410 400 checkEntry(info); 411 assertTrue( format(errors), errors.isEmpty());401 assertTrue(errors.isEmpty(), format(errors)); 412 402 assertFalse(workingURLs.isEmpty()); 413 assumeTrue( format(ignoredErrors), ignoredErrors.isEmpty());403 assumeTrue(ignoredErrors.isEmpty(), format(ignoredErrors)); 414 404 } 415 405 } -
trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
r16658 r16727 24 24 25 25 import org.awaitility.Awaitility; 26 import org.junit.jupiter.api.extension.AfterAllCallback; 26 27 import org.junit.jupiter.api.extension.AfterEachCallback; 28 import org.junit.jupiter.api.extension.BeforeAllCallback; 27 29 import org.junit.jupiter.api.extension.BeforeEachCallback; 28 30 import org.junit.jupiter.api.extension.ExtensionContext; … … 82 84 * @author Michael Zangl 83 85 */ 84 public class JOSMTestRules implements TestRule, AfterEachCallback, BeforeEachCallback {86 public class JOSMTestRules implements TestRule, AfterEachCallback, BeforeEachCallback, AfterAllCallback, BeforeAllCallback { 85 87 private int timeout = isDebugMode() ? -1 : 10 * 1000; 86 88 private TemporaryFolder josmHome; … … 465 467 } 466 468 469 @Override 470 public void beforeAll(ExtensionContext context) throws Exception { 471 beforeEach(context); 472 } 473 474 @Override 475 public void afterAll(ExtensionContext context) throws Exception { 476 afterEach(context); 477 } 478 467 479 /** 468 480 * Set up before running a test
Note:
See TracChangeset
for help on using the changeset viewer.