Changeset 14497 in josm for trunk/test/unit/org
- Timestamp:
- 2018-12-02T18:54:57+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
r14489 r14497 5 5 6 6 import java.io.IOException; 7 import java.net.MalformedURLException;8 7 import java.net.URL; 9 8 import java.util.ArrayList; 10 9 import java.util.Collections; 11 import java.util.HashMap;12 10 import java.util.HashSet; 13 11 import java.util.List; 14 12 import java.util.Map; 15 13 import java.util.Set; 14 import java.util.TreeMap; 16 15 17 16 import org.junit.Rule; … … 38 37 public JOSMTestRules test = new JOSMTestRules().https().timeout(10000*60); 39 38 40 private final Map< ImageryInfo, List<String>> errors = Collections.synchronizedMap(new HashMap<>());41 private final Set< URL> workingURLs = Collections.synchronizedSet(new HashSet<>());39 private final Map<String, Map<ImageryInfo, List<String>>> errors = Collections.synchronizedMap(new TreeMap<>()); 40 private final Set<String> workingURLs = Collections.synchronizedSet(new HashSet<>()); 42 41 43 42 private boolean addError(ImageryInfo info, String error) { 44 return errors.computeIfAbsent(info, x -> new ArrayList<>()).add(error); 43 return errors.computeIfAbsent(info.getCountryCode(), x -> Collections.synchronizedMap(new TreeMap<>())) 44 .computeIfAbsent(info, x -> Collections.synchronizedList(new ArrayList<>())) 45 .add(error); 45 46 } 46 47 47 48 private void checkUrl(ImageryInfo info, String url) { 48 if (url != null) {49 try {50 checkUrl(info, new URL(url));51 } catch (MalformedURLException e) {52 addError(info, url + " -> " + e);53 }54 }55 }56 57 private void checkUrl(ImageryInfo info, URL url) {58 49 if (url != null && !workingURLs.contains(url)) { 59 50 try { 60 Response response = HttpClient.create( url).connect();51 Response response = HttpClient.create(new URL(url)).connect(); 61 52 if (response.getResponseCode() >= 400) { 62 addError(info, url .toExternalForm()+ " -> HTTP " + response.getResponseCode());53 addError(info, url + " -> HTTP " + response.getResponseCode()); 63 54 } else if (response.getResponseCode() >= 300) { 64 Logging.warn(url .toExternalForm()+ " -> HTTP " + response.getResponseCode());55 Logging.warn(url + " -> HTTP " + response.getResponseCode()); 65 56 } else { 66 57 workingURLs.add(url); … … 102 93 ImageryLayerInfo.instance.load(false); 103 94 ImageryLayerInfo.instance.getDefaultLayers().parallelStream().forEach(this::checkEntry); 104 assertTrue(errors.toString(), errors.isEmpty()); 95 assertTrue(errors.toString().replaceAll("\\}, ", "\n\\}, ").replaceAll(", ImageryInfo\\{", "\n ,ImageryInfo\\{"), 96 errors.isEmpty()); 105 97 } 106 98 }
Note:
See TracChangeset
for help on using the changeset viewer.