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:
parent
2d2c842d2f
commit
aa2b88285a
@ -25,26 +25,22 @@ class HttpClientHeadersLiveTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenClientUsesCustomUserAgent_thenCorrect() throws IOException {
|
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);
|
final HttpGet request = new HttpGet(SAMPLE_URL);
|
||||||
|
|
||||||
try (CloseableHttpClient client = HttpClients.custom()
|
String response = client.execute(request, new BasicHttpClientResponseHandler());
|
||||||
.setUserAgent("Mozilla/5.0 Firefox/26.0")
|
logger.info("Response -> {}", response);
|
||||||
.build()) {
|
|
||||||
|
|
||||||
String response = client.execute(request, new BasicHttpClientResponseHandler());
|
|
||||||
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");
|
||||||
|
String response = client.execute(request, new BasicHttpClientResponseHandler());
|
||||||
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
logger.info("Response -> {}", response);
|
||||||
String response = client.execute(request, new BasicHttpClientResponseHandler());
|
|
||||||
logger.info("Response -> {}", response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user