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.Test;
|
---|
9 | import org.openstreetmap.josm.tools.HttpClient;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Automatic test of imagery synchronization between JOSM and ELI.
|
---|
13 | * See <a href="https://josm.openstreetmap.de/wiki/ImageryCompare">JOSM wiki</a>
|
---|
14 | */
|
---|
15 | public class ImageryCompareTestIT {
|
---|
16 |
|
---|
17 | private static String BLACK_PREFIX = "<pre style=\"margin:3px;color:black\">";
|
---|
18 | private static String RED_PREFIX = "<pre style=\"margin:3px;color:red\">";
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Test of imagery entries.
|
---|
22 | * @throws Exception if an error occurs
|
---|
23 | */
|
---|
24 | @Test
|
---|
25 | public void testImageryEntries() throws Exception {
|
---|
26 | System.out.println("Displaying only red entries. The test fails if at least one is found");
|
---|
27 | boolean rubricDisplayed = false;
|
---|
28 | boolean redFound = false;
|
---|
29 | String comparison = HttpClient.create(new URL("https://josm.openstreetmap.de/wiki/ImageryCompare")).connect().fetchContent();
|
---|
30 | String rubricLine = null;
|
---|
31 | for (String line : comparison.split("\n")) {
|
---|
32 | boolean black = line.startsWith(BLACK_PREFIX);
|
---|
33 | if (black) {
|
---|
34 | rubricLine = line;
|
---|
35 | rubricDisplayed = false;
|
---|
36 | } else {
|
---|
37 | boolean red = line.startsWith(RED_PREFIX);
|
---|
38 | if (red) {
|
---|
39 | if (!rubricDisplayed && rubricLine != null) {
|
---|
40 | System.out.println(rubricLine.replace(BLACK_PREFIX, "").replace("</pre>", ""));
|
---|
41 | rubricDisplayed = true;
|
---|
42 | }
|
---|
43 | System.out.println(line.replace(RED_PREFIX, "").replace("</pre>", ""));
|
---|
44 | if (!redFound && red) {
|
---|
45 | redFound = true;
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
50 | if (redFound) {
|
---|
51 | fail("Error: at least a red line has been found, see https://josm.openstreetmap.de/wiki/ImageryCompare for details");
|
---|
52 | } else {
|
---|
53 | System.out.println("No error :)");
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|