public void testObjectListing() {
String containerName = createTempContainerName("object-listing-marker");
try {
byte randomData[] = makeRandomBytes();
FilesClient client = new FilesClient();
// client.setUseETag(false);
client.useSnet();
assertTrue(client.usingSnet());
assertTrue(client.login());
// Set up
client.createContainer(containerName);
// Store it
for (int i=0; i < 10; i++) {
assertTrue(client.storeObject(containerName, randomData, "application/octet-stream", "testfile" + i + ".bogus", new HashMap<String,String>()));
}
// Make sure it's there
List<FilesObject> objects = client.listObjects(containerName);
assertEquals(10, objects.size());
for (int i=0; i < 10; i++) {
FilesObject obj = objects.get(i);
assertEquals("testfile" + i + ".bogus", obj.getName());
assertEquals("application/octet-stream", obj.getMimeType());
}
// Now do a limit
objects = client.listObjects(containerName, 3);
assertEquals(3, objects.size());
for (int i=0; i < 3; i++) {
FilesObject obj = objects.get(i);
assertEquals("testfile" + i + ".bogus", obj.getName());
assertEquals("application/octet-stream", obj.getMimeType());
}
// Now check out a marker
objects = client.listObjects(containerName, 4, "testfile3.bogus");
assertEquals(4, objects.size());
for (int i=0; i < 4; i++) {
FilesObject obj = objects.get(i);
assertEquals("testfile" + (i + 4) + ".bogus", obj.getName());
assertEquals("application/octet-stream", obj.getMimeType());
}
// Clean up
for (int i=0; i < 10; i++) {
client.deleteObject(containerName, "testfile" + i + ".bogus");
}
assertTrue(client.deleteContainer(containerName));
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());