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

View File

@ -21,7 +21,7 @@ public class HttpClient {
this.password = password; this.password = password;
} }
public int sendRquestWithAuthHeader(String url) throws IOException { public int sendRequestWithAuthHeader(String url) throws IOException {
HttpURLConnection connection = null; HttpURLConnection connection = null;
try { try {
connection = createConnection(url); 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(); setAuthenticator();
HttpURLConnection connection = null; HttpURLConnection connection = null;

View File

@ -7,28 +7,28 @@ import org.junit.Test;
public class HttpClientLiveTest { public class HttpClientLiveTest {
@Test @Test
public void sendRquestWithAuthHeader() throws Exception { public void sendRequestWithAuthHeader() throws Exception {
HttpClient httpClient = new HttpClient("user1", "pass1"); 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)); assertTrue(isSuccess(status));
} }
@Test @Test
public void sendRquestWithAuthHeader_whenIncorrectCredentials_thenNotSuccessful() throws Exception { public void sendRequestWithAuthHeader_whenIncorrectCredentials_thenNotSuccessful() throws Exception {
HttpClient httpClient = new HttpClient("John", "Smith"); 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)); assertTrue(isUnauthorized(status));
} }
@Test @Test
public void sendRquestWithAuthenticator() throws Exception { public void sendRequestWithAuthenticator() throws Exception {
HttpClient httpClient = new HttpClient("user2", "pass2"); 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)); assertTrue(isSuccess(status));
} }
@ -37,7 +37,7 @@ public class HttpClientLiveTest {
public void sendRquestWithAuthenticator_whenIncorrectCredentials_thenNotSuccessful() throws Exception { public void sendRquestWithAuthenticator_whenIncorrectCredentials_thenNotSuccessful() throws Exception {
HttpClient httpClient = new HttpClient("John", "Smith"); 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)); assertTrue(isUnauthorized(status));
} }