11package com .datatheorem .android .trustkit .config ;
22
3- import static junit .framework .Assert .assertEquals ;
4- import static junit .framework .Assert .assertFalse ;
5- import static junit .framework .Assert .assertNotNull ;
6- import static junit .framework .Assert .assertNull ;
7- import static junit .framework .Assert .assertTrue ;
8-
93import android .content .Context ;
10- import android .support .test .InstrumentationRegistry ;
11- import android .support .test .runner .AndroidJUnit4 ;
4+
5+ import androidx .test .platform .app .InstrumentationRegistry ;
6+
7+ import org .junit .Test ;
8+ import org .xmlpull .v1 .XmlPullParser ;
9+ import org .xmlpull .v1 .XmlPullParserException ;
10+ import org .xmlpull .v1 .XmlPullParserFactory ;
11+
1212import java .io .IOException ;
1313import java .io .InputStream ;
1414import java .io .StringReader ;
2121import java .util .Date ;
2222import java .util .HashSet ;
2323import java .util .Locale ;
24- import org .junit .Test ;
25- import org .junit .runner .RunWith ;
26- import org .xmlpull .v1 .XmlPullParser ;
27- import org .xmlpull .v1 .XmlPullParserException ;
28- import org .xmlpull .v1 .XmlPullParserFactory ;
2924
30- @ RunWith (AndroidJUnit4 .class )
25+ import static junit .framework .Assert .assertEquals ;
26+ import static junit .framework .Assert .assertFalse ;
27+ import static junit .framework .Assert .assertNotNull ;
28+ import static junit .framework .Assert .assertNull ;
29+ import static junit .framework .Assert .assertTrue ;
30+
3131public class TrustKitConfigurationTest {
3232
3333 private XmlPullParser parseXmlString (String xmlString ) throws XmlPullParserException {
@@ -42,7 +42,7 @@ private XmlPullParser parseXmlString(String xmlString) throws XmlPullParserExcep
4242
4343 @ Test
4444 public void testBadHostnameValidation () throws XmlPullParserException , IOException , CertificateException {
45- Context context = InstrumentationRegistry .getContext ();
45+ Context context = InstrumentationRegistry .getInstrumentation (). getContext ();
4646 String xml = "" +
4747 "<?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n " +
4848 "<network-security-config>\n " +
@@ -70,7 +70,7 @@ public void testBadHostnameValidation() throws XmlPullParserException, IOExcepti
7070 @ Test
7171 public void testDefaultValues () throws XmlPullParserException , IOException , ParseException ,
7272 CertificateException {
73- Context context = InstrumentationRegistry .getContext ();
73+ Context context = InstrumentationRegistry .getInstrumentation (). getContext ();
7474 String xml = "" +
7575 "<?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n " +
7676 "<network-security-config>\n " +
@@ -114,7 +114,7 @@ public void testDefaultValues() throws XmlPullParserException, IOException, Pars
114114 @ Test
115115 public void testIncludeSubdomainsAndNoTrustkitTag () throws XmlPullParserException , IOException ,
116116 ParseException , CertificateException {
117- Context context = InstrumentationRegistry .getContext ();
117+ Context context = InstrumentationRegistry .getInstrumentation (). getContext ();
118118 String xml = "" +
119119 "<?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n " +
120120 "<network-security-config>\n " +
@@ -148,7 +148,7 @@ public void testIncludeSubdomainsAndNoTrustkitTag() throws XmlPullParserExceptio
148148 @ Test
149149 public void testEnforcePinning () throws XmlPullParserException , IOException ,
150150 ParseException , CertificateException {
151- Context context = InstrumentationRegistry .getContext ();
151+ Context context = InstrumentationRegistry .getInstrumentation (). getContext ();
152152 String xml = "" +
153153 "<?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n " +
154154 "<network-security-config>\n " +
@@ -174,7 +174,7 @@ public void testEnforcePinning() throws XmlPullParserException, IOException,
174174 @ Test
175175 public void testExpirationDate () throws XmlPullParserException , IOException ,
176176 ParseException , CertificateException {
177- Context context = InstrumentationRegistry .getContext ();
177+ Context context = InstrumentationRegistry .getInstrumentation (). getContext ();
178178 String xml = "" +
179179 "<?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n " +
180180 "<network-security-config>\n " +
@@ -199,7 +199,7 @@ public void testExpirationDate() throws XmlPullParserException, IOException,
199199 @ Test
200200 public void testDisableDefaultReportUri () throws XmlPullParserException , IOException ,
201201 ParseException , CertificateException {
202- Context context = InstrumentationRegistry .getContext ();
202+ Context context = InstrumentationRegistry .getInstrumentation (). getContext ();
203203 String xml = "" +
204204 "<?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n " +
205205 "<network-security-config>\n " +
@@ -225,7 +225,7 @@ public void testDisableDefaultReportUri() throws XmlPullParserException, IOExcep
225225 @ Test
226226 public void testDebugOverrides () throws XmlPullParserException , IOException ,
227227 ParseException , CertificateException {
228- Context context = InstrumentationRegistry .getContext ();
228+ Context context = InstrumentationRegistry .getInstrumentation (). getContext ();
229229 String xml = "" +
230230 "<?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n " +
231231 "<network-security-config>\n " +
@@ -272,7 +272,7 @@ public void testDebugOverrides() throws XmlPullParserException, IOException,
272272 @ Test
273273 public void testNestedDomainConfig () throws XmlPullParserException , IOException ,
274274 ParseException , CertificateException {
275- Context context = InstrumentationRegistry .getContext ();
275+ Context context = InstrumentationRegistry .getInstrumentation (). getContext ();
276276 String xml = "" +
277277 "<?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n " +
278278 "<network-security-config>\n " +
@@ -354,7 +354,7 @@ public void testNestedDomainConfig() throws XmlPullParserException, IOException,
354354 @ Test
355355 public void testIgnoreDomainWithNoPins (
356356 ) throws XmlPullParserException , IOException , CertificateException {
357- Context context = InstrumentationRegistry .getContext ();
357+ Context context = InstrumentationRegistry .getInstrumentation (). getContext ();
358358 // Given a valid network security config
359359 String xml = "" +
360360 "<?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n " +
@@ -391,7 +391,7 @@ context, parseXmlString(xml)
391391 @ Test
392392 public void testAllowsEmptyPinningConfig (
393393 ) throws XmlPullParserException , IOException , CertificateException {
394- Context context = InstrumentationRegistry .getContext ();
394+ Context context = InstrumentationRegistry .getInstrumentation (). getContext ();
395395 // Given a valid network security config that has no entries related to pinning
396396 String xml = "" +
397397 "<?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n " +
0 commit comments