Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(apache-v5): confirm behavior of connect timeout #2014

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,39 @@

/** Tests {@link Apache5HttpTransport}. */
public class Apache5HttpTransportTest {
private static final String NO_CONNECT_URL = "https://google.com:81";

@Test(timeout = 10_000L)
public void testConnectTimeoutGet() throws IOException {
HttpTransport transport = new Apache5HttpTransport();
try {
transport
.createRequestFactory()
.buildGetRequest(new GenericUrl(NO_CONNECT_URL))
.setConnectTimeout(10)
.execute();
fail("No exception thrown for HTTP error response");
} catch (ConnectTimeoutException e) {
assertTrue(
"Expected exception message to contain a connection timeout message",
e.getMessage().contains("Connect timed out"));
}
}

@Test(timeout = 10_000L)
public void testConnectTimeoutPost() throws IOException {
Apache5HttpTransport transport = new Apache5HttpTransport();
Apache5HttpRequest request = transport.buildRequest("POST", NO_CONNECT_URL);
request.setTimeout(10, 0);
try {
request.execute();
fail("No exception thrown for HTTP error response");
} catch (ConnectTimeoutException e) {
assertTrue(
"Expected exception message to contain a connection timeout message",
e.getMessage().contains("Connect timed out"));
}
}

@Test
public void testApacheHttpTransport() {
Expand Down
Loading