Skip to content

Commit

Permalink
Merge pull request #2 from jcookems/listBlobBlockTest
Browse files Browse the repository at this point in the history
Cleanup of the listBlockBlobWithNoCommittedBlocksWorks test.
  • Loading branch information
jcookems committed Oct 10, 2012
2 parents 110adf1 + be88add commit 8312403
Showing 1 changed file with 13 additions and 20 deletions.
Expand Up @@ -650,35 +650,28 @@ public void listBlobsWithDelimiterWorks() throws Exception {
assertEquals(0, results6.getBlobPrefixes().size());
}

// Repro case for https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/295
@Test
public void listBlockBlobWithNoCommittedBlocksWorks() throws Exception {
Configuration config = createConfiguration();
BlobContract service = BlobService.create(config);

String container = "mysample2";
String blob = "test14";
String container = TEST_CONTAINER_FOR_BLOBS;
String blob = "listBlockBlobWithNoCommittedBlocksWorks";

service.createBlockBlob(container, blob, null);
service.createBlobBlock(container, blob, "01", new ByteArrayInputStream(new byte[] { 0x00 }));
service.deleteBlob(container, blob);

try {
service.createContainer(container);
service.listBlobs(container);
service.createBlockBlob(container, blob, null);
service.createBlobBlock(container, blob, "01", new ByteArrayInputStream(new byte[] { 0x00 }));
service.listBlobBlocks(container, blob, new ListBlobBlocksOptions().setCommittedList(true)
.setUncommittedList(true));
service.listBlobs(container);
service.deleteContainer(container);
Thread.sleep(40000);
service.createContainer(container);
service.listBlobs(container);
// Note: This next two lines should give a 404, because the blob no longer
// exists. However, the service sometimes allow this improper access, so
// the SDK has to handle the situation gracefully.
service.createBlobBlock(container, blob, "01", new ByteArrayInputStream(new byte[] { 0x00 }));
// The next line throws
service.listBlobBlocks(container, blob, new ListBlobBlocksOptions().setCommittedList(true)
.setUncommittedList(true));
service.listBlobs(container);
ListBlobBlocksResult result = service.listBlobBlocks(container, blob);
assertEquals(0, result.getCommittedBlocks().size());
}
finally {
deleteContainers(service, null, new String[] { container });
catch (ServiceException ex) {
assertEquals(404, ex.getHttpStatusCode());
}
}

Expand Down

0 comments on commit 8312403

Please sign in to comment.