@Test(expected = ConnectException.class) public void should_stop_runner_directly() throws IOException { runner.run(); try { assertThat(helper.get(root()), is("foo")); } catch (HttpHostConnectException e) { fail(e.getMessage()); } runner.stop(); shutdownMoco(SHUTDOWN_PORT, SHUTDOWN_MOCO_KEY); }
@Test(expected = HttpHostConnectException.class) public void should_stop_runner_via_shutdown_task() throws IOException { runner.run(); try { assertThat(helper.get(root()), is("foo")); } catch (HttpHostConnectException e) { fail(e.getMessage()); } ShutdownTask task = new ShutdownTask(SHUTDOWN_MOCO_KEY); task.run(new String[]{"-s", Integer.toString(SHUTDOWN_PORT)}); waitChangeHappens(); helper.get(root()); }
@Test(expected = HttpHostConnectException.class) public void should_shutdown_runner_by_socket() throws IOException { runner.run(); try { assertThat(helper.get(root()), is("foo")); } catch (HttpHostConnectException e) { fail(e.getMessage()); } shutdownMoco(SHUTDOWN_PORT, SHUTDOWN_MOCO_KEY); waitChangeHappens(); helper.get(root()); }
@Test(expected = HttpHostConnectException.class) public void should_shutdown_with_shutdown_port() throws IOException { RunnerFactory factory = new RunnerFactory(SHUTDOWN_MOCO_KEY); runner = factory.createRunner(httpArgs().withPort(port()).withConfigurationFile("src/test/resources/foo.json").build()); runner.run(); try { assertThat(helper.get(root()), is("foo")); } catch (HttpHostConnectException e) { fail(e.getMessage()); } ShutdownRunner shutdownRunner = (ShutdownRunner) runner; int port = shutdownRunner.shutdownPort(); shutdownMoco(port, SHUTDOWN_MOCO_KEY); waitChangeHappens(); helper.get(root()); } }
public CloseableHttpResponse execute() { CloseableHttpResponse response; try { response = closeableHttpClient.execute(httpRequestBase, context); } catch (SocketTimeoutException ste) { throw new RuntimeException("Socket timeout: " + ste.getMessage(), ste); } catch (HttpHostConnectException connectEx) { throw new RuntimeException("Connection error: " + connectEx.getMessage(), connectEx); } catch (IOException e) { throw new RuntimeException("Error while executing http request: " + e.getMessage(), e); } return response; } }
public CloseableHttpResponse execute() { CloseableHttpResponse response; try { response = closeableHttpClient.execute(httpRequestBase, context); } catch (SocketTimeoutException ste) { throw new RuntimeException("Socket timeout: " + ste.getMessage(), ste); } catch (HttpHostConnectException connectEx) { throw new RuntimeException("Connection error: " + connectEx.getMessage(), connectEx); } catch (IOException e) { throw new RuntimeException("Error while executing http request: " + e.getMessage(), e); } return response; } }
public CloseableHttpResponse execute() { CloseableHttpResponse response; try { response = closeableHttpClient.execute(httpRequestBase, context); } catch (SocketTimeoutException ste) { throw new RuntimeException("Socket timeout: " + ste.getMessage(), ste); } catch (HttpHostConnectException connectEx) { throw new RuntimeException("Connection error: " + connectEx.getMessage(), connectEx); } catch (IOException e) { throw new RuntimeException("Error while executing http request: " + e.getMessage(), e); } return response; } }
public CloseableHttpResponse execute() { CloseableHttpResponse response; try { response = closeableHttpClient.execute(httpRequestBase, context); } catch (SocketTimeoutException ste) { throw new RuntimeException("Socket timeout: " + ste.getMessage(), ste); } catch (HttpHostConnectException connectEx) { throw new RuntimeException("Connection error: " + connectEx.getMessage(), connectEx); } catch (IOException e) { throw new RuntimeException("Error while executing http request: " + e.getMessage(), e); } return response; } }
protected HttpResponse exec(String url) { try { HttpGet httpget = new HttpGet(url); if (isSecured) { return client.execute(httpHost, httpget, getLocalContext(httpHost)); } else { return client.execute(httpHost, httpget); } } catch (HttpHostConnectException e) { logger.log(SystemProperties.DIAG, "Host connection error.", e); throw new RuntimeException("Host connection error: " + e.getMessage()); } catch (Exception e) { logger.log(SystemProperties.DIAG, "Query Execution Error", e); throw new RuntimeException("Query Execution Error: " + e.getMessage()); } }
log.warning("ERROR: getApiJson: (url=" + url + ") " + e.getMessage()); return null; } catch (final Exception e) {
System.out.println("Host Not Found : "+ e.getMessage())
} catch (HttpHostConnectException e) { log.log(Level.SEVERE, "Can't connect to host", e); throw new WinRMConnectException("Can't connect to host: " + e.getMessage(), e); } catch (IOException e) { log.log(Level.SEVERE, "I/O Exception in HTTP POST", e);
} catch (HttpHostConnectException e) { log.log(Level.SEVERE, "Can't connect to host", e); throw new WinRMConnectException("Can't connect to host: " + e.getMessage(), e); } catch (IOException e) { log.log(Level.SEVERE, "I/O Exception in HTTP POST", e);
this.bearerToken = "Bearer " + this.token; } catch (HttpHostConnectException httpHostConnectException) { throw new SDKException("Host unreachable: " + httpHostConnectException.getMessage()); } catch (Exception e) { throw new SDKException(e);
throw new CloudletException(e.getMessage(), e);
protected TransmissionResponse sendHttpRequest(HttpPost httpPost) throws OxalisTransmissionException { Span span = tracer.buildSpan("execute").asChildOf(root).start(); try (CloseableHttpClient httpClient = httpClientProvider.get()) { BasicHttpContext basicHttpContext = new BasicHttpContext(); basicHttpContext.setAttribute(Constants.PARENT_CONTEXT, span.context()); CloseableHttpResponse response = httpClient.execute(httpPost, basicHttpContext); span.finish(); return handleResponse(response); } catch (HttpHostConnectException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Receiving server does not seem to be running.", transmissionRequest.getEndpoint().getAddress(), e); } catch (SSLHandshakeException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Possible invalid SSL Certificate at the other end.", transmissionRequest.getEndpoint().getAddress(), e); } catch (IOException e) { span.setTag("exception", String.valueOf(e.getMessage())); throw new OxalisTransmissionException(transmissionRequest.getEndpoint().getAddress(), e); } finally { span.finish(); } }
/** * * @param path * @param remotePath * @param remoteUser * @param remotePw * @param serverPortAddress * @param am * @return upload result or -1: general exception, -2: host not reachable, -3: internet not reachable */ public static int sendFile(Path path, String remotePath, String remoteUser, String remotePw, String serverPortAddress, ApplicationManager am) { try { return upload(path, remotePath, remoteUser, remotePw, serverPortAddress, am); } catch (HttpHostConnectException e) { am.getLogger().warn(e.getMessage()); am.getLogger().debug("Exception detail:", e); return -2; } catch (UnknownHostException| NoRouteToHostException e) { am.getLogger().warn(e.getMessage()); am.getLogger().debug("Exception detail:", e); return -3; } catch (KeyManagementException | NoSuchAlgorithmException | IOException e) { am.getLogger().warn(e.getMessage()); am.getLogger().debug("Exception detail:", e); return -1; } }
protected TransmissionResponse sendHttpRequest(HttpPost httpPost) throws OxalisTransmissionException { Span span = tracer.buildSpan("execute").asChildOf(root).start(); try (CloseableHttpClient httpClient = httpClientProvider.get()) { BasicHttpContext basicHttpContext = new BasicHttpContext(); basicHttpContext.setAttribute(Constants.PARENT_CONTEXT, span.context()); CloseableHttpResponse response = httpClient.execute(httpPost, basicHttpContext); span.finish(); return handleResponse(response); } catch (SocketTimeoutException e) { span.setTag("exception", String.valueOf(e.getMessage())); throw new OxalisTransmissionException("Receiving server has not sent anything back within SOCKET_TIMEOUT", transmissionRequest.getEndpoint().getAddress(), e); } catch (HttpHostConnectException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Receiving server does not seem to be running.", transmissionRequest.getEndpoint().getAddress(), e); } catch (SSLHandshakeException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Possible invalid SSL Certificate at the other end.", transmissionRequest.getEndpoint().getAddress(), e); } catch (IOException e) { span.setTag("exception", String.valueOf(e.getMessage())); throw new OxalisTransmissionException(transmissionRequest.getEndpoint().getAddress(), e); } finally { span.finish(); } }