Search in sources :

Example 6 with XmlPath

use of com.jayway.restassured.path.xml.XmlPath in project carina by qaprosoft.

the class JenkinsClient method getCurrentJobURL.

public String getCurrentJobURL(String job) {
    String url = null;
    try {
        URL obj = new URL(String.format(JOB_API, jenkinsURL, job));
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
        con.setRequestMethod("GET");
        con.getResponseCode();
        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String inputLine;
        StringBuffer response = new StringBuffer();
        try {
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
        } catch (Exception e) {
            LOGGER.debug("Error during FileWriter append. " + e.getMessage(), e.getCause());
        } finally {
            try {
                in.close();
            } catch (Exception e) {
                LOGGER.debug("Error during FileWriter close. " + e.getMessage(), e.getCause());
            }
        }
        XmlPath xmlPath = new XmlPath(response.toString());
        if (xmlPath.getBoolean("freeStyleProject.lastBuild.building")) {
            url = String.format(JOB, jenkinsURL, job, xmlPath.getString("freeStyleProject.lastBuild.number").trim());
        }
    } catch (Exception e) {
        url = "";
        LOGGER.error(e.getMessage());
    }
    return url;
}
Also used : XmlPath(com.jayway.restassured.path.xml.XmlPath) HttpURLConnection(java.net.HttpURLConnection) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) URL(java.net.URL)

Aggregations

XmlPath (com.jayway.restassured.path.xml.XmlPath)6 Response (com.jayway.restassured.response.Response)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Test (org.junit.Test)2 NodeChildren (com.jayway.restassured.path.xml.element.NodeChildren)1 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)1 Call (com.xebialabs.restito.semantics.Call)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 InputStreamReader (java.io.InputStreamReader)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)1 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 HasXPath.hasXPath (org.hamcrest.xml.HasXPath.hasXPath)1