11
11
import com .parse .http .ParseHttpRequest ;
12
12
import com .parse .http .ParseHttpResponse ;
13
13
import com .parse .http .ParseNetworkInterceptor ;
14
- import com . squareup . okhttp .MediaType ;
15
- import com . squareup . okhttp .Protocol ;
16
- import com . squareup . okhttp .Request ;
17
- import com . squareup . okhttp .RequestBody ;
18
- import com . squareup . okhttp .Response ;
19
- import com . squareup . okhttp .ResponseBody ;
20
- import com . squareup . okhttp .mockwebserver .MockResponse ;
21
- import com . squareup . okhttp .mockwebserver .MockWebServer ;
22
- import com . squareup . okhttp .mockwebserver .RecordedRequest ;
14
+ import okhttp3 .MediaType ;
15
+ import okhttp3 .Protocol ;
16
+ import okhttp3 .Request ;
17
+ import okhttp3 .RequestBody ;
18
+ import okhttp3 .Response ;
19
+ import okhttp3 .ResponseBody ;
20
+ import okhttp3 .mockwebserver .MockResponse ;
21
+ import okhttp3 .mockwebserver .MockWebServer ;
22
+ import okhttp3 .mockwebserver .RecordedRequest ;
23
23
24
24
import org .json .JSONException ;
25
25
import org .json .JSONObject ;
@@ -116,7 +116,7 @@ public void testGetOkHttpRequest() throws IOException {
116
116
// Verify method
117
117
assertEquals (ParseHttpRequest .Method .POST .toString (), okHttpRequest .method ());
118
118
// Verify URL
119
- assertEquals (url , okHttpRequest .urlString ());
119
+ assertEquals (url , okHttpRequest .url (). toString ());
120
120
// Verify Headers
121
121
assertEquals (1 , okHttpRequest .headers (headerName ).size ());
122
122
assertEquals (headerValue , okHttpRequest .headers (headerName ).get (0 ));
@@ -173,12 +173,12 @@ public MediaType contentType() {
173
173
}
174
174
175
175
@ Override
176
- public long contentLength () throws IOException {
176
+ public long contentLength () {
177
177
return contentLength ;
178
178
}
179
179
180
180
@ Override
181
- public BufferedSource source () throws IOException {
181
+ public BufferedSource source () {
182
182
Buffer buffer = new Buffer ();
183
183
buffer .write (content .getBytes ());
184
184
return buffer ;
@@ -252,7 +252,7 @@ public ParseHttpResponse intercept(Chain chain) throws IOException {
252
252
});
253
253
254
254
// We do not need to add Accept-Encoding header manually, httpClient library should do that.
255
- String requestUrl = server .getUrl ("/" ).toString ();
255
+ String requestUrl = server .url ("/" ).toString ();
256
256
ParseHttpRequest parseRequest = new ParseHttpRequest .Builder ()
257
257
.setUrl (requestUrl )
258
258
.setMethod (ParseHttpRequest .Method .GET )
@@ -359,7 +359,7 @@ private ParseHttpRequest generateClientRequest() throws Exception {
359
359
JSONObject json = new JSONObject ();
360
360
json .put ("key" , "value" );
361
361
ParseHttpRequest parseRequest = new ParseHttpRequest .Builder ()
362
- .setUrl (server .getUrl ("/" ).toString ())
362
+ .setUrl (server .url ("/" ).toString ())
363
363
.setMethod (ParseHttpRequest .Method .POST )
364
364
.setBody (new ParseByteArrayHttpBody (json .toString ().getBytes (), "application/json" ))
365
365
.setHeaders (headers )
@@ -370,7 +370,7 @@ private ParseHttpRequest generateClientRequest() throws Exception {
370
370
// Verify the request from client, if you change the data in generateClientRequest, make
371
371
// sure you also change the condition in this method otherwise tests will fail
372
372
private void verifyClientRequest (ParseHttpRequest parseRequest ) throws IOException {
373
- assertEquals (server .getUrl ("/" ).toString (), parseRequest .getUrl ());
373
+ assertEquals (server .url ("/" ).toString (), parseRequest .getUrl ());
374
374
assertEquals (ParseHttpRequest .Method .POST , parseRequest .getMethod ());
375
375
assertEquals ("requestValue" , parseRequest .getHeader ("requestKey" ));
376
376
assertEquals ("application/json" , parseRequest .getBody ().getContentType ());
@@ -390,7 +390,7 @@ private ParseHttpRequest generateInterceptorRequest() {
390
390
ParseHttpRequest requestAgain =
391
391
new ParseHttpRequest .Builder ()
392
392
.addHeader ("requestKeyAgain" , "requestValueAgain" )
393
- .setUrl (server .getUrl ("/test" ).toString ())
393
+ .setUrl (server .url ("/test" ).toString ())
394
394
.setMethod (ParseHttpRequest .Method .GET )
395
395
.build ();
396
396
return requestAgain ;
0 commit comments