@Override public int getConnectTimeout() { return delegate.getConnectTimeout(); }
@Override public int getConnectTimeout() { return delegate.getConnectTimeout(); }
checkForCommonExceptionTypes(ex); final String msg = format("Error saving '%s' to file '%s'%nConnection Timeout: %d%nEncoding: %s%n", url.toString(), outputPath.getAbsolutePath(), conn.getConnectTimeout(), encoding); throw new DownloadFailedException(msg, ex); } catch (Exception ex) { final String msg = format("Unexpected exception saving '%s' to file '%s'%nConnection Timeout: %d%nEncoding: %s%n", url.toString(), outputPath.getAbsolutePath(), conn.getConnectTimeout(), encoding); throw new DownloadFailedException(msg, ex); } finally {
uc.setConnectTimeout(request.resolveProperty(ClientProperties.CONNECT_TIMEOUT, uc.getConnectTimeout()));
uc.setConnectTimeout(request.resolveProperty(ClientProperties.CONNECT_TIMEOUT, uc.getConnectTimeout()));
uc.setConnectTimeout(request.resolveProperty(ClientProperties.CONNECT_TIMEOUT, uc.getConnectTimeout()));
@Test public void shouldCreateHttpUrlConnection() throws IOException { // given final String parsedDefaultHost = "clients3.google.com"; // when HttpURLConnection connection = strategy.createHttpUrlConnection(getHost(), PORT, TIMEOUT_IN_MS); // then assertThat(connection).isNotNull(); assertThat(connection.getURL().getHost()).isEqualTo(parsedDefaultHost); assertThat(connection.getURL().getPort()).isEqualTo(PORT); assertThat(connection.getConnectTimeout()).isEqualTo(TIMEOUT_IN_MS); assertThat(connection.getReadTimeout()).isEqualTo(TIMEOUT_IN_MS); assertThat(connection.getInstanceFollowRedirects()).isFalse(); assertThat(connection.getUseCaches()).isFalse(); }
/** * Returns input stream to read server response from. * * @return input stream to read server response from. */ public InputStream getInputStream() { try { return connection.getInputStream(); }catch(SocketTimeoutException e){ throw new HttpException("Failed URL: " + url + ", waited for: " + connection.getConnectTimeout() + " milliseconds", e); }catch (Exception e) { throw new HttpException("Failed URL: " + url, e); } }
@Override public int getConnectTimeout() { return super.getConnectTimeout(); }
@Override public int getConnectTimeout() { return delegate.getConnectTimeout(); }
@Override public int getConnectTimeout () { return this.connection.getConnectTimeout(); }
@Override public int getConnectTimeout() { return delegate.getConnectTimeout(); }
@Override public int getConnectTimeout() { return delegate.getConnectTimeout(); }
public HttpURLConnection connect(URL url) throws IOException { HttpURLConnection con = (HttpURLConnection) ProxyConfiguration.open(url); // Set default timeouts in case there are none if (con.getConnectTimeout() == 0) { con.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT); } if (con.getReadTimeout() == 0) { con.setReadTimeout(DEFAULT_READ_TIMEOUT); } return con; } }
@Test @DisplayName(value = "Expected success, calling the \"setupConnection\" method if the connection timeout > 0") public void unitTest_20180503194559() throws Exception { GitlabAPI api = mock(GitlabAPI.class); when(api.getConnectionTimeout()).thenReturn(456); GitlabHTTPRequestor http = new GitlabHTTPRequestor(api); URL url = new URL("http://test.url"); Method method = GitlabHTTPRequestor.class.getDeclaredMethod("setupConnection", URL.class); method.setAccessible(true); HttpURLConnection connection = (HttpURLConnection) method.invoke(http, url); assertThat(connection.getConnectTimeout(), is(456)); }
@Test @DisplayName(value = "Expected success, calling the \"setupConnection\" method if the connection timeout = 0") public void unitTest_20180503194340() throws Exception { GitlabAPI api = mock(GitlabAPI.class); when(api.getConnectionTimeout()).thenReturn(0); GitlabHTTPRequestor http = new GitlabHTTPRequestor(api); URL url = new URL("http://test.url"); Method method = GitlabHTTPRequestor.class.getDeclaredMethod("setupConnection", URL.class); method.setAccessible(true); HttpURLConnection connection = (HttpURLConnection) method.invoke(http, url); assertThat(connection.getConnectTimeout(), is(0)); }
@Test(timeout = 1000) public void setsDefaultConnectTimeoutWhenNoTimeoutIsSet() throws IOException { HttpClient httpClient = new HttpClient(); HttpURLConnection connection = httpClient.init("http://example.com/"); assertEquals(30000, connection.getConnectTimeout()); }
@Test public void setsConnectTimeout() throws IOException { PayPalHttpClient httpClient = new PayPalHttpClient(); HttpURLConnection connection = httpClient.init("http://example.com"); assertEquals(90000, connection.getConnectTimeout()); } }
@Test(timeout = 1000) public void setsConnectTimeout() throws IOException { HttpClient httpClient = new HttpClient() .setConnectTimeout(1000); HttpURLConnection connection = httpClient.init("http://example.com/"); assertEquals(1000, connection.getConnectTimeout()); }
@Test public void testSetConnectionTimeout() throws IOException { HttpURLConnection connection = (HttpURLConnection) mockServerURL.openConnection(); TusClient client = new TusClient(); assertEquals(client.getConnectTimeout(), 5000); client.setConnectTimeout(3000); assertEquals(client.getConnectTimeout(), 3000); client.prepareConnection(connection); assertEquals(connection.getConnectTimeout(), 3000); }