use of com.aliyun.oss.model.ListPartsRequest in project aliyun-oss-java-sdk by aliyun.
the class UploadPartTest method testUnormalListParts.
@Test
public void testUnormalListParts() {
final String key = "unormal-list-parts-object";
// Try to list parts with non-existent part id
final String nonexistentUploadId = "nonexistent-upload-id";
try {
ListPartsRequest listPartsRequest = new ListPartsRequest(bucketName, key, nonexistentUploadId);
ossClient.listParts(listPartsRequest);
Assert.fail("List parts should not be successful");
} catch (OSSException e) {
Assert.assertEquals(OSSErrorCode.NO_SUCH_UPLOAD, e.getErrorCode());
Assert.assertTrue(e.getMessage().startsWith(NO_SUCH_UPLOAD_ERR));
}
// Try to list LIST_PART_MAX_RETURNS + 1 parts each time
String uploadId = null;
try {
uploadId = claimUploadId(ossClient, bucketName, key);
ListPartsRequest listPartsRequest = new ListPartsRequest(bucketName, key, uploadId);
listPartsRequest.setMaxParts(LIST_PART_MAX_RETURNS + 1);
ossClient.listParts(listPartsRequest);
Assert.fail("List parts should not be successful");
} catch (Exception e) {
Assert.assertTrue(e instanceof IllegalArgumentException);
AbortMultipartUploadRequest abortMultipartUploadRequest = new AbortMultipartUploadRequest(bucketName, key, uploadId);
ossClient.abortMultipartUpload(abortMultipartUploadRequest);
}
}
use of com.aliyun.oss.model.ListPartsRequest in project aliyun-oss-java-sdk by aliyun.
the class OSSClientRequestTest method testListPartsRequest.
@Test
public void testListPartsRequest() {
String uploadId = "upload123";
final ListPartsRequest request = new ListPartsRequest(bucketName, objectKey, uploadId);
String expectedUrl = objectKey + "?uploadId=" + uploadId;
TestAction test1 = new TestAction() {
public void run() throws Exception {
multipartOp.listParts(request);
}
};
executeTest(test1, HttpMethod.GET, bucketName + "." + endpoint.getHost(), expectedUrl, null);
request.setMaxParts(100);
request.setPartNumberMarker(50);
expectedUrl += "&max-parts=" + request.getMaxParts().toString() + "&part-number-marker=" + request.getPartNumberMarker().toString();
executeTest(test1, HttpMethod.GET, bucketName + "." + endpoint.getHost(), expectedUrl, null);
}
Aggregations