/** * @return The currently set API key or {@code null} if no key is set. */ public String getApiKey() { return serverConnector.getApiKey(); }
/** * @return The current proxy settings used by the rest client, * or {@code null} if no proxy is set. */ @SuppressWarnings("UnusedDeclaration") public AbstractProxySettings getProxy() { return getProxyBase(); }
/** * @return The URI of the eyes server. */ @SuppressWarnings("UnusedDeclaration") public URI getServerUrl() { return getServerUrlBase(); }
@Override public RenderingInfo getRenderInfo() { String apiKey = getApiKey(); WebTarget target = restClient.target(serverUrl).path((RENDER_INFO_PATH)).queryParam("apiKey", apiKey); Invocation.Builder request = target.request(MediaType.APPLICATION_JSON); // Ok, let's create the running session from the response List<Integer> validStatusCodes = new ArrayList<>(); validStatusCodes.add(Response.Status.OK.getStatusCode()); Response response = request.get(); renderingInfo = parseResponseWithJsonData(response, validStatusCodes, RenderingInfo.class); return renderingInfo; }
Invocation.Builder request = endPoint.queryParam("apiKey", getApiKey()). request(MediaType.APPLICATION_JSON); response = postWithRetry(request, Entity.json(postData), null); } catch (RuntimeException e) { logger.log("Server request failed: " + e.getMessage()); validStatusCodes.add(Response.Status.CREATED.getStatusCode()); runningSession = parseResponseWithJsonData(response, validStatusCodes, RunningSession.class);
Invocation.Builder request = endPoint.queryParam("apiKey", getApiKey()). request(MediaType.APPLICATION_JSON); response = sendWithRetry(HttpMethod.POST, request, Entity.json(postData), null); } catch (RuntimeException e) { logger.log("Server request failed: " + e.getMessage()); validStatusCodes.add(Response.Status.CREATED.getStatusCode()); runningSession = parseResponseWithJsonData(response, validStatusCodes, RunningSession.class);
response = sendLongRequest(delete, "stopSession"); validStatusCodes.add(Response.Status.OK.getStatusCode()); result = parseResponseWithJsonData(response, validStatusCodes, TestResults.class); return result;
@Override public String postDomSnapshot(String domJson) { WebTarget target = restClient.target(serverUrl).path(("api/sessions/running/data")).queryParam("apiKey", getApiKey()); byte[] resultStream = GeneralUtils.getGzipByteArrayOutputStream(domJson); Invocation.Builder request = target.request(MediaType.APPLICATION_JSON); Response response = postWithRetry(request, Entity.entity(resultStream, MediaType.APPLICATION_OCTET_STREAM), null); String entity = response.getHeaderString("Location"); return entity; }
@Override public String postDomSnapshot(String domJson) { restClient.register(GZipEncoder.class); WebTarget target = restClient.target(serverUrl).path((RUNNING_DATA_PATH)).queryParam("apiKey", getApiKey()); Invocation.Builder request = target.request(MediaType.APPLICATION_JSON); byte[] resultStream = GeneralUtils.getGzipByteArrayOutputStream(domJson); Response response = sendWithRetry(HttpMethod.POST, request, Entity.entity(resultStream, MediaType.APPLICATION_OCTET_STREAM), null); @SuppressWarnings("UnnecessaryLocalVariable") String entity = response.getHeaderString("Location"); return entity; }
serverConnector.getServerUrl())); logger.verbose(String.format("Timeout = '%d'", serverConnector.getTimeout())); logger.log(String.format("matchTimeout = '%d' ", matchTimeout)); logger.log(String.format("Default match settings = '%s' ",
/** * Sets the current server URL used by the rest client. * @param serverUrl The URI of the rest server. */ @SuppressWarnings("UnusedDeclaration") public void setServerUrl(URI serverUrl) { setServerUrlBase(serverUrl); // After the server is updated we must make sure the endpoint refers // to the correct path. endPoint = endPoint.path(API_PATH); }
/** * Sets the proxy settings to be used by the rest client. * @param proxySettings The proxy settings to be used by the rest client. * If {@code null} then no proxy is set. */ @SuppressWarnings("UnusedDeclaration") public void setProxy(AbstractProxySettings proxySettings) { setProxyBase(proxySettings); // After the server is updated we must make sure the endpoint refers // to the correct path. endPoint = endPoint.path(API_PATH); }
Response response = request.post(Entity.json(json)); if (validStatusCodes.contains(response.getStatus())) { RunningRender[] runningRenders = parseResponseWithJsonData(response, validStatusCodes, RunningRender[].class); return Arrays.asList(runningRenders);
@Override public void failed(Throwable throwable) { // on fail if (!isSecondRetry) { logger.verbose("Async GET failed - entering retry"); downloadString(uri, true, listener); } else { listener.onDownloadFailed(); } } });
/** * * @return The current proxy settings used by the server connector, * or {@code null} if no proxy is set. */ @SuppressWarnings("UnusedDeclaration") public ProxySettings getProxy() { return serverConnector.getProxy(); }
/** * * @return The URI of the eyes server. */ @SuppressWarnings("UnusedDeclaration") public URI getServerUrl() { return serverConnector.getServerUrl(); }
Invocation.Builder request = endPoint.queryParam("apiKey", getApiKey()). request(MediaType.APPLICATION_JSON); response = postWithRetry(request, Entity.json(postData), null); } catch (RuntimeException e) { logger.log("Server request failed: " + e.getMessage()); validStatusCodes.add(Response.Status.CREATED.getStatusCode()); runningSession = parseResponseWithJsonData(response, validStatusCodes, RunningSession.class);
response = runningSessionsEndpoint.queryParam("apiKey", getApiKey()). accept(MediaType.APPLICATION_JSON). entity(requestData, MediaType.APPLICATION_OCTET_STREAM_TYPE). validStatusCodes.add(ClientResponse.Status.OK.getStatusCode()); result = parseResponseWithJsonData(response, validStatusCodes, MatchResult.class);
Invocation.Builder request = runningSessionsEndpoint.queryParam("apiKey", getApiKey()). request(MediaType.APPLICATION_JSON); response = sendWithRetry(HttpMethod.POST, request, Entity.entity(requestData, MediaType.APPLICATION_OCTET_STREAM), null); validStatusCodes.add(Response.Status.OK.getStatusCode()); result = parseResponseWithJsonData(response, validStatusCodes, MatchResult.class);
response = sendLongRequest(delete, "stopSession"); validStatusCodes.add(Response.Status.OK.getStatusCode()); result = parseResponseWithJsonData(response, validStatusCodes, TestResults.class); return result;