|
4 | 4 | import static org.mockito.Matchers.eq; |
5 | 5 | import static org.mockito.Mockito.verify; |
6 | 6 |
|
| 7 | +import androidx.test.platform.app.InstrumentationRegistry; |
7 | 8 | import android.os.Build; |
8 | | -import android.support.annotation.RequiresApi; |
9 | | -import android.support.test.InstrumentationRegistry; |
10 | | -import android.support.test.runner.AndroidJUnit4; |
| 9 | +import androidx.annotation.RequiresApi; |
| 10 | + |
11 | 11 | import com.datatheorem.android.trustkit.pinning.PinningValidationResult; |
12 | 12 | import com.datatheorem.android.trustkit.reporting.BackgroundReporter; |
13 | 13 | import java.io.IOException; |
|
23 | 23 | import okhttp3.Request; |
24 | 24 | import org.junit.Before; |
25 | 25 | import org.junit.Test; |
26 | | -import org.junit.runner.RunWith; |
27 | 26 | import org.mockito.Mock; |
28 | 27 | import org.mockito.MockitoAnnotations; |
29 | 28 |
|
30 | 29 | @SuppressWarnings("unchecked") |
31 | | -@RunWith(AndroidJUnit4.class) |
32 | 30 | public class HttpLibrariesTest { |
33 | 31 |
|
34 | 32 | @Mock |
@@ -58,7 +56,7 @@ public void testHttpsUrlConnectionWithTrustKit() throws MalformedURLException { |
58 | 56 | } |
59 | 57 | // Initialize TrustKit |
60 | 58 | TestableTrustKit.initializeWithNetworkSecurityConfiguration( |
61 | | - InstrumentationRegistry.getContext(), reporter); |
| 59 | + InstrumentationRegistry.getInstrumentation().getContext(), reporter); |
62 | 60 |
|
63 | 61 | // Test a connection |
64 | 62 | HttpsURLConnection connection = null; |
@@ -109,7 +107,7 @@ public void testHttpsUrlConnectionWithTrustKitApiLevelUnder17() throws IOExcepti |
109 | 107 | } |
110 | 108 | // Initialize TrustKit |
111 | 109 | TestableTrustKit.initializeWithNetworkSecurityConfiguration( |
112 | | - InstrumentationRegistry.getContext(), reporter); |
| 110 | + InstrumentationRegistry.getInstrumentation().getContext(), reporter); |
113 | 111 |
|
114 | 112 | // Test a connection |
115 | 113 | // Although the pins are invalid, the connection should succeed because TrustKit's pinning |
@@ -145,7 +143,7 @@ public void testOkhttp3WithTrustKit() throws MalformedURLException { |
145 | 143 | } |
146 | 144 | // Initialize TrustKit |
147 | 145 | TestableTrustKit.initializeWithNetworkSecurityConfiguration( |
148 | | - InstrumentationRegistry.getContext(), reporter); |
| 146 | + InstrumentationRegistry.getInstrumentation().getContext(), reporter); |
149 | 147 |
|
150 | 148 | // Test a connection |
151 | 149 | boolean didReceiveHandshakeError = false; |
@@ -191,7 +189,7 @@ public void testOkhttp3WithTrustKitOldBuilder() throws MalformedURLException { |
191 | 189 | } |
192 | 190 | // Initialize TrustKit |
193 | 191 | TestableTrustKit.initializeWithNetworkSecurityConfiguration( |
194 | | - InstrumentationRegistry.getContext(), reporter); |
| 192 | + InstrumentationRegistry.getInstrumentation().getContext(), reporter); |
195 | 193 |
|
196 | 194 | // Test a connection |
197 | 195 | boolean didReceiveHandshakeError = false; |
|
0 commit comments