Changeset 15423 in josm for trunk/test/unit
- Timestamp:
- 2019-10-05T19:23:20+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java
r15101 r15423 8 8 9 9 import java.io.IOException; 10 import java.net.URL; 10 11 import java.util.Collection; 11 12 import java.util.HashSet; … … 28 29 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 29 30 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader; 31 import org.openstreetmap.josm.gui.tagging.presets.items.Link; 30 32 import org.openstreetmap.josm.spi.preferences.Config; 31 33 import org.openstreetmap.josm.testutils.JOSMTestRules; 34 import org.openstreetmap.josm.tools.HttpClient; 35 import org.openstreetmap.josm.tools.HttpClient.Response; 32 36 import org.openstreetmap.josm.tools.ImageProvider; 33 37 import org.openstreetmap.josm.tools.Logging; … … 113 117 assertFalse(presets.isEmpty()); 114 118 // wait for asynchronous icon loading 115 presets. stream().map(TaggingPreset::getIconLoadingTask).filter(Objects::nonNull).forEach(t -> {119 presets.parallelStream().map(TaggingPreset::getIconLoadingTask).filter(Objects::nonNull).forEach(t -> { 116 120 try { 117 121 t.get(30, TimeUnit.SECONDS); 118 122 } catch (InterruptedException | ExecutionException | TimeoutException e) { 123 Logging.error(e); 124 } 125 }); 126 // check that links are correct and not redirections 127 presets.parallelStream().flatMap(x -> x.data.stream().filter(i -> i instanceof Link).map(i -> ((Link) i).getUrl())).forEach(u -> { 128 try { 129 Response cr = HttpClient.create(new URL(u)).setMaxRedirects(-1).connect(); 130 final int code = cr.getResponseCode(); 131 if (HttpClient.isRedirect(code)) { 132 addOrIgnoreError(messages, "Found HTTP redirection for " + u + " -> " + code + " -> " + cr.getHeaderField("Location")); 133 } else if (code >= 400) { 134 addOrIgnoreError(messages, "Found HTTP error for " + u + " -> " + code); 135 } 136 } catch (IOException e) { 119 137 Logging.error(e); 120 138 } … … 125 143 if (message.contains(TaggingPreset.PRESET_ICON_ERROR_MSG_PREFIX)) { 126 144 error = true; 127 if (isIgnoredSubstring(message)) { 128 ignoredErrors.add(message); 129 } else { 130 messages.add(message); 131 } 145 addOrIgnoreError(messages, message); 132 146 } 133 147 } … … 136 150 } 137 151 } 152 153 void addOrIgnoreError(Set<String> messages, String message) { 154 if (isIgnoredSubstring(message)) { 155 ignoredErrors.add(message); 156 } else { 157 messages.add(message); 158 } 159 } 138 160 }
Note:
See TracChangeset
for help on using the changeset viewer.