1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.imagery;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.fail;
|
---|
5 |
|
---|
6 | import java.net.URL;
|
---|
7 |
|
---|
8 | import org.junit.Rule;
|
---|
9 | import org.junit.Test;
|
---|
10 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
11 | import org.openstreetmap.josm.tools.HttpClient;
|
---|
12 |
|
---|
13 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Automatic test of imagery synchronization between JOSM and ELI.
|
---|
17 | * See <a href="https://josm.openstreetmap.de/wiki/ImageryCompare">JOSM wiki</a>
|
---|
18 | */
|
---|
19 | public class ImageryCompareTestIT {
|
---|
20 |
|
---|
21 | private static String BLACK_PREFIX = "<pre style=\"margin:3px;color:black\">";
|
---|
22 | private static String RED_PREFIX = "<pre style=\"margin:3px;color:red\">";
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Setup test.
|
---|
26 | */
|
---|
27 | @Rule
|
---|
28 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
29 | public JOSMTestRules test = new JOSMTestRules().preferences().timeout(60000);
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * Test of imagery entries.
|
---|
33 | * @throws Exception if an error occurs
|
---|
34 | */
|
---|
35 | @Test
|
---|
36 | public void testImageryEntries() throws Exception {
|
---|
37 | System.out.println("Displaying only red entries. The test fails if at least one is found");
|
---|
38 | boolean rubricDisplayed = false;
|
---|
39 | boolean redFound = false;
|
---|
40 | String comparison = HttpClient.create(new URL("https://josm.openstreetmap.de/wiki/ImageryCompare")).connect().fetchContent();
|
---|
41 | String rubricLine = null;
|
---|
42 | for (String line : comparison.split("\n")) {
|
---|
43 | boolean black = line.startsWith(BLACK_PREFIX);
|
---|
44 | if (black) {
|
---|
45 | rubricLine = line;
|
---|
46 | rubricDisplayed = false;
|
---|
47 | } else {
|
---|
48 | boolean red = line.startsWith(RED_PREFIX);
|
---|
49 | if (red) {
|
---|
50 | if (!rubricDisplayed && rubricLine != null) {
|
---|
51 | System.out.println(rubricLine.replace(BLACK_PREFIX, "").replace("</pre>", ""));
|
---|
52 | rubricDisplayed = true;
|
---|
53 | }
|
---|
54 | System.out.println(line.replace(RED_PREFIX, "").replace("</pre>", ""));
|
---|
55 | if (!redFound && red) {
|
---|
56 | redFound = true;
|
---|
57 | }
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|
61 | if (redFound) {
|
---|
62 | fail("Error: at least a red line has been found, see https://josm.openstreetmap.de/wiki/ImageryCompare for details");
|
---|
63 | } else {
|
---|
64 | System.out.println("No error :)");
|
---|
65 | }
|
---|
66 | }
|
---|
67 | }
|
---|