1515import com .google .firebase .FirebaseException ;
1616import com .google .firebase .FirebaseOptions ;
1717import com .google .firebase .IncomingHttpResponse ;
18- import com .google .firebase .TestOnlyImplFirebaseTrampolines ;
1918import com .google .firebase .auth .MockGoogleCredentials ;
2019
2120import java .io .IOException ;
2524import org .junit .Test ;
2625
2726public class ApacheHttp2TransportIT {
27+ private static FirebaseApp app ;
2828 private static final GoogleCredentials MOCK_CREDENTIALS = new MockGoogleCredentials ("test_token" );
2929 private static final ImmutableMap <String , Object > payload =
3030 ImmutableMap .<String , Object >of ("foo" , "bar" );
31+
3132 // Sets a 1 second delay before response
3233 private static final String DELAY_URL = "https://nghttp2.org/httpbin/delay/1" ;
3334 private static final String POST_URL = "https://nghttp2.org/httpbin/post" ;
@@ -38,7 +39,7 @@ public static void setUpClass() {
3839
3940 @ After
4041 public void cleanup () {
41- TestOnlyImplFirebaseTrampolines . clearInstancesForTest ();
42+ app . delete ();
4243 }
4344
4445 @ Test
@@ -51,11 +52,11 @@ public void testUnauthorizedPostRequest() throws FirebaseException {
5152
5253 @ Test
5354 public void testConnectTimeoutAuthorizedGet () throws FirebaseException {
54- FirebaseApp timeoutApp = FirebaseApp .initializeApp (FirebaseOptions .builder ()
55+ app = FirebaseApp .initializeApp (FirebaseOptions .builder ()
5556 .setCredentials (MOCK_CREDENTIALS )
5657 .setConnectTimeout (1 )
57- .build ());
58- ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , timeoutApp );
58+ .build (), "test-app" );
59+ ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , app );
5960 HttpRequestInfo request = HttpRequestInfo .buildGetRequest (DELAY_URL );
6061
6162 try {
@@ -70,11 +71,11 @@ public void testConnectTimeoutAuthorizedGet() throws FirebaseException {
7071
7172 @ Test
7273 public void testConnectTimeoutAuthorizedPost () throws FirebaseException {
73- FirebaseApp timeoutApp = FirebaseApp .initializeApp (FirebaseOptions .builder ()
74+ app = FirebaseApp .initializeApp (FirebaseOptions .builder ()
7475 .setCredentials (MOCK_CREDENTIALS )
7576 .setConnectTimeout (1 )
76- .build ());
77- ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , timeoutApp );
77+ .build (), "test-app" );
78+ ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , app );
7879 HttpRequestInfo request = HttpRequestInfo .buildJsonPostRequest (DELAY_URL , payload );
7980
8081 try {
@@ -89,11 +90,11 @@ public void testConnectTimeoutAuthorizedPost() throws FirebaseException {
8990
9091 @ Test
9192 public void testReadTimeoutAuthorizedGet () throws FirebaseException {
92- FirebaseApp timeoutApp = FirebaseApp .initializeApp (FirebaseOptions .builder ()
93+ app = FirebaseApp .initializeApp (FirebaseOptions .builder ()
9394 .setCredentials (MOCK_CREDENTIALS )
9495 .setReadTimeout (1 )
95- .build ());
96- ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , timeoutApp );
96+ .build (), "test-app" );
97+ ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , app );
9798 HttpRequestInfo request = HttpRequestInfo .buildGetRequest (DELAY_URL );
9899
99100 try {
@@ -108,11 +109,11 @@ public void testReadTimeoutAuthorizedGet() throws FirebaseException {
108109
109110 @ Test
110111 public void testReadTimeoutAuthorizedPost () throws FirebaseException {
111- FirebaseApp timeoutApp = FirebaseApp .initializeApp (FirebaseOptions .builder ()
112+ app = FirebaseApp .initializeApp (FirebaseOptions .builder ()
112113 .setCredentials (MOCK_CREDENTIALS )
113114 .setReadTimeout (1 )
114- .build ());
115- ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , timeoutApp );
115+ .build (), "test-app" );
116+ ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , app );
116117 HttpRequestInfo request = HttpRequestInfo .buildJsonPostRequest (DELAY_URL , payload );
117118
118119 try {
@@ -127,11 +128,11 @@ public void testReadTimeoutAuthorizedPost() throws FirebaseException {
127128
128129 @ Test
129130 public void testWriteTimeoutAuthorizedGet () throws FirebaseException {
130- FirebaseApp timeoutApp = FirebaseApp .initializeApp (FirebaseOptions .builder ()
131+ app = FirebaseApp .initializeApp (FirebaseOptions .builder ()
131132 .setCredentials (MOCK_CREDENTIALS )
132133 .setWriteTimeout (1 )
133- .build ());
134- ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , timeoutApp );
134+ .build (), "test-app" );
135+ ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , app );
135136 HttpRequestInfo request = HttpRequestInfo .buildGetRequest (DELAY_URL );
136137
137138 try {
@@ -146,11 +147,11 @@ public void testWriteTimeoutAuthorizedGet() throws FirebaseException {
146147
147148 @ Test
148149 public void testWriteTimeoutAuthorizedPost () throws FirebaseException {
149- FirebaseApp timeoutApp = FirebaseApp .initializeApp (FirebaseOptions .builder ()
150+ app = FirebaseApp .initializeApp (FirebaseOptions .builder ()
150151 .setCredentials (MOCK_CREDENTIALS )
151152 .setWriteTimeout (1 )
152- .build ());
153- ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , timeoutApp );
153+ .build (), "test-app" );
154+ ErrorHandlingHttpClient <FirebaseException > httpClient = getHttpClient (true , app );
154155 HttpRequestInfo request = HttpRequestInfo .buildJsonPostRequest (DELAY_URL , payload );
155156
156157 try {
@@ -177,9 +178,10 @@ private static ErrorHandlingHttpClient<FirebaseException> getHttpClient(boolean
177178 }
178179
179180 private static ErrorHandlingHttpClient <FirebaseException > getHttpClient (boolean authorized ) {
180- return getHttpClient ( authorized , FirebaseApp .initializeApp (FirebaseOptions .builder ()
181+ app = FirebaseApp .initializeApp (FirebaseOptions .builder ()
181182 .setCredentials (MOCK_CREDENTIALS )
182- .build (), "test-app" ));
183+ .build (), "test-app" );
184+ return getHttpClient (authorized , app );
183185 }
184186
185187
0 commit comments