protected Response request(HttpMethod method) throws IOException { final int statusCode; final String body; try { statusCode = client.executeMethod(method); body = new String(method.getResponseBody(), "utf-8"); logger.debug("Remote Control replied with '" + statusCode + " / '" + body + "'"); return new Response(statusCode, body); } finally { method.releaseConnection(); } }
protected void reply(HttpServletResponse response, Response remoteControlResponse) throws IOException { response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.setStatus(remoteControlResponse.statusCode()); response.getWriter().print(remoteControlResponse.body()); }
protected Response forward(HttpParameters parameters, DynamicRemoteControlPool pool, EnvironmentManager environmentManager) throws IOException { final SeleneseCommand command; final Response response; LOGGER.info("Processing '" + parameters.toString() + "'"); try { command = new HttpCommandParser(parameters).parse(environmentManager); response = command.execute(pool); } catch (CommandParsingException e) { LOGGER.error("Failed to parse '" + parameters.toString() + "' : " + e.getMessage()); return new Response(e.getMessage()); } catch (NoSuchEnvironmentException e) { LOGGER.error("Could not find any remote control providing the '" + e.environment() + "' environment. Please make sure you started some remote controls which registered as offering this environment."); return new Response(e.getMessage()); } catch (NoSuchSessionException e) { LOGGER.error(e.getMessage()); return new Response(e.getMessage()); } final String responseBody = response.body(); if (responseBody.length() > 128) { final int truncated = responseBody.length() - 128; LOGGER.info(String.format("Responding with %d / %s...[%d characters truncated]", response.statusCode(), responseBody.substring(0, 128), truncated)); } else { LOGGER.info(String.format("Responding with %d / %s", response.statusCode(), responseBody)); } return response; }
public Response execute(RemoteControlPool pool) throws IOException { RemoteControlProxy remoteControl; final String sessionId; final Response response; remoteControl = pool.reserve(environment); if (null == remoteControl) { final String message = "No available remote control for environment '" + environment.name() + "'"; logger.warn(message); return new Response(message); } try { response = remoteControl.forward(parameters()); sessionId = parseSessionId(response.body()); if (null == sessionId) { pool.release(remoteControl); return new Response("Could not retrieve a new session"); } pool.associateWithSession(remoteControl, sessionId); pool.updateSessionLastActiveAt(sessionId); return response; } catch (Exception e) { logger.error("Problem while requesting new browser session", e); pool.release(remoteControl); return new Response(e.getMessage()); } }
public boolean unreliable() { final Response response; try { LOGGER.debug("Polling Remote Control at " + host + ":" + port); response = httpClient.get(remoteControlPingURL()); } catch (Exception e) { LOGGER.warn("Remote Control at " + host + ":" + port + " is unresponsive"); return true; } if (response.statusCode() != 200) { LOGGER.warn("Remote Control at " + host + ":" + port + " did not respond correctly"); return true; } return false; }
protected Response forward(HttpParameters parameters, DynamicRemoteControlPool pool, EnvironmentManager environmentManager) throws IOException { final SeleneseCommand command; final Response response; LOGGER.info("Processing '" + parameters.toString() + "'"); try { command = new HttpCommandParser(parameters).parse(environmentManager); response = command.execute(pool); } catch (CommandParsingException e) { LOGGER.error("Failed to parse '" + parameters.toString() + "' : " + e.getMessage()); return new Response(e.getMessage()); } catch (NoSuchEnvironmentException e) { LOGGER.error("Could not find any remote control providing the '" + e.environment() + "' environment. Please make sure you started some remote controls which registered as offering this environment."); return new Response(e.getMessage()); } LOGGER.info("Responding with " + response.statusCode() + "/ '" + response.body() + "'"); return response; }
public Response execute(RemoteControlPool pool) throws IOException { RemoteControlProxy remoteControl; final String sessionId; final Response response; remoteControl = pool.reserve(environment); if (null == remoteControl) { final String message = "No available remote control for environment '" + environment.name() + "'"; logger.warn(message); return new Response(message); } try { response = remoteControl.forward(parameters()); sessionId = parseSessionId(response.body()); if (null == sessionId) { pool.release(remoteControl); return new Response("Could not retrieve a new session"); } pool.associateWithSession(remoteControl, sessionId); pool.updateSessionLastActiveAt(sessionId); return response; } catch (Exception e) { logger.error("Problem while requesting new browser session", e); pool.release(remoteControl); return new Response(e.getMessage()); } }
if (response.statusCode() != 200) { LOGGER.warn("Remote Control at " + host + ":" + port + " did not respond correctly");
protected void reply(HttpServletResponse response, Response remoteControlResponse) throws IOException { response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.setStatus(remoteControlResponse.statusCode()); response.getWriter().print(remoteControlResponse.body()); }
protected Response request(HttpMethod method) throws IOException { final int statusCode; final String body; try { statusCode = client.executeMethod(method); body = new String(method.getResponseBody(), "utf-8"); logger.debug("Remote Control replied with '" + statusCode + " / '" + body + "'"); return new Response(statusCode, body); } finally { method.releaseConnection(); } }
public Status execute() { final Response response; try { LOGGER.info("Ping Hub at " + heartBeatURL); response = httpClient().get(heartBeatURL); } catch (Exception e) { LOGGER.warn("Hub at " + heartBeatURL + " is unresponsive"); return Status.DOWN; } if (response.statusCode() != 200) { LOGGER.warn("Hub at " + heartBeatURL + " did not respond correctly"); return Status.DOWN; } if (!response.body().equals("Hub : OK")) { LOGGER.warn("Hub at " + heartBeatURL + " does not have us as registered"); return Status.UNREGISTERED; } return Status.OK; }
protected Response request(HttpMethod method) throws IOException { final int statusCode; final String body; try { statusCode = client.executeMethod(method); body = new String(method.getResponseBody(), "utf-8"); logger.info("Remote Control replied with '" + statusCode + " / '" + body + "'"); return new Response(statusCode, body); } finally { method.releaseConnection(); } }
public Status execute() { final Response response; try { LOGGER.info("Ping Hub at " + heartBeatURL); response = httpClient().get(heartBeatURL); } catch (Exception e) { LOGGER.warn("Hub at " + heartBeatURL + " is unresponsive"); return Status.DOWN; } if (response.statusCode() != 200) { LOGGER.warn("Hub at " + heartBeatURL + " did not respond correctly"); return Status.DOWN; } if (!response.body().equals("Hub : OK")) { LOGGER.warn("Hub at " + heartBeatURL + " does not have us as registered"); return Status.UNREGISTERED; } return Status.OK; }
public Response execute(RemoteControlPool pool) throws IOException { final RemoteControlProxy remoteControl; final Response response; if (null == sessionId) { return new Response("Selenium Driver error: No sessionId provided for command '" + parameters.toString() + "'"); } remoteControl = pool.retrieve(sessionId()); pool.updateSessionLastActiveAt(sessionId); response = remoteControl.forward(parameters()); pool.updateSessionLastActiveAt(sessionId); return response; }
public Response execute(RemoteControlPool pool) throws IOException { final RemoteControlProxy remoteControl; final Response response; if (null == sessionId) { return new Response("Selenium Driver error: No sessionId provided for command '" + parameters.toString() + "'"); } remoteControl = pool.retrieve(sessionId()); pool.updateSessionLastActiveAt(sessionId); response = remoteControl.forward(parameters()); pool.updateSessionLastActiveAt(sessionId); return response; }