Java 15029 (#13257)

* [JAVA-15029] Formatting

* [JAVA-15029] Clean up

Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com>
This commit is contained in:
panos-kakos 2023-01-13 14:30:06 +00:00 committed by GitHub
parent 1f987c4bb3
commit 58882b371c
1 changed files with 11 additions and 20 deletions

View File

@ -26,24 +26,10 @@ class HttpClientCookieLiveTest {
final void whenSettingCookiesOnARequest_thenCorrect() throws IOException {
final HttpGet request = new HttpGet("http://www.github.com");
request.setHeader("Cookie", "JSESSIONID=1234");
try (CloseableHttpClient client = HttpClients.createDefault(); CloseableHttpResponse response = (CloseableHttpResponse) client.execute(request, new CustomHttpClientResponseHandler());) {
assertThat(response.getCode(), equalTo(200));
}
}
@Test
final void givenUsingDeprecatedApi_whenSettingCookiesOnTheHttpClient_thenCorrect() throws IOException {
final BasicCookieStore cookieStore = new BasicCookieStore();
final BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234");
cookie.setDomain(".github.com");
cookie.setAttribute("domain", "true");
cookie.setPath("/");
cookieStore.addCookie(cookie);
final HttpGet request = new HttpGet("https://www.github.com");
try (CloseableHttpClient client = HttpClientBuilder.create()
.setDefaultCookieStore(cookieStore)
.build(); CloseableHttpResponse response = (CloseableHttpResponse) client.execute(request, new CustomHttpClientResponseHandler())) {
try (CloseableHttpClient client = HttpClients.createDefault();
CloseableHttpResponse response = (CloseableHttpResponse) client
.execute(request, new CustomHttpClientResponseHandler())) {
assertThat(response.getCode(), equalTo(200));
}
}
@ -58,9 +44,12 @@ class HttpClientCookieLiveTest {
cookieStore.addCookie(cookie);
final HttpGet request = new HttpGet("http://www.github.com");
try (CloseableHttpClient client = HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build();
CloseableHttpResponse response = (CloseableHttpResponse) client.execute(request, new CustomHttpClientResponseHandler())) {
try (CloseableHttpClient client = HttpClientBuilder.create()
.setDefaultCookieStore(cookieStore)
.build();
CloseableHttpResponse response = (CloseableHttpResponse) client
.execute(request, new CustomHttpClientResponseHandler())) {
assertThat(response.getCode(), equalTo(200));
}
@ -79,7 +68,9 @@ class HttpClientCookieLiveTest {
// localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); // before 4.3
try (CloseableHttpClient client = HttpClientBuilder.create().build();
CloseableHttpResponse response = (CloseableHttpResponse) client.execute(request, localContext, new CustomHttpClientResponseHandler())) {
CloseableHttpResponse response = (CloseableHttpResponse) client
.execute(request, localContext, new CustomHttpClientResponseHandler())) {
assertThat(response.getCode(), equalTo(200));
}
}