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


Ignore:
Timestamp:
2018-12-02T18:54:57+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #17060, see #16073 - update integration test

File:
1 edited

Legend:

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

    r14489 r14497  
    55
    66import java.io.IOException;
    7 import java.net.MalformedURLException;
    87import java.net.URL;
    98import java.util.ArrayList;
    109import java.util.Collections;
    11 import java.util.HashMap;
    1210import java.util.HashSet;
    1311import java.util.List;
    1412import java.util.Map;
    1513import java.util.Set;
     14import java.util.TreeMap;
    1615
    1716import org.junit.Rule;
     
    3837    public JOSMTestRules test = new JOSMTestRules().https().timeout(10000*60);
    3938
    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<>());
    4241
    4342    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);
    4546    }
    4647
    4748    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) {
    5849        if (url != null && !workingURLs.contains(url)) {
    5950            try {
    60                 Response response = HttpClient.create(url).connect();
     51                Response response = HttpClient.create(new URL(url)).connect();
    6152                if (response.getResponseCode() >= 400) {
    62                     addError(info, url.toExternalForm() + " -> HTTP " + response.getResponseCode());
     53                    addError(info, url + " -> HTTP " + response.getResponseCode());
    6354                } else if (response.getResponseCode() >= 300) {
    64                     Logging.warn(url.toExternalForm() + " -> HTTP " + response.getResponseCode());
     55                    Logging.warn(url + " -> HTTP " + response.getResponseCode());
    6556                } else {
    6657                    workingURLs.add(url);
     
    10293        ImageryLayerInfo.instance.load(false);
    10394        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());
    10597    }
    10698}
Note: See TracChangeset for help on using the changeset viewer.