Java 15032 (#13913)

* JAVA-15032: Changes made for adding the test cases custom userAgent in request  header

* JAVA-15032: Changes made for adding the test cases custom userAgent in request  header

* JAVA-15032: Changes made for incorporarting review comments
This commit is contained in:
Bipin kumar 2023-05-01 23:39:29 +05:30 committed by GitHub
parent 2d2c842d2f
commit aa2b88285a
1 changed files with 8 additions and 12 deletions

View File

@ -25,26 +25,22 @@ class HttpClientHeadersLiveTest {
@Test
void whenClientUsesCustomUserAgent_thenCorrect() throws IOException {
final CloseableHttpClient client = HttpClients.custom()
.setUserAgent("Mozilla/5.0 Firefox/26.0")
.build();
final HttpGet request = new HttpGet(SAMPLE_URL);
try (CloseableHttpClient client = HttpClients.custom()
.setUserAgent("Mozilla/5.0 Firefox/26.0")
.build()) {
String response = client.execute(request, new BasicHttpClientResponseHandler());
logger.info("Response -> {}", response);
}
String response = client.execute(request, new BasicHttpClientResponseHandler());
logger.info("Response -> {}", response);
}
@Test
void whenRequestHasCustomUserAgent_thenCorrect() throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
final HttpGet request = new HttpGet(SAMPLE_URL);
request.setHeader(HttpHeaders.USER_AGENT, "Mozilla/5.0 Firefox/26.0");
try (CloseableHttpClient client = HttpClients.createDefault()) {
String response = client.execute(request, new BasicHttpClientResponseHandler());
logger.info("Response -> {}", response);
}
String response = client.execute(request, new BasicHttpClientResponseHandler());
logger.info("Response -> {}", response);
}
@Test