Ignore:
Timestamp:
2020-06-28T19:08:21+02:00 (4 years ago)
Author:
simon04
Message:

fix #16567 - Fix ImageryPreferenceTestIT for JUnit 5 (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java

    r16643 r16727  
    22package org.openstreetmap.josm.gui.preferences.imagery;
    33
    4 import static org.junit.Assert.assertFalse;
    5 import static org.junit.Assert.assertTrue;
    6 import static org.junit.Assume.assumeTrue;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
     6import static org.junit.jupiter.api.Assumptions.assumeTrue;
    77
    88import java.io.ByteArrayInputStream;
     
    1515import java.util.Locale;
    1616import java.util.Map;
    17 import java.util.Objects;
    1817import java.util.Optional;
    1918import java.util.TreeMap;
     
    2524
    2625import 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;
     26import org.junit.jupiter.api.AfterAll;
     27import org.junit.jupiter.api.BeforeAll;
     28import org.junit.jupiter.api.extension.RegisterExtension;
     29import org.junit.jupiter.params.ParameterizedTest;
     30import org.junit.jupiter.params.provider.Arguments;
     31import org.junit.jupiter.params.provider.MethodSource;
    3332import org.openstreetmap.gui.jmapviewer.Coordinate;
    3433import org.openstreetmap.gui.jmapviewer.FeatureAdapter;
     
    6261import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException;
    6362import org.openstreetmap.josm.testutils.JOSMTestRules;
    64 import org.openstreetmap.josm.testutils.ParallelParameterized;
    6563import org.openstreetmap.josm.tools.HttpClient;
    6664import org.openstreetmap.josm.tools.HttpClient.Response;
     
    7371 * Integration tests of {@link ImageryPreference} class.
    7472 */
    75 @RunWith(ParallelParameterized.class)
    7673public class ImageryPreferenceTestIT {
    7774
     
    8380     * Setup rule
    8481     */
    85     @ClassRule
     82    @RegisterExtension
    8683    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    87     public static 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));
    8986
    9087    /** Entry to test */
    91     private final ImageryInfo info;
    9288    private final Map<String, Map<ImageryInfo, List<String>>> errors = Collections.synchronizedMap(new TreeMap<>());
    9389    private final Map<String, Map<ImageryInfo, List<String>>> ignoredErrors = Collections.synchronizedMap(new TreeMap<>());
     
    10298     * @throws IOException in case of I/O error
    10399     */
    104     @BeforeClass
     100    @BeforeAll
    105101    public static void beforeClass() throws IOException {
    106102        FeatureAdapter.registerApiKeyAdapter(ApiKeyProvider::retrieveApiKey);
     
    113109     * Cleanup test
    114110     */
    115     @AfterClass
     111    @AfterAll
    116112    public static void afterClass() {
    117113        for (String e : notIgnoredErrors) {
     
    124120     * @return list of imagery entries to test
    125121     */
    126     @Parameters(name = "{0}")
    127     public static List<Object[]> data() {
     122    public static List<Arguments> data() {
    128123        ImageryLayerInfo.instance.load(false);
    129124        return ImageryLayerInfo.instance.getDefaultLayers()
    130125                .stream()
    131                 .map(x -> new Object[] {x.getId(), x})
     126                .map(i -> Arguments.of(i.getId(), i))
    132127                .collect(Collectors.toList());
    133     }
    134 
    135     /**
    136      * Constructs a new {@code ImageryPreferenceTestIT} instance.
    137      * @param id entry ID, used only to name tests
    138      * @param info entry to test
    139      */
    140     public ImageryPreferenceTestIT(String id, ImageryInfo info) {
    141         this.info = Objects.requireNonNull(info);
    142128    }
    143129
     
    405391    /**
    406392     * 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
    407396     */
    408     @Test
    409     public void testImageryEntryValidity() {
     397    @ParameterizedTest(name = "{0}")
     398    @MethodSource("data")
     399    public void testImageryEntryValidity(String id, ImageryInfo info) {
    410400        checkEntry(info);
    411         assertTrue(format(errors), errors.isEmpty());
     401        assertTrue(errors.isEmpty(), format(errors));
    412402        assertFalse(workingURLs.isEmpty());
    413         assumeTrue(format(ignoredErrors), ignoredErrors.isEmpty());
     403        assumeTrue(ignoredErrors.isEmpty(), format(ignoredErrors));
    414404    }
    415405}
Note: See TracChangeset for help on using the changeset viewer.