@@ -49,7 +49,13 @@ public void whenSendPostRequest_thenCorrect() throws IOException {
4949 public void whenSendPostRequestWithAuthorization_thenCorrect () throws IOException {
5050 final String postBody = "test post" ;
5151
52- final Request request = new Request .Builder ().url (URL_SECURED_BY_BASIC_AUTHENTICATION ).addHeader ("Authorization" , Credentials .basic ("test" , "test" )).post (RequestBody .create (MediaType .parse ("text/x-markdown; charset=utf-8" ), postBody )).build ();
52+ client = new OkHttpClient ();
53+
54+ final Request request = new Request .Builder ()
55+ .url (URL_SECURED_BY_BASIC_AUTHENTICATION )
56+ .addHeader ("Authorization" , Credentials .basic ("test" , "test" ))
57+ .post (RequestBody .create (MediaType .parse ("text/x-markdown; charset=utf-8" ), "test post" ))
58+ .build ();
5359
5460 final Call call = client .newCall (request );
5561 final Response response = call .execute ();
@@ -61,8 +67,9 @@ public void whenSendPostRequestWithAuthorization_thenCorrect() throws IOExceptio
6167 public void whenPostJson_thenCorrect () throws IOException {
6268 final String json = "{\" id\" :1,\" name\" :\" John\" }" ;
6369
64- final RequestBody body = RequestBody . create ( MediaType . parse ( "application/json; charset=utf-8" ), json );
70+ client = new OkHttpClient ( );
6571
72+ final RequestBody body = RequestBody .create (MediaType .parse ("application/json; charset=utf-8" ), "{\" id\" :1,\" name\" :\" John\" }" );
6673 final Request request = new Request .Builder ().url (BASE_URL + "/users/detail" ).post (body ).build ();
6774
6875 final Call call = client .newCall (request );
0 commit comments