[JAVA-15018] Removed redundant apache httpclient dependency + added commons-codec (#13828)

This commit is contained in:
panos-kakos 2023-04-14 16:08:12 +03:00 committed by GitHub
parent 5c2126b626
commit 5471db832c
3 changed files with 13 additions and 13 deletions

View File

@ -15,9 +15,9 @@
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@ -52,11 +52,11 @@
</build>
<properties>
<httpclient.version>4.5.9</httpclient.version>
<angus.mail.version>2.0.1</angus.mail.version>
<async-http-client.version>2.4.5</async-http-client.version>
<jakarta.bind.version>2.3.3</jakarta.bind.version>
<greenmail.version>2.0.0-alpha-3</greenmail.version>
<commons-codec.version>1.15</commons-codec.version>
</properties>
</project>

View File

@ -21,7 +21,7 @@ public class HttpClient {
this.password = password;
}
public int sendRquestWithAuthHeader(String url) throws IOException {
public int sendRequestWithAuthHeader(String url) throws IOException {
HttpURLConnection connection = null;
try {
connection = createConnection(url);
@ -34,7 +34,7 @@ public class HttpClient {
}
}
public int sendRquestWithAuthenticator(String url) throws IOException {
public int sendRequestWithAuthenticator(String url) throws IOException {
setAuthenticator();
HttpURLConnection connection = null;

View File

@ -7,28 +7,28 @@ import org.junit.Test;
public class HttpClientLiveTest {
@Test
public void sendRquestWithAuthHeader() throws Exception {
public void sendRequestWithAuthHeader() throws Exception {
HttpClient httpClient = new HttpClient("user1", "pass1");
int status = httpClient.sendRquestWithAuthHeader("https://httpbin.org/basic-auth/user1/pass1");
int status = httpClient.sendRequestWithAuthHeader("https://httpbin.org/basic-auth/user1/pass1");
assertTrue(isSuccess(status));
}
@Test
public void sendRquestWithAuthHeader_whenIncorrectCredentials_thenNotSuccessful() throws Exception {
public void sendRequestWithAuthHeader_whenIncorrectCredentials_thenNotSuccessful() throws Exception {
HttpClient httpClient = new HttpClient("John", "Smith");
int status = httpClient.sendRquestWithAuthHeader("https://httpbin.org/basic-auth/user1/pass1");
int status = httpClient.sendRequestWithAuthHeader("https://httpbin.org/basic-auth/user1/pass1");
assertTrue(isUnauthorized(status));
}
@Test
public void sendRquestWithAuthenticator() throws Exception {
public void sendRequestWithAuthenticator() throws Exception {
HttpClient httpClient = new HttpClient("user2", "pass2");
int status = httpClient.sendRquestWithAuthenticator("https://httpbin.org/basic-auth/user2/pass2");
int status = httpClient.sendRequestWithAuthenticator("https://httpbin.org/basic-auth/user2/pass2");
assertTrue(isSuccess(status));
}
@ -37,7 +37,7 @@ public class HttpClientLiveTest {
public void sendRquestWithAuthenticator_whenIncorrectCredentials_thenNotSuccessful() throws Exception {
HttpClient httpClient = new HttpClient("John", "Smith");
int status = httpClient.sendRquestWithAuthenticator("https://httpbin.org/basic-auth/user2/pass2");
int status = httpClient.sendRequestWithAuthenticator("https://httpbin.org/basic-auth/user2/pass2");
assertTrue(isUnauthorized(status));
}