@Test
public void shouldRespectUserConfigurationTimeoutOverridingSystemConfigurationTimeout() throws Throwable {
// pre-conditions
final int timeout = 1000;
final int serverDelay = timeout * 15;
IOpenShiftConfiguration configuration = new OpenShiftConfigurationFake(null,"3000","2000","1000");
IHttpClient httpClient = new UrlConnectionHttpClientBuilder()
.setAcceptMediaType(ACCEPT_APPLICATION_JSON)
.setUserAgent("com.openshift.client.test")
.setConfigTimeout(configuration.getTimeout())
.client();
WaitingHttpServerFake serverFake = startWaitingHttpServerFake(serverDelay);
long startTime = System.currentTimeMillis();
// operations
try {
httpClient.get(serverFake.getUrl(), IHttpClient.NO_TIMEOUT);
fail("Timeout expected.");
} catch (SocketTimeoutException e) {
// assert
assertThat(System.currentTimeMillis() - startTime)
.isGreaterThan(configuration.getTimeout() - 20)
.isLessThan(configuration.getTimeout() + 20);
} finally {
serverFake.stop();
}
}