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

View File

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