1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.testtools.selenium;
17
18 import org.junit.After;
19 import org.junit.Before;
20 import org.junit.Test;
21
22 import java.net.MalformedURLException;
23
24
25
26
27
28
29
30 public class JenkinsJsonAllJobsResults extends JenkinsJsonJobResultsBase {
31
32 @Before
33 public void setUp() throws MalformedURLException, InterruptedException {
34 super.setUp();
35 }
36
37 @After
38 public void tearDown() {
39 closeAndQuitWebDriver();
40 }
41
42 @Test
43 public void testFetchAllJobReports() throws Exception {
44 for (int i = 0, s = jobs.size(); i < s; i++) {
45 fetchAllJobReports(jobs.get(i));
46 }
47 }
48
49 private void fetchAllJobReports(String job) throws Exception {
50 String url = null;
51 String jobJson;
52
53 url = jenkinsBase + "/job/" + job + "/api/json";
54
55 jobJson = retrieveJson(url);
56
57 String jsonJobNumber;
58 while (jobJson.contains(("{\"number\":"))) {
59 jsonJobNumber = jobJson.substring(jobJson.indexOf("{\"number\":") + 10, jobJson.length());
60 jsonJobNumber = jsonJobNumber.substring(0, jsonJobNumber.indexOf(","));
61
62 jobJson = jobJson.substring(jobJson.indexOf("{\"number\":") + 9, jobJson.length());
63
64 try {
65 fetchAndWriteTestReport(job, jsonJobNumber);
66 } catch (Exception e) {
67 passed = false;
68 System.out.println("job: " + job + " url: " + url + " " + e.getMessage());
69 e.printStackTrace();
70 }
71 }
72 }
73 }