Java-15020: Minor fix in HttpClientParamsLiveTest (#14284)
This commit is contained in:
parent
462cfaf980
commit
f70b3a06ab
@ -3,7 +3,6 @@ package com.baeldung.httpclient;
|
|||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@ -13,10 +12,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
||||||
import org.apache.hc.client5.http.classic.methods.HttpPost;
|
import org.apache.hc.client5.http.classic.methods.HttpPost;
|
||||||
|
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
|
||||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
||||||
import org.apache.hc.client5.http.ClientProtocolException;
|
|
||||||
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
|
|
||||||
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||||
import org.apache.hc.core5.http.HttpStatus;
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
import org.apache.hc.core5.http.NameValuePair;
|
import org.apache.hc.core5.http.NameValuePair;
|
||||||
@ -42,7 +40,7 @@ class HttpClientParamsLiveTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenStringNameValuePairParams_whenGetRequest_thenResponseOk() throws URISyntaxException, ClientProtocolException, IOException {
|
void givenStringNameValuePairParams_whenGetRequest_thenResponseOk() throws URISyntaxException, IOException {
|
||||||
HttpGet httpGet = new HttpGet("https://postman-echo.com/get");
|
HttpGet httpGet = new HttpGet("https://postman-echo.com/get");
|
||||||
URI uri = new URIBuilder(httpGet.getUri()).addParameter("param1", "value1")
|
URI uri = new URIBuilder(httpGet.getUri()).addParameter("param1", "value1")
|
||||||
.addParameter("param2", "value2")
|
.addParameter("param2", "value2")
|
||||||
@ -59,7 +57,7 @@ class HttpClientParamsLiveTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenStringNameValuePairParams_whenPostRequest_thenResponseOk() throws URISyntaxException, ClientProtocolException, IOException {
|
void givenStringNameValuePairParams_whenPostRequest_thenResponseOk() throws URISyntaxException, IOException {
|
||||||
HttpPost httpPost = new HttpPost("https://postman-echo.com/post");
|
HttpPost httpPost = new HttpPost("https://postman-echo.com/post");
|
||||||
URI uri = new URIBuilder(httpPost.getUri()).addParameter("param1", "value1")
|
URI uri = new URIBuilder(httpPost.getUri()).addParameter("param1", "value1")
|
||||||
.addParameter("param2", "value2")
|
.addParameter("param2", "value2")
|
||||||
@ -76,7 +74,7 @@ class HttpClientParamsLiveTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenNameValuePairParams_whenGetRequest_thenResponseOk() throws URISyntaxException, ClientProtocolException, IOException {
|
void givenNameValuePairParams_whenGetRequest_thenResponseOk() throws URISyntaxException, IOException {
|
||||||
HttpGet httpGet = new HttpGet("https://postman-echo.com/get");
|
HttpGet httpGet = new HttpGet("https://postman-echo.com/get");
|
||||||
URI uri = new URIBuilder(httpGet.getUri()).addParameters(nameValuePairs)
|
URI uri = new URIBuilder(httpGet.getUri()).addParameters(nameValuePairs)
|
||||||
.build();
|
.build();
|
||||||
@ -92,7 +90,7 @@ class HttpClientParamsLiveTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenNameValuePairsParams_whenPostRequest_thenResponseOk() throws URISyntaxException, ClientProtocolException, IOException {
|
void givenNameValuePairsParams_whenPostRequest_thenResponseOk() throws URISyntaxException, IOException {
|
||||||
HttpPost httpPost = new HttpPost("https://postman-echo.com/post");
|
HttpPost httpPost = new HttpPost("https://postman-echo.com/post");
|
||||||
URI uri = new URIBuilder(httpPost.getUri()).addParameters(nameValuePairs)
|
URI uri = new URIBuilder(httpPost.getUri()).addParameters(nameValuePairs)
|
||||||
.build();
|
.build();
|
||||||
@ -108,7 +106,7 @@ class HttpClientParamsLiveTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenUrlEncodedEntityParams_whenPostRequest_thenResponseOk() throws URISyntaxException, ClientProtocolException, IOException {
|
void givenUrlEncodedEntityParams_whenPostRequest_thenResponseOk() throws IOException {
|
||||||
HttpPost httpPost = new HttpPost("https://postman-echo.com/post");
|
HttpPost httpPost = new HttpPost("https://postman-echo.com/post");
|
||||||
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, StandardCharsets.UTF_8));
|
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user