Changeset 14612 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2018-12-30T00:53:55+01:00 (6 years ago)
Author:
Don-vip
Message:

see #16073 - mark ignored tests as skipped

File:
1 edited

Legend:

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

    r14611 r14612  
    44import static org.junit.Assert.assertFalse;
    55import static org.junit.Assert.assertTrue;
     6import static org.junit.Assume.assumeTrue;
    67
    78import java.io.ByteArrayInputStream;
     
    100101    private final ImageryInfo info;
    101102    private final Map<String, Map<ImageryInfo, List<String>>> errors = Collections.synchronizedMap(new TreeMap<>());
     103    private final Map<String, Map<ImageryInfo, List<String>>> ignoredErrors = Collections.synchronizedMap(new TreeMap<>());
    102104    private static final Map<String, byte[]> workingURLs = Collections.synchronizedMap(new TreeMap<>());
    103105
    104106    private static TMSCachedTileLoaderJob helper;
    105     private static List<String> ignoredErrors;
     107    private static List<String> errorsToIgnore;
    106108
    107109    /**
     
    112114    public static void beforeClass() throws IOException {
    113115        helper = new TMSCachedTileLoaderJob(null, null, new CacheAccess<>(null), new TileJobOptions(0, 0, null, 0), null);
    114         ignoredErrors = TestUtils.getIgnoredErrorMessages(ImageryPreferenceTestIT.class);
     116        errorsToIgnore = TestUtils.getIgnoredErrorMessages(ImageryPreferenceTestIT.class);
    115117    }
    116118
     
    139141    private boolean addError(ImageryInfo info, String error) {
    140142        String errorMsg = error.replace('\n', ' ');
    141         return !ignoredErrors.contains(errorMsg) &&
    142                errors.computeIfAbsent(info.getCountryCode(), x -> Collections.synchronizedMap(new TreeMap<>()))
    143                      .computeIfAbsent(info, x -> Collections.synchronizedList(new ArrayList<>()))
    144                      .add(errorMsg);
     143        return addError(errorsToIgnore.contains(errorMsg) ? ignoredErrors : errors, info, errorMsg);
     144    }
     145
     146    private static boolean addError(Map<String, Map<ImageryInfo, List<String>>> map, ImageryInfo info, String errorMsg) {
     147        return map.computeIfAbsent(info.getCountryCode(), x -> Collections.synchronizedMap(new TreeMap<>()))
     148                  .computeIfAbsent(info, x -> Collections.synchronizedList(new ArrayList<>()))
     149                  .add(errorMsg);
    145150    }
    146151
     
    381386    }
    382387
     388    private static String format(Map<String, Map<ImageryInfo, List<String>>> map) {
     389        return map.toString().replaceAll("\\}, ", "\n\\}, ").replaceAll(", ImageryInfo\\{", "\n      ,ImageryInfo\\{");
     390    }
     391
    383392    /**
    384393     * Test that available imagery entry is valid.
     
    387396    public void testImageryEntryValidity() {
    388397        checkEntry(info);
    389         assertTrue(errors.toString().replaceAll("\\}, ", "\n\\}, ").replaceAll(", ImageryInfo\\{", "\n      ,ImageryInfo\\{"),
    390                 errors.isEmpty());
     398        assertTrue(format(errors), errors.isEmpty());
    391399        assertFalse(workingURLs.isEmpty());
     400        assumeTrue(format(ignoredErrors), ignoredErrors.isEmpty());
    392401    }
    393402}
Note: See TracChangeset for help on using the changeset viewer.