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

Last change on this file since 13203 was 13203, checked in by Don-vip, 6 years ago

javadoc fixes + some test timeout increases

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.imagery;
3
4import static org.junit.Assert.fail;
5
6import java.net.URL;
7
8import org.junit.Rule;
9import org.junit.Test;
10import org.openstreetmap.josm.testutils.JOSMTestRules;
11import org.openstreetmap.josm.tools.HttpClient;
12
13import 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 */
19public 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}
Note: See TracBrowser for help on using the repository browser.