MockResponse mr = buildBaseResponse(204);
mr.addHeader(GlacierHeaders.TREE_HASH, TREEHASH);
server.enqueue(mr);
long size = 1024;
ContentRange range = ContentRange.fromPartNumber(0, size);
Payload payload = buildPayload(1);
payload.getContentMetadata().setContentLength(size * MiB);
try {
/* The client.uploadPart call should throw an HttpResponseException since the payload is smaller than expected.
* This trick makes the test way faster.
*/
client.uploadPart(VAULT_NAME, MULTIPART_UPLOAD_ID, range, payload);
Assert.fail();
} catch (HttpResponseException e) {
}
RecordedRequest request = server.takeRequest();
assertEquals(request.getRequestLine(), "PUT /-/vaults/" + VAULT_NAME + "/multipart-uploads/" + MULTIPART_UPLOAD_ID + " " + HTTP);
assertEquals(request.getHeader(HttpHeaders.CONTENT_RANGE), range.buildHeader());
assertEquals(request.getHeader(HttpHeaders.CONTENT_LENGTH), payload.getContentMetadata().getContentLength().toString());
}