Search in sources :

Example 1 with ListNextBatchOfObjectsRequest

use of com.qcloud.cos.model.ListNextBatchOfObjectsRequest in project cos-java-sdk-v5 by tencentyun.

the class ListObjectTest method ListNextBatchObjectWithTrunCated.

@Test
public void ListNextBatchObjectWithTrunCated() {
    if (!judgeUserInfoValid()) {
        return;
    }
    ObjectListing objectListingPrev = new ObjectListing();
    objectListingPrev.setBucketName(bucket);
    objectListingPrev.setPrefix(keyPrefix);
    objectListingPrev.setNextMarker("");
    objectListingPrev.setMaxKeys(100);
    objectListingPrev.setDelimiter("");
    objectListingPrev.setTruncated(false);
    ListNextBatchOfObjectsRequest listNextBatchOfObjectsRequest = new ListNextBatchOfObjectsRequest(objectListingPrev);
    ObjectListing objectListingNext = cosclient.listNextBatchOfObjects(listNextBatchOfObjectsRequest);
    assertEquals(bucket, objectListingNext.getBucketName());
    assertEquals(objectListingPrev.isTruncated(), objectListingNext.isTruncated());
    assertEquals(objectListingPrev.getMaxKeys(), objectListingNext.getMaxKeys());
    assertEquals(objectListingPrev.getNextMarker(), objectListingNext.getMarker());
    assertEquals(0L, objectListingNext.getCommonPrefixes().size());
    assertEquals(0L, objectListingNext.getObjectSummaries().size());
}
Also used : ObjectListing(com.qcloud.cos.model.ObjectListing) ListNextBatchOfObjectsRequest(com.qcloud.cos.model.ListNextBatchOfObjectsRequest) Test(org.junit.Test)

Example 2 with ListNextBatchOfObjectsRequest

use of com.qcloud.cos.model.ListNextBatchOfObjectsRequest in project cos-java-sdk-v5 by tencentyun.

the class ListObjectTest method ListNextBatchObjectWithNoTrunCated.

@Test
public void ListNextBatchObjectWithNoTrunCated() {
    if (!judgeUserInfoValid()) {
        return;
    }
    ObjectListing objectListingPrev = new ObjectListing();
    objectListingPrev.setBucketName(bucket);
    objectListingPrev.setPrefix(keyPrefix);
    objectListingPrev.setNextMarker("");
    objectListingPrev.setMaxKeys(100);
    objectListingPrev.setDelimiter("");
    objectListingPrev.setTruncated(true);
    ListNextBatchOfObjectsRequest listNextBatchOfObjectsRequest = new ListNextBatchOfObjectsRequest(objectListingPrev);
    ObjectListing objectListingNext = cosclient.listNextBatchOfObjects(listNextBatchOfObjectsRequest);
    assertEquals(0L, objectListingNext.getCommonPrefixes().size());
    assertEquals(arrayNum, objectListingNext.getObjectSummaries().size());
    List<COSObjectSummary> objectSummaries = objectListingNext.getObjectSummaries();
    for (int i = 0; i < arrayNum; ++i) {
        COSObjectSummary cosObjectSummary = objectSummaries.get(i);
        String expectedKey = String.format("%s/%dk.txt", keyPrefix, i);
        assertEquals(expectedKey, cosObjectSummary.getKey());
        assertEquals(i * 1024L, cosObjectSummary.getSize());
    }
}
Also used : COSObjectSummary(com.qcloud.cos.model.COSObjectSummary) ObjectListing(com.qcloud.cos.model.ObjectListing) ListNextBatchOfObjectsRequest(com.qcloud.cos.model.ListNextBatchOfObjectsRequest) Test(org.junit.Test)

Aggregations

ListNextBatchOfObjectsRequest (com.qcloud.cos.model.ListNextBatchOfObjectsRequest)2 ObjectListing (com.qcloud.cos.model.ObjectListing)2 Test (org.junit.Test)2 COSObjectSummary (com.qcloud.cos.model.COSObjectSummary)1