Changeset 14612 in josm for trunk/test/unit/org
- Timestamp:
- 2018-12-30T00:53:55+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
r14611 r14612 4 4 import static org.junit.Assert.assertFalse; 5 5 import static org.junit.Assert.assertTrue; 6 import static org.junit.Assume.assumeTrue; 6 7 7 8 import java.io.ByteArrayInputStream; … … 100 101 private final ImageryInfo info; 101 102 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<>()); 102 104 private static final Map<String, byte[]> workingURLs = Collections.synchronizedMap(new TreeMap<>()); 103 105 104 106 private static TMSCachedTileLoaderJob helper; 105 private static List<String> ignoredErrors;107 private static List<String> errorsToIgnore; 106 108 107 109 /** … … 112 114 public static void beforeClass() throws IOException { 113 115 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); 115 117 } 116 118 … … 139 141 private boolean addError(ImageryInfo info, String error) { 140 142 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); 145 150 } 146 151 … … 381 386 } 382 387 388 private static String format(Map<String, Map<ImageryInfo, List<String>>> map) { 389 return map.toString().replaceAll("\\}, ", "\n\\}, ").replaceAll(", ImageryInfo\\{", "\n ,ImageryInfo\\{"); 390 } 391 383 392 /** 384 393 * Test that available imagery entry is valid. … … 387 396 public void testImageryEntryValidity() { 388 397 checkEntry(info); 389 assertTrue(errors.toString().replaceAll("\\}, ", "\n\\}, ").replaceAll(", ImageryInfo\\{", "\n ,ImageryInfo\\{"), 390 errors.isEmpty()); 398 assertTrue(format(errors), errors.isEmpty()); 391 399 assertFalse(workingURLs.isEmpty()); 400 assumeTrue(format(ignoredErrors), ignoredErrors.isEmpty()); 392 401 } 393 402 }
Note:
See TracChangeset
for help on using the changeset viewer.