|
30 | 30 | import java.util.Collections;
|
31 | 31 | import java.util.List;
|
32 | 32 | import java.util.Map;
|
| 33 | +import java.util.Random; |
33 | 34 | import java.util.concurrent.CompletableFuture;
|
34 | 35 | import java.util.concurrent.ThreadLocalRandom;
|
35 | 36 | import java.util.concurrent.TimeUnit;
|
|
61 | 62 |
|
62 | 63 | public abstract class HttpClientDefaultPoxyConfigTest {
|
63 | 64 |
|
| 65 | + static Random random = new Random(); |
| 66 | + |
64 | 67 | private static final EnvironmentVariableHelper ENVIRONMENT_VARIABLE_HELPER = new EnvironmentVariableHelper();
|
65 | 68 |
|
66 | 69 | protected WireMockServer mockProxy = new WireMockServer(new WireMockConfiguration()
|
@@ -206,9 +209,14 @@ public void defaultProxyConfigurationSyncHttp(SdkHttpClient client, Class<? exte
|
206 | 209 | .request(request)
|
207 | 210 | .build());
|
208 | 211 |
|
209 |
| - if (exceptionType != null && proxyFailedCauseExceptionType != null) { |
210 |
| - assertThatExceptionOfType(exceptionType).isThrownBy(() -> executableHttpRequest.call()) |
211 |
| - .withCauseInstanceOf(proxyFailedCauseExceptionType); |
| 212 | + if (exceptionType != null) { |
| 213 | + if (proxyFailedCauseExceptionType != null) { |
| 214 | + assertThatExceptionOfType(exceptionType).isThrownBy(() -> executableHttpRequest.call()) |
| 215 | + .withCauseInstanceOf(proxyFailedCauseExceptionType); |
| 216 | + } else { |
| 217 | + |
| 218 | + assertThatExceptionOfType(exceptionType).isThrownBy(() -> executableHttpRequest.call()); |
| 219 | + } |
212 | 220 | } else {
|
213 | 221 | HttpExecuteResponse executeResponse = executableHttpRequest.call();
|
214 | 222 | assertThat(error.get()).isNull();
|
@@ -284,7 +292,7 @@ static SdkHttpFullRequest createRequest(URI endpoint,
|
284 | 292 | private int getRandomPort(int currentPort) {
|
285 | 293 | int randomPort;
|
286 | 294 | do {
|
287 |
| - randomPort = ThreadLocalRandom.current().nextInt(65535); |
| 295 | + randomPort = random.nextInt(65535); |
288 | 296 | } while (randomPort == currentPort);
|
289 | 297 | return randomPort;
|
290 | 298 | }
|
|
0 commit comments