private void postJobUpdate(String storyName, SessionId sessionId, String payload) { try { URL url = new URL("http://saucelabs.com/rest/v1/" + getSauceUser() + "/jobs/" + sessionId.toString()); Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(getSauceUser(), getSauceAccessKey().toCharArray()); } }); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestMethod("PUT"); OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream()); writer.write(payload); writer.close(); int rc = connection.getResponseCode(); String jobUrl = null; if (rc == 200) { jobUrl = readResponseLinesFromSauceLabToGetJobUrl(new BufferedReader(new InputStreamReader(connection.getInputStream()))); storyToJobIds.put(storyName, jobUrl); } } catch (IOException e) { System.err.println("SauceContextStoryReporter: Error updating Saucelabs job info: " + e.getMessage()); } }
private void postJobUpdate(String storyName, SessionId sessionId, String payload) { try { URL url = new URL("http://saucelabs.com/rest/v1/" + getSauceUser() + "/jobs/" + sessionId.toString()); Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(getSauceUser(), getSauceAccessKey().toCharArray()); } }); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestMethod("PUT"); OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream()); writer.write(payload); writer.close(); int rc = connection.getResponseCode(); String jobUrl = null; if (rc == 200) { jobUrl = readResponseLinesFromSauceLabToGetJobUrl(new BufferedReader(new InputStreamReader(connection.getInputStream()))); storyToJobIds.put(storyName, jobUrl); } } catch (IOException e) { System.err.println("SauceContextStoryReporter: Error updating Saucelabs job info: " + e.getMessage()); } }