fixing incorrect merge
This commit is contained in:
parent
7e5bea3330
commit
c1f94aab92
|
@ -27,15 +27,12 @@ public class OkHttpFileUploadingLiveTest {
|
|||
|
||||
@Before
|
||||
public void init() {
|
||||
|
||||
client = new OkHttpClient();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUploadFile_thenCorrect() throws IOException {
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
RequestBody requestBody = new MultipartBody.Builder()
|
||||
.setType(MultipartBody.FORM)
|
||||
.addFormDataPart("file", "file.txt",
|
||||
|
@ -56,8 +53,6 @@ public class OkHttpFileUploadingLiveTest {
|
|||
@Test
|
||||
public void whenGetUploadFileProgress_thenCorrect() throws IOException {
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
RequestBody requestBody = new MultipartBody.Builder()
|
||||
.setType(MultipartBody.FORM)
|
||||
.addFormDataPart("file", "file.txt",
|
||||
|
|
|
@ -13,6 +13,7 @@ import okhttp3.OkHttpClient;
|
|||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
|
||||
public class OkHttpGetLiveTest {
|
||||
|
||||
private static final String BASE_URL = "http://localhost:8080/spring-rest";
|
||||
|
@ -27,9 +28,6 @@ public class OkHttpGetLiveTest {
|
|||
|
||||
@Test
|
||||
public void whenGetRequest_thenCorrect() throws IOException {
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(BASE_URL + "/date")
|
||||
.build();
|
||||
|
@ -42,9 +40,6 @@ public class OkHttpGetLiveTest {
|
|||
|
||||
@Test
|
||||
public void whenGetRequestWithQueryParameter_thenCorrect() throws IOException {
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
HttpUrl.Builder urlBuilder = HttpUrl.parse(BASE_URL + "/ex/bars").newBuilder();
|
||||
urlBuilder.addQueryParameter("id", "1");
|
||||
|
||||
|
@ -62,9 +57,6 @@ public class OkHttpGetLiveTest {
|
|||
|
||||
@Test
|
||||
public void whenAsynchronousGetRequest_thenCorrect() throws InterruptedException {
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(BASE_URL + "/date")
|
||||
.build();
|
||||
|
|
|
@ -24,9 +24,6 @@ public class OkHttpHeaderLiveTest {
|
|||
|
||||
@Test
|
||||
public void whenSetHeader_thenCorrect() throws IOException {
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(SAMPLE_URL)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
|
@ -40,7 +37,7 @@ public class OkHttpHeaderLiveTest {
|
|||
@Test
|
||||
public void whenSetDefaultHeader_thenCorrect() throws IOException {
|
||||
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
OkHttpClient clientWithInterceptor = new OkHttpClient.Builder()
|
||||
.addInterceptor(new DefaultContentTypeInterceptor("application/json"))
|
||||
.build();
|
||||
|
||||
|
@ -48,7 +45,7 @@ public class OkHttpHeaderLiveTest {
|
|||
.url(SAMPLE_URL)
|
||||
.build();
|
||||
|
||||
Call call = client.newCall(request);
|
||||
Call call = clientWithInterceptor.newCall(request);
|
||||
Response response = call.execute();
|
||||
response.close();
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@ public class OkHttpMiscLiveTest {
|
|||
|
||||
@Test
|
||||
public void whenSetRequestTimeout_thenFail() throws IOException {
|
||||
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
OkHttpClient clientWithTimeout = new OkHttpClient.Builder()
|
||||
.readTimeout(1, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
|
@ -43,18 +42,15 @@ public class OkHttpMiscLiveTest {
|
|||
.url(BASE_URL + "/delay/2") // This URL is served with a 2 second delay.
|
||||
.build();
|
||||
|
||||
Call call = client.newCall(request);
|
||||
Call call = clientWithTimeout.newCall(request);
|
||||
Response response = call.execute();
|
||||
response.close();
|
||||
}
|
||||
|
||||
@Test(expected = IOException.class)
|
||||
public void whenCancelRequest_thenCorrect() throws IOException {
|
||||
|
||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(BASE_URL + "/delay/2") // This URL is served with a 2 second delay.
|
||||
.build();
|
||||
|
@ -85,7 +81,7 @@ public class OkHttpMiscLiveTest {
|
|||
File cacheDirectory = new File("src/test/resources/cache");
|
||||
Cache cache = new Cache(cacheDirectory, cacheSize);
|
||||
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
OkHttpClient clientCached = new OkHttpClient.Builder()
|
||||
.cache(cache)
|
||||
.build();
|
||||
|
||||
|
@ -93,10 +89,10 @@ public class OkHttpMiscLiveTest {
|
|||
.url("http://publicobject.com/helloworld.txt")
|
||||
.build();
|
||||
|
||||
Response response1 = client.newCall(request).execute();
|
||||
Response response1 = clientCached.newCall(request).execute();
|
||||
logResponse(response1);
|
||||
|
||||
Response response2 = client.newCall(request).execute();
|
||||
Response response2 = clientCached.newCall(request).execute();
|
||||
logResponse(response2);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,9 +34,6 @@ public class OkHttpPostingLiveTest {
|
|||
|
||||
@Test
|
||||
public void whenSendPostRequest_thenCorrect() throws IOException {
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
RequestBody formBody = new FormBody.Builder()
|
||||
.add("username", "test")
|
||||
.add("password", "test")
|
||||
|
@ -55,11 +52,8 @@ public class OkHttpPostingLiveTest {
|
|||
|
||||
@Test
|
||||
public void whenSendPostRequestWithAuthorization_thenCorrect() throws IOException {
|
||||
|
||||
String postBody = "test post";
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(URL_SECURED_BY_BASIC_AUTHENTICATION)
|
||||
.addHeader("Authorization", Credentials.basic("test", "test"))
|
||||
|
@ -74,9 +68,6 @@ public class OkHttpPostingLiveTest {
|
|||
|
||||
@Test
|
||||
public void whenPostJson_thenCorrect() throws IOException {
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
String json = "{\"id\":1,\"name\":\"John\"}";
|
||||
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json);
|
||||
|
@ -94,9 +85,6 @@ public class OkHttpPostingLiveTest {
|
|||
|
||||
@Test
|
||||
public void whenSendMultipartRequest_thenCorrect() throws IOException {
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
RequestBody requestBody = new MultipartBody.Builder()
|
||||
.setType(MultipartBody.FORM)
|
||||
.addFormDataPart("username", "test")
|
||||
|
|
Loading…
Reference in New Issue