source: josm/trunk/test/functional/org/openstreetmap/josm/data/imagery/ImageryCompareTestIT.java@ 18870

Last change on this file since 18870 was 18870, checked in by taylor.smock, 11 months ago

See #16567: Update to JUnit 5

This converts most tests to use @Annotations. There are also some performance
improvements as it relates to tests.

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.imagery;
3
4import static org.junit.jupiter.api.Assertions.fail;
5
6import java.net.URL;
7
8import org.junit.jupiter.api.Test;
9import org.junit.jupiter.api.Timeout;
10import org.openstreetmap.josm.spi.preferences.Config;
11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
12import org.openstreetmap.josm.tools.HttpClient;
13
14/**
15 * Automatic test of imagery synchronization between JOSM and ELI.
16 * See <a href="https://josm.openstreetmap.de/wiki/ImageryCompare">JOSM wiki</a>
17 */
18@BasicPreferences
19@Timeout(60)
20class ImageryCompareTestIT {
21
22 private static final String BLACK_PREFIX = "<pre style=\"margin:3px;color:black\">";
23 private static final String RED_PREFIX = "<pre style=\"margin:3px;color:red\">";
24
25 /**
26 * Test of imagery entries.
27 * @throws Exception if an error occurs
28 */
29 @Test
30 void testImageryEntries() throws Exception {
31 // Increase traditional timeouts to avoid random problems
32 Config.getPref().putInt("socket.timeout.connect", 60);
33 Config.getPref().putInt("socket.timeout.read", 90);
34 System.out.println("Displaying only red entries. The test fails if at least one is found");
35 boolean rubricDisplayed = false;
36 boolean redFound = false;
37 String comparison = HttpClient.create(new URL("https://josm.openstreetmap.de/wiki/ImageryCompare")).connect().fetchContent();
38 String rubricLine = null;
39 for (String line : comparison.split("\n", -1)) {
40 boolean black = line.startsWith(BLACK_PREFIX);
41 if (black) {
42 rubricLine = line;
43 rubricDisplayed = false;
44 } else {
45 boolean red = line.startsWith(RED_PREFIX);
46 if (red) {
47 if (!rubricDisplayed && rubricLine != null) {
48 System.out.println(rubricLine.replace(BLACK_PREFIX, "").replace("</pre>", ""));
49 rubricDisplayed = true;
50 }
51 System.out.println(line.replace(RED_PREFIX, "").replace("</pre>", ""));
52 if (!redFound && red) {
53 redFound = true;
54 }
55 }
56 }
57 }
58 if (redFound) {
59 fail("Error: at least a red line has been found, see https://josm.openstreetmap.de/wiki/ImageryCompare for details");
60 } else {
61 System.out.println("No error :)");
62 }
63 }
64}
Note: See TracBrowser for help on using the repository browser.