diff --git a/pom.xml b/pom.xml
index 7c7121b5..48bdd2eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -126,15 +126,9 @@
- org.powermock
- powermock-module-junit4
- 2.0.9
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.9
+ org.mockito
+ mockito-core
+ 4.11.0
test
@@ -215,7 +209,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.7
+ 0.8.14
prepare-agent
@@ -301,7 +295,7 @@
org.sonatype.central
central-publishing-maven-plugin
- 0.4.0
+ 0.10.0
true
central
diff --git a/src/test/java/com/skyflow/utils/HttpUtilityTests.java b/src/test/java/com/skyflow/utils/HttpUtilityTests.java
index f7214690..c9595bb7 100644
--- a/src/test/java/com/skyflow/utils/HttpUtilityTests.java
+++ b/src/test/java/com/skyflow/utils/HttpUtilityTests.java
@@ -6,11 +6,9 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -26,13 +24,10 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({URL.class, HttpURLConnection.class})
+@RunWith(MockitoJUnitRunner.class)
public class HttpUtilityTests {
private static String INVALID_EXCEPTION_THROWN = "Should not have thrown any exception";
- @InjectMocks
- HttpUtility httpUtility;
@Mock
OutputStream outputStream;
private String expected;
@@ -60,7 +55,6 @@ protected URLConnection openConnection(final URL arg0) throws IOException {
}
@Test
- @PrepareForTest({URL.class, HttpURLConnection.class})
public void testSendRequest() {
try {
given(mockConnection.getRequestProperty("content-type")).willReturn("application/json");
@@ -68,7 +62,7 @@ public void testSendRequest() {
headers.put("content-type", "application/json");
JsonObject params = new JsonObject();
params.addProperty("key", "value");
- String response = httpUtility.sendRequest("GET", url, params, headers);
+ String response = HttpUtility.sendRequest("GET", url, params, headers);
Assert.assertEquals(expected, response);
} catch (Exception e) {
fail(INVALID_EXCEPTION_THROWN);
@@ -77,7 +71,6 @@ public void testSendRequest() {
@Test
- @PrepareForTest({URL.class, HttpURLConnection.class})
public void testSendRequestFormData() {
try {
given(mockConnection.getRequestProperty("content-type")).willReturn("multipart/form-data");
@@ -85,7 +78,7 @@ public void testSendRequestFormData() {
headers.put("content-type", "multipart/form-data");
JsonObject params = new JsonObject();
params.addProperty("key", "value");
- String response = httpUtility.sendRequest("GET", url, params, headers);
+ String response = HttpUtility.sendRequest("GET", url, params, headers);
Assert.assertEquals(expected, response);
} catch (Exception e) {
fail(INVALID_EXCEPTION_THROWN);
@@ -93,7 +86,6 @@ public void testSendRequestFormData() {
}
@Test
- @PrepareForTest({URL.class, HttpURLConnection.class})
public void testSendRequestFormURLEncoded() {
try {
given(mockConnection.getRequestProperty("content-type")).willReturn("application/x-www-form-urlencoded");
@@ -101,7 +93,7 @@ public void testSendRequestFormURLEncoded() {
headers.put("content-type", "application/x-www-form-urlencoded");
JsonObject params = new JsonObject();
params.addProperty("key", "value");
- String response = httpUtility.sendRequest("GET", url, params, headers);
+ String response = HttpUtility.sendRequest("GET", url, params, headers);
Assert.assertEquals(expected, response);
} catch (Exception e) {
fail(INVALID_EXCEPTION_THROWN);
@@ -109,11 +101,10 @@ public void testSendRequestFormURLEncoded() {
}
@Test
- @PrepareForTest({URL.class, HttpURLConnection.class})
public void testSendRequestError() {
try {
given(mockConnection.getResponseCode()).willReturn(500);
- String response = httpUtility.sendRequest("GET", url, null, null);
+ String response = HttpUtility.sendRequest("GET", url, null, null);
} catch (SkyflowException e) {
Assert.assertEquals(500, e.getHttpCode());
Assert.assertEquals(new Integer(123), e.getGrpcCode());