/** * Returns the result of a HTTP get to the value of the <code>restEndpoint</code> parameter, * as a BufferedInputStream suitable for consumption or saving to file. * * @param jobId the Sauce Job id * @param restEndpoint the URL to perform a HTTP GET * @throws IOException when something goes wrong fetching the data */ // TODO: Asset fetching can fail just after a test finishes. Allow for configurable retries. private BufferedInputStream downloadFileData(String jobId, URL restEndpoint) throws IOException{ logger.log(Level.FINE, "Downloading asset " + restEndpoint.toString() + " For Job " + jobId); logger.log(Level.FINEST, "Opening connection for Job " + jobId); HttpURLConnection connection = openConnection(restEndpoint); connection.setRequestProperty("User-Agent", this.getUserAgent()); connection.setDoOutput(true); connection.setRequestMethod("GET"); addAuthenticationProperty(connection); logger.log(Level.FINEST, "Obtaining input stream for request issued for Job " + jobId); InputStream stream = connection.getInputStream(); BufferedInputStream in = new BufferedInputStream(stream); return in; }
/** * Returns the result of a HTTP get to the value of the <code>restEndpoint</code> parameter, * as a BufferedInputStream suitable for consumption or saving to file. * * @param jobId the Sauce Job id * @param restEndpoint the URL to perform a HTTP GET * @throws IOException when something goes wrong fetching the data */ // TODO: Asset fetching can fail just after a test finishes. Allow for configurable retries. private BufferedInputStream downloadFileData(String jobId, URL restEndpoint) throws IOException{ logger.log(Level.FINE, "Downloading asset " + restEndpoint.toString() + " For Job " + jobId); logger.log(Level.FINEST, "Opening connection for Job " + jobId); HttpURLConnection connection = openConnection(restEndpoint); connection.setRequestProperty("User-Agent", this.getUserAgent()); connection.setDoOutput(true); connection.setRequestMethod("GET"); addAuthenticationProperty(connection); logger.log(Level.FINEST, "Obtaining input stream for request issued for Job " + jobId); InputStream stream = connection.getInputStream(); BufferedInputStream in = new BufferedInputStream(stream); return in; }
/** * Invokes the Sauce REST API to update the details of a Sauce job, using the details included in the <code>updates</code> * parameter. * * @param jobId the Sauce job id to update * @param updates Map of attributes to update */ public void updateJobInfo(String jobId, Map<String, Object> updates) { HttpURLConnection postBack = null; try { URL restEndpoint = this.buildURL("v1/" + username + "/jobs/" + jobId); postBack = openConnection(restEndpoint); postBack.setRequestProperty("User-Agent", this.getUserAgent()); postBack.setDoOutput(true); postBack.setRequestMethod("PUT"); addAuthenticationProperty(postBack); postBack.getOutputStream().write(new JSONObject(updates).toString().getBytes()); } catch (IOException e) { logger.log(Level.WARNING, "Error updating Sauce Results", e); } closeInputStream(postBack); }
connection.setRequestProperty("User-Agent", this.getUserAgent());
/** * Invokes the Sauce REST API to delete a tunnel. * * @param tunnelId Identifier of the tunnel to delete */ public void deleteTunnel(String tunnelId) { HttpURLConnection connection = null; try { URL restEndpoint = this.buildURL("v1/" + username + "/tunnels/" + tunnelId); connection = openConnection(restEndpoint); connection.setRequestProperty("User-Agent", this.getUserAgent()); connection.setDoOutput(true); connection.setRequestMethod("DELETE"); addAuthenticationProperty(connection); connection.getOutputStream().write("".getBytes()); } catch (IOException e) { logger.log(Level.WARNING, "Error stopping Sauce Job", e); } closeInputStream(connection); }
/** * Invokes the Sauce REST API to delete a completed job from Sauce. * * @param jobId the Sauce Job id */ public void deleteJob(String jobId) { HttpURLConnection postBack = null; try { URL restEndpoint = this.buildURL("v1/" + username + "/jobs/" + jobId); postBack = openConnection(restEndpoint); postBack.setRequestProperty("User-Agent", this.getUserAgent()); postBack.setDoOutput(true); postBack.setRequestMethod("DELETE"); addAuthenticationProperty(postBack); postBack.getOutputStream().write("".getBytes()); } catch (IOException e) { logger.log(Level.WARNING, "Error stopping Sauce Job", e); } closeInputStream(postBack); }
/** * Invokes the Sauce REST API to delete a tunnel. * * @param tunnelId Identifier of the tunnel to delete */ public void deleteTunnel(String tunnelId) { HttpURLConnection connection = null; try { URL restEndpoint = this.buildURL("v1/" + username + "/tunnels/" + tunnelId); connection = openConnection(restEndpoint); connection.setRequestProperty("User-Agent", this.getUserAgent()); connection.setDoOutput(true); connection.setRequestMethod("DELETE"); addAuthenticationProperty(connection); connection.getOutputStream().write("".getBytes()); } catch (IOException e) { logger.log(Level.WARNING, "Error stopping Sauce Job", e); } closeInputStream(connection); }
/** * Invokes the Sauce REST API to delete a completed job from Sauce. * * @param jobId the Sauce Job id */ public void deleteJob(String jobId) { HttpURLConnection postBack = null; try { URL restEndpoint = this.buildURL("v1/" + username + "/jobs/" + jobId); postBack = openConnection(restEndpoint); postBack.setRequestProperty("User-Agent", this.getUserAgent()); postBack.setDoOutput(true); postBack.setRequestMethod("DELETE"); addAuthenticationProperty(postBack); postBack.getOutputStream().write("".getBytes()); } catch (IOException e) { logger.log(Level.WARNING, "Error stopping Sauce Job", e); } closeInputStream(postBack); }
/** * Invokes the Sauce REST API to stop a running job. * * @param jobId the Sauce Job id */ public void stopJob(String jobId) { HttpURLConnection postBack = null; try { URL restEndpoint = this.buildURL("v1/" + username + "/jobs/" + jobId + "/stop"); postBack = openConnection(restEndpoint); postBack.setRequestProperty("User-Agent", this.getUserAgent()); postBack.setDoOutput(true); postBack.setRequestMethod("PUT"); addAuthenticationProperty(postBack); postBack.getOutputStream().write("".getBytes()); } catch (IOException e) { logger.log(Level.WARNING, "Error stopping Sauce Job", e); } closeInputStream(postBack); }
/** * Invokes the Sauce REST API to update the details of a Sauce job, using the details included in the <code>updates</code> * parameter. * * @param jobId the Sauce job id to update * @param updates Map of attributes to update */ public void updateJobInfo(String jobId, Map<String, Object> updates) { HttpURLConnection postBack = null; try { URL restEndpoint = this.buildURL("v1/" + username + "/jobs/" + jobId); postBack = openConnection(restEndpoint); postBack.setRequestProperty("User-Agent", this.getUserAgent()); postBack.setDoOutput(true); postBack.setRequestMethod("PUT"); addAuthenticationProperty(postBack); postBack.getOutputStream().write(new JSONObject(updates).toString().getBytes()); } catch (IOException e) { logger.log(Level.WARNING, "Error updating Sauce Results", e); } closeInputStream(postBack); }
/** * Invokes the Sauce REST API to stop a running job. * * @param jobId the Sauce Job id */ public void stopJob(String jobId) { HttpURLConnection postBack = null; try { URL restEndpoint = this.buildURL("v1/" + username + "/jobs/" + jobId + "/stop"); postBack = openConnection(restEndpoint); postBack.setRequestProperty("User-Agent", this.getUserAgent()); postBack.setDoOutput(true); postBack.setRequestMethod("PUT"); addAuthenticationProperty(postBack); postBack.getOutputStream().write("".getBytes()); } catch (IOException e) { logger.log(Level.WARNING, "Error stopping Sauce Job", e); } closeInputStream(postBack); }
connection.setRequestProperty("User-Agent", this.getUserAgent());
postBack.setRequestProperty("User-Agent", this.getUserAgent());
postBack.setRequestProperty("User-Agent", this.getUserAgent());
connection.setRequestProperty("User-Agent", this.getUserAgent()); addAuthenticationProperty(connection); connection.setUseCaches(false);
connection.setRequestProperty("User-Agent", this.getUserAgent()); addAuthenticationProperty(connection); connection.setUseCaches(false);