// List items in chunks of size 2, ensure we get a total of seven.
int chunkedObjectsCount = 0;
int chunkedIterationsCount = 0;
String priorLastKey = null;
do {
StorageObjectsChunk chunk = service.listObjectsChunked(
bucketName, null, null, 2, priorLastKey);
priorLastKey = chunk.getPriorLastKey();
chunkedObjectsCount += chunk.getObjects().length;
chunkedIterationsCount++;
} while (priorLastKey != null);
assertEquals("Chunked bucket listing retreived incorrect number of objects",
objectsList.size(), chunkedObjectsCount);
assertEquals("Chunked bucket listing ran for an unexpected number of iterations",
(objectsList.size() + 1) / 2, chunkedIterationsCount);
// List objects with a prefix and delimiter to check common prefixes.
StorageObjectsChunk chunk = service.listObjectsChunked(
bucketName, "dir1/", "/", 100, null);
assertEquals("Chunked bucket listing with prefix and delimiter retreived incorrect number of objects",
3, chunk.getObjects().length);
assertEquals("Chunked bucket listing with prefix and delimiter retreived incorrect number of common prefixes",
1, chunk.getCommonPrefixes().length);
// List the same items with a prefix.
objects = service.listObjects(bucketName, "dir1", null);
assertEquals("Incorrect number of objects matching prefix", 7, objects.length);