View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Any passed in job numbers are ignored, as all available job numbers will be saved.
26   *
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   * @Deprecated see JenkinsJsonJobResultsBase jobs builds properties and "all"
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()); // strip off while condition
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  }