From fac5e3d48a9f5fade7e2ea2f14ce3224de4dbe90 Mon Sep 17 00:00:00 2001 From: Stephane Bailliez Date: Mon, 3 Aug 2020 09:56:12 -0400 Subject: [PATCH] - Update very old dependencies that are least susceptible to cause conflict in today's environment - Update gson to 2.8.6 - Update httpclient to 4.5.12 and httpcore to 4.4.13 - Update slf4j to 1.7.30 - For internal use, update junit to 4.13, mockito to 3.4.6 and all maven plugins - Fix unit test to have correct mocking and remove deprecated usages --- pom.xml | 26 +++++++++---------- .../client/AbstractSailthruClientTest.java | 19 +++++++------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index 8c8a110..8efd5d1 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ junit junit - 4.9 + 4.13 jar test true @@ -62,38 +62,38 @@ com.google.code.gson gson - 2.2.4 + 2.8.6 compile org.apache.httpcomponents httpclient - 4.3.6 + 4.5.12 org.apache.httpcomponents httpcore - 4.3 + 4.4.13 org.apache.httpcomponents httpmime - 4.3.1 + 4.5.12 org.slf4j slf4j-api - 1.7.5 + 1.7.30 org.slf4j slf4j-simple - 1.7.5 + 1.7.30 org.mockito mockito-core - 1.10.17 + 3.4.6 test @@ -114,7 +114,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.3 + 1.6.8 true sonatype-nexus-staging @@ -125,7 +125,7 @@ org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + 3.8.1 1.6 1.6 @@ -135,7 +135,7 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.2.1 attach-sources @@ -153,7 +153,7 @@ true none - 3.0.0 + 3.2.0 attach-javadocs @@ -171,7 +171,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.0.0 + 3.2.0 ${basedir}/src/main/javadoc/stylesheet.css public diff --git a/src/test/com/sailthru/client/AbstractSailthruClientTest.java b/src/test/com/sailthru/client/AbstractSailthruClientTest.java index 6898638..af61e73 100644 --- a/src/test/com/sailthru/client/AbstractSailthruClientTest.java +++ b/src/test/com/sailthru/client/AbstractSailthruClientTest.java @@ -1,7 +1,6 @@ package com.sailthru.client; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import com.sailthru.client.http.SailthruHttpClient; import com.sailthru.client.params.Send; import org.apache.http.HttpHost; @@ -18,7 +17,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -26,9 +25,9 @@ import java.util.Date; import java.util.Map; -import static junit.framework.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -59,7 +58,7 @@ public void testGetLastRateLimitInfo() throws IOException { long resetTs = ((new Date().getTime() / 1000) * 1000) + 18000; // pretend the top of the next minute is 18 seconds from now Date resetDate = new Date(resetTs); CloseableHttpResponse httpResponse = getMockHttpResponseWithRateLimitHeaders(limit, remaining, resetDate); - doReturn(httpResponse).when(httpClient).execute(any(HttpHost.class), any(HttpRequest.class), any(HttpContext.class)); + doReturn(httpResponse).when(httpClient).execute(any(HttpHost.class), any(HttpRequest.class), (HttpContext)any()); sailthruClient.apiGet(ApiAction.send, ImmutableMap.of(Send.PARAM_SEND_ID, "some valid send id")); @@ -95,7 +94,7 @@ public void testGetLastRateLimitInfoDifferentActions() throws IOException { doReturn(sendHttpResponse).doReturn(listHttpResponse) .doReturn(returnHttpResponse) .when(httpClient) - .execute(any(HttpHost.class), any(HttpRequest.class), any(HttpContext.class)); + .execute(any(HttpHost.class), any(HttpRequest.class), (HttpContext)any()); sailthruClient.apiGet(ApiAction.send, ImmutableMap.of(Send.PARAM_SEND_ID, "some valid send id")); sailthruClient.apiGet(ApiAction.list, ImmutableMap.of("list", "some list")); @@ -133,7 +132,7 @@ public void testGetLastRateLimitInfoDifferentMethods() throws IOException { Date postResetDate = new Date(postResetTs); CloseableHttpResponse postHttpResponse = getMockHttpResponseWithRateLimitHeaders(postLimit, postRemaining, postResetDate); - doReturn(getHttpResponse).doReturn(postHttpResponse).when(httpClient).execute(any(HttpHost.class), any(HttpRequest.class), any(HttpContext.class)); + doReturn(getHttpResponse).doReturn(postHttpResponse).when(httpClient).execute(any(HttpHost.class), any(HttpRequest.class), (HttpContext)any()); sailthruClient.apiGet(ApiAction.list, ImmutableMap.of("list", "some list")); sailthruClient.apiPost(ApiAction.list, ImmutableMap.of("list", "some new list")); @@ -152,10 +151,10 @@ public void testGetLastRateLimitInfoDifferentMethods() throws IOException { @Test public void testReturnUrl() throws IOException { CloseableHttpResponse response = getMockHttpResponseWithRateLimitHeaders(1, 1, new Date()); - doReturn(response).when(httpClient).execute(any(HttpHost.class), any(HttpRequest.class), any(HttpContext.class)); + doReturn(response).when(httpClient).execute(any(HttpHost.class), any(HttpRequest.class), (HttpContext)any()); sailthruClient.apiPost(ApiAction.RETURN, Collections.emptyMap()); verify(httpClient).executeHttpRequest(eq("https://api.sailthru.com/return"), eq(AbstractSailthruClient.HttpRequestMethod.POST), - any(Map.class), any(ResponseHandler.class), any(Map.class)); + any(Map.class), any(ResponseHandler.class), (Map)any()); } private CloseableHttpResponse getMockHttpResponseWithRateLimitHeaders(int limit, int remaining, Date reset) {