Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Update tests to OkHttp 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
royclarkson committed Jun 24, 2015
1 parent 6371c9c commit 2f21201
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/spring-android-rest-template-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<properties>
<org.apache.httpcomponents-version>4.3.5.1</org.apache.httpcomponents-version>
<com.squareup.okhttp-version>2.1.0</com.squareup.okhttp-version>
<com.squareup.okhttp-version>2.4.0</com.squareup.okhttp-version>
<org.codehaus.jackson-version>1.9.13</org.codehaus.jackson-version>
<com.fasterxml.jackson.core-version>2.5.4</com.fasterxml.jackson.core-version>
<com.google.code.gson-version>2.3.1</com.google.code.gson-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,30 @@ public void testHttpMethods() throws Exception {
assertHttpMethod("delete", HttpMethod.DELETE);
}

protected void assertHttpMethod(String path, HttpMethod method) throws Exception {
ClientHttpResponse response = null;
try {
ClientHttpRequest request = factory.createRequest(new URI(baseUrl + "/methods/" + path), method);
if (method == HttpMethod.POST || method == HttpMethod.PUT || method == HttpMethod.PATCH) {
// requires a body
try {
request.getBody().write(32);
}
catch (UnsupportedOperationException ex) {
// probably a streaming request - let's simply ignore it
}
}
response = request.execute();
assertEquals("Invalid response status", HttpStatus.OK, response.getStatusCode());
assertEquals("Invalid method", path.toUpperCase(Locale.ENGLISH), request.getMethod().name());
}
finally {
if (response != null) {
response.close();
}
}
}

@MediumTest
public void testGetAcceptEncodingGzip() throws Exception {
ClientHttpRequest request = factory.createRequest(new URI(baseUrl + "/gzip"), HttpMethod.GET);
Expand Down Expand Up @@ -448,21 +472,6 @@ public void writeTo(OutputStream outputStream) throws IOException {
}
}

protected void assertHttpMethod(String path, HttpMethod method) throws Exception {
ClientHttpResponse response = null;
try {
ClientHttpRequest request = factory.createRequest(new URI(baseUrl + "/methods/" + path), method);
response = request.execute();
assertEquals("Invalid response status", HttpStatus.OK, response.getStatusCode());
assertEquals("Invalid method", path.toUpperCase(Locale.ENGLISH), request.getMethod().name());
}
finally {
if (response != null) {
response.close();
}
}
}

/**
* Servlet that sets a given status code.
*/
Expand Down

0 comments on commit 2f21201

Please sign in to comment.