Changeset 17531 in josm


Ignore:
Timestamp:
2021-02-23T00:28:29+01:00 (4 years ago)
Author:
Don-vip
Message:

see #16567 - consistency between extended source entry integration tests

Location:
trunk/test/unit/org/openstreetmap/josm/gui/preferences
Files:
3 edited
1 moved

Legend:

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

    r17530 r17531  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.preferences.map;
     2package org.openstreetmap.josm.gui.preferences;
    33
    44import java.util.ArrayList;
     
    1212import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry;
    1313
    14 abstract class AbstractExtendedSourceEntryTestCase {
     14/**
     15 * Super class of parameterized source entry integration tests.
     16 */
     17public abstract class AbstractExtendedSourceEntryTestCase {
    1518
    1619    private static final Pattern RESOURCE_PATTERN = Pattern.compile("resource://(.+)");
     
    4043    }
    4144
    42     protected final void handleException(ExtendedSourceEntry source, Exception e, Set<String> errors, List<String> ignoredErrors) {
     45    protected final void handleException(ExtendedSourceEntry source, Throwable e, Set<String> errors, List<String> ignoredErrors) {
    4346        e.printStackTrace();
    4447        String s = source.url + " => " + e.toString();
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java

    r17360 r17531  
    2222import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction;
    2323import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction.AssignmentInstruction;
     24import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCase;
    2425import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule;
    2526import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java

    r17360 r17531  
    1818import org.junit.jupiter.api.BeforeAll;
    1919import org.junit.jupiter.api.extension.RegisterExtension;
     20import org.junit.jupiter.api.parallel.Execution;
     21import org.junit.jupiter.api.parallel.ExecutionMode;
    2022import org.junit.jupiter.params.ParameterizedTest;
    2123import org.junit.jupiter.params.provider.MethodSource;
    2224import org.openstreetmap.josm.TestUtils;
    2325import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry;
     26import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCase;
    2427import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
    2528import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
     
    7982     * @throws Exception in case of error
    8083     */
     84    @Execution(ExecutionMode.CONCURRENT)
    8185    @ParameterizedTest(name = "{0} - {1}")
    8286    @MethodSource("data")
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java

    r17383 r17531  
    22package org.openstreetmap.josm.gui.preferences.validator;
    33
     4import static org.junit.Assume.assumeFalse;
     5import static org.junit.Assume.assumeTrue;
    46import static org.junit.jupiter.api.Assertions.assertFalse;
    57import static org.junit.jupiter.api.Assertions.assertTrue;
     
    79import java.io.IOException;
    810import java.util.ArrayList;
    9 import java.util.Collection;
     11import java.util.HashSet;
     12import java.util.List;
     13import java.util.Set;
    1014
    11 import org.junit.jupiter.api.Test;
     15import org.junit.jupiter.api.BeforeAll;
    1216import org.junit.jupiter.api.extension.RegisterExtension;
     17import org.junit.jupiter.api.parallel.Execution;
     18import org.junit.jupiter.api.parallel.ExecutionMode;
     19import org.junit.jupiter.params.ParameterizedTest;
     20import org.junit.jupiter.params.provider.MethodSource;
     21import org.openstreetmap.josm.TestUtils;
    1322import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry;
    1423import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
    1524import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.ParseResult;
     25import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCase;
    1626import org.openstreetmap.josm.testutils.JOSMTestRules;
    1727
     
    2131 * Integration tests of {@link ValidatorTagCheckerRulesPreference} class.
    2232 */
    23 class ValidatorTagCheckerRulesPreferenceTestIT {
     33class ValidatorTagCheckerRulesPreferenceTestIT extends AbstractExtendedSourceEntryTestCase {
    2434
    2535    /**
     
    2838    @RegisterExtension
    2939    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().https().timeout(20_000);
     40    static JOSMTestRules test = new JOSMTestRules().https().timeout(20_000);
    3141
    3242    /**
    33      * Test that available tag checker rules are valid.
     43     * Setup test
     44     * @throws IOException in case of I/O error
     45     */
     46    @BeforeAll
     47    public static void beforeClass() throws IOException {
     48        errorsToIgnore.addAll(TestUtils.getIgnoredErrorMessages(ValidatorTagCheckerRulesPreferenceTestIT.class));
     49    }
     50
     51    /**
     52     * Returns list of entries to test.
     53     * @return list of entries to test
    3454     * @throws Exception in case of error
    3555     */
    36     @Test
    37     void testValidityOfAvailableRules() throws Exception {
    38         Collection<ExtendedSourceEntry> sources = new ValidatorTagCheckerRulesPreference.TagCheckerRulesSourceEditor()
    39                 .loadAndGetAvailableSources();
    40         assertFalse(sources.isEmpty(), sources::toString);
    41         Collection<Throwable> allErrors = new ArrayList<>();
    42         MapCSSTagChecker tagChecker = new MapCSSTagChecker();
    43         for (ExtendedSourceEntry source : sources) {
    44             System.out.print(source.url);
    45             try {
    46                 ParseResult result = tagChecker.addMapCSS(source.url);
    47                 assertFalse(result.parseChecks.isEmpty(), result::toString);
    48                 System.out.println(result.parseErrors.isEmpty() ? " => OK" : " => KO");
    49                 allErrors.addAll(result.parseErrors);
    50             } catch (IOException e) {
    51                 System.out.println(" => KO");
    52                 allErrors.add(e);
    53                 e.printStackTrace();
    54             }
     56    public static List<Object[]> data() throws Exception {
     57        return getTestParameters(new ValidatorTagCheckerRulesPreference.TagCheckerRulesSourceEditor()
     58                .loadAndGetAvailableSources());
     59    }
     60
     61    /**
     62     * Test that available tag checker rule is valid.
     63     * @param displayName displayed name
     64     * @param url URL
     65     * @param source source entry to test
     66     * @throws Exception in case of error
     67     */
     68    @Execution(ExecutionMode.CONCURRENT)
     69    @ParameterizedTest(name = "{0} - {1}")
     70    @MethodSource("data")
     71    void testValidityOfAvailableRule(String displayName, String url, ExtendedSourceEntry source) throws Exception {
     72        assumeFalse(isIgnoredSubstring(source, source.url));
     73        List<String> ignoredErrors = new ArrayList<>();
     74        Set<String> errors = new HashSet<>();
     75        System.out.print(source.url);
     76        try {
     77            ParseResult result = new MapCSSTagChecker().addMapCSS(source.url);
     78            assertFalse(result.parseChecks.isEmpty(), result::toString);
     79            System.out.println(result.parseErrors.isEmpty() ? " => OK" : " => KO");
     80            result.parseErrors.forEach(e -> handleException(source, e, errors, ignoredErrors));
     81        } catch (IOException e) {
     82            System.out.println(" => KO");
     83            e.printStackTrace();
     84            handleException(source, e, errors, ignoredErrors);
    5585        }
    56         assertTrue(allErrors.isEmpty(), allErrors::toString);
     86        // #16567 - Shouldn't be necessary to print displayName if Ant worked properly
     87        // See https://josm.openstreetmap.de/ticket/16567#comment:53
     88        // See https://bz.apache.org/bugzilla/show_bug.cgi?id=64564
     89        // See https://github.com/apache/ant/pull/121
     90        assertTrue(errors.isEmpty(), displayName + " => " + errors);
     91        assumeTrue(ignoredErrors.toString(), ignoredErrors.isEmpty());
    5792    }
    5893}
Note: See TracChangeset for help on using the changeset viewer.