Changeset 14605 in josm for trunk/test
- Timestamp:
- 2018-12-27T21:06:59+01:00 (6 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
r14603 r14605 14 14 import java.util.Locale; 15 15 import java.util.Map; 16 import java.util.Objects; 16 17 import java.util.Optional; 17 18 import java.util.TreeMap; 18 19 import java.util.concurrent.TimeUnit; 20 import java.util.stream.Collectors; 19 21 20 22 import javax.imageio.ImageIO; 21 23 22 24 import org.apache.commons.jcs.access.CacheAccess; 23 import org.junit.Before ;24 import org.junit. Rule;25 import org.junit.BeforeClass; 26 import org.junit.ClassRule; 25 27 import org.junit.Test; 28 import org.junit.runner.Description; 29 import org.junit.runner.RunWith; 30 import org.junit.runners.Parameterized.Parameters; 31 import org.junit.runners.model.Statement; 26 32 import org.openstreetmap.gui.jmapviewer.Coordinate; 27 33 import org.openstreetmap.gui.jmapviewer.TileXY; … … 53 59 import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException; 54 60 import org.openstreetmap.josm.testutils.JOSMTestRules; 61 import org.openstreetmap.josm.testutils.ParallelParameterized; 55 62 import org.openstreetmap.josm.tools.HttpClient; 56 63 import org.openstreetmap.josm.tools.HttpClient.Response; … … 63 70 * Integration tests of {@link ImageryPreference} class. 64 71 */ 72 @RunWith(ParallelParameterized.class) 65 73 public class ImageryPreferenceTestIT { 66 74 … … 71 79 * Setup rule 72 80 */ 73 @ Rule81 @ClassRule 74 82 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 75 public JOSMTestRules test = new JOSMTestRules().https().preferences().projection().projectionNadGrids()83 public static JOSMTestRules test = new JOSMTestRules().https().preferences().projection().projectionNadGrids() 76 84 .timeout((int) TimeUnit.MINUTES.toMillis(40)); 77 85 86 static { 87 try { 88 test.apply(new Statement() { 89 @Override 90 public void evaluate() throws Throwable { 91 // Do nothing. Hack needed because @Parameters are computed before anything else 92 } 93 }, Description.createSuiteDescription(ImageryPreferenceTestIT.class)).evaluate(); 94 } catch (Throwable e) { 95 Logging.error(e); 96 } 97 } 98 99 /** Entry to test */ 100 private final ImageryInfo info; 78 101 private final Map<String, Map<ImageryInfo, List<String>>> errors = Collections.synchronizedMap(new TreeMap<>()); 79 private final Map<String, byte[]> workingURLs = Collections.synchronizedMap(new TreeMap<>());80 81 private TMSCachedTileLoaderJob helper;82 private List<String> ignoredErrors;102 private static final Map<String, byte[]> workingURLs = Collections.synchronizedMap(new TreeMap<>()); 103 104 private static TMSCachedTileLoaderJob helper; 105 private static List<String> ignoredErrors; 83 106 84 107 /** … … 86 109 * @throws IOException in case of I/O error 87 110 */ 88 @Before 89 public void before() throws IOException {111 @BeforeClass 112 public static void beforeClass() throws IOException { 90 113 helper = new TMSCachedTileLoaderJob(null, null, new CacheAccess<>(null), new TileJobOptions(0, 0, null, 0), null); 91 114 ignoredErrors = TestUtils.getIgnoredErrorMessages(ImageryPreferenceTestIT.class); 115 } 116 117 /** 118 * Returns list of imagery entries to test. 119 * @return list of imagery entries to test 120 */ 121 @Parameters(name = "{0}") 122 public static List<Object[]> data() { 123 ImageryLayerInfo.instance.load(false); 124 return ImageryLayerInfo.instance.getDefaultLayers() 125 .stream().map(x -> new Object[] {x.getId(), x}) 126 .collect(Collectors.toList()); 127 } 128 129 /** 130 * Constructs a new {@code ImageryPreferenceTestIT} instance. 131 * @param id entry ID, used only to name tests 132 * @param info entry to test 133 */ 134 public ImageryPreferenceTestIT(String id, ImageryInfo info) { 135 this.info = Objects.requireNonNull(info); 92 136 } 93 137 … … 336 380 337 381 /** 338 * Test that available imagery entries are valid. 339 * @throws Exception in case of error 382 * Test that available imagery entry is valid. 340 383 */ 341 384 @Test 342 public void testValidityOfAvailableImageryEntries() throws Exception { 343 ImageryLayerInfo.instance.load(false); 344 ImageryLayerInfo.instance.getDefaultLayers().parallelStream().forEach(this::checkEntry); 385 public void testValidityOfAvailableImageryEntry() { 386 checkEntry(info); 345 387 assertTrue(errors.toString().replaceAll("\\}, ", "\n\\}, ").replaceAll(", ImageryInfo\\{", "\n ,ImageryInfo\\{"), 346 388 errors.isEmpty());
Note:
See TracChangeset
for help on using the changeset viewer.