CacheOperationsIT: Assert that all REST calls were successful
Otherwise the error message is misleading if a REST call fails and we try to parse a JSON object from the response. Change-Id: I4d48849feba8cd0cd98ad47f9cb798901c3d5871 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import com.google.gerrit.extensions.restapi.RawInput;
|
||||
import com.google.gerrit.server.OutputFormat;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.fluent.Request;
|
||||
import org.apache.http.entity.BufferedHttpEntity;
|
||||
import org.apache.http.entity.InputStreamEntity;
|
||||
@@ -37,6 +38,18 @@ public class RestSession extends HttpSession {
|
||||
super(server, account);
|
||||
}
|
||||
|
||||
public RestResponse getOK(String endPoint)
|
||||
throws Exception {
|
||||
return get(endPoint, HttpStatus.SC_OK);
|
||||
}
|
||||
|
||||
public RestResponse get(String endPoint, int expectedStatus)
|
||||
throws Exception {
|
||||
RestResponse r = get(endPoint);
|
||||
r.assertStatus(expectedStatus);
|
||||
return r;
|
||||
}
|
||||
|
||||
public RestResponse get(String endPoint) throws IOException {
|
||||
return getWithHeader(endPoint, null);
|
||||
}
|
||||
@@ -102,6 +115,18 @@ public class RestSession extends HttpSession {
|
||||
return post(endPoint, null);
|
||||
}
|
||||
|
||||
public RestResponse postOK(String endPoint, Object content)
|
||||
throws Exception {
|
||||
return post(endPoint, content, HttpStatus.SC_OK);
|
||||
}
|
||||
|
||||
public RestResponse post(String endPoint, Object content, int expectedStatus)
|
||||
throws Exception {
|
||||
RestResponse r = post(endPoint, content);
|
||||
r.assertStatus(expectedStatus);
|
||||
return r;
|
||||
}
|
||||
|
||||
public RestResponse post(String endPoint, Object content) throws IOException {
|
||||
return postWithHeader(endPoint, content, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user