diff --git a/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java b/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java index 49cfe20a74..85b19eba22 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java @@ -380,9 +380,6 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr public void execute(final String containerName, ListContainerOptions listOptions) { - if (listOptions.getDelimiter() != null || listOptions.getPrefix() != null) { - throw new IllegalArgumentException("Prefix and delimiter support has not yet been added"); - } final AtomicBoolean deleteFailure = new AtomicBoolean(); int retries = maxErrors; diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java index 7aae5a4314..009e8fc861 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java @@ -80,6 +80,14 @@ public class BaseBlobStoreIntegrationTest extends BaseViewLiveTest FILE_NESTED_STRINGS = ImmutableMap.of( + "path/1/a", String.format(XML_STRING_FORMAT, "apple"), + "path/1/2/b", String.format(XML_STRING_FORMAT, "bear"), + "path/1/2/3/c", String.format(XML_STRING_FORMAT, "candy"), + "path/1/2/3/4/d", String.format(XML_STRING_FORMAT, "dog"), + "path/1/2/3/5/e", String.format(XML_STRING_FORMAT, "echo") + ); + public static long INCONSISTENCY_WINDOW = 10000; protected static final AtomicInteger containerIndex = new AtomicInteger(0); @@ -282,6 +290,14 @@ public class BaseBlobStoreIntegrationTest extends BaseViewLiveTest entry : FILE_NESTED_STRINGS.entrySet()) { + Blob sourceObject = view.getBlobStore().blobBuilder(entry.getKey()).payload(entry.getValue()) + .contentType("text/xml").build(); + addBlobToContainer(sourceContainer, sourceObject); + } + } + protected String addBlobToContainer(String sourceContainer, Blob object) { return view.getBlobStore().putBlob(sourceContainer, object); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java index abbaba715d..6364c984c8 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java @@ -176,6 +176,63 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { } } + @Test(groups = { "integration", "live" }) + public void testClearWithOptions() throws InterruptedException { + String containerName = getContainerName(); + try { + ListContainerOptions options; + + add5NestedBlobsToContainer(containerName); + options = new ListContainerOptions(); + options.prefix("path/1/"); + options.recursive(); + view.getBlobStore().clearContainer(containerName, options); + assertConsistencyAwareContainerSize(containerName, 0); + + view.getBlobStore().clearContainer(containerName); + add5NestedBlobsToContainer(containerName); + options = new ListContainerOptions(); + options.prefix("path/1/2/3"); + options.recursive(); + view.getBlobStore().clearContainer(containerName, options); + assertConsistencyAwareContainerSize(containerName, 2); + + view.getBlobStore().clearContainer(containerName); + add5NestedBlobsToContainer(containerName); + options = new ListContainerOptions(); + options.prefix("path/1/2/3/4/"); + options.recursive(); + view.getBlobStore().clearContainer(containerName, options); + assertConsistencyAwareContainerSize(containerName, 4); + + // non-recursive, should not clear anything, as prefix does not match + view.getBlobStore().clearContainer(containerName); + add5NestedBlobsToContainer(containerName); + options = new ListContainerOptions(); + options.prefix("path/1/2/3"); + view.getBlobStore().clearContainer(containerName, options); + assertConsistencyAwareContainerSize(containerName, 5); + + // non-recursive, should only clear path/1/2/3/c + view.getBlobStore().clearContainer(containerName); + add5NestedBlobsToContainer(containerName); + options = new ListContainerOptions(); + options.prefix("path/1/2/3/"); + view.getBlobStore().clearContainer(containerName, options); + assertConsistencyAwareContainerSize(containerName, 4); + + // non-recursive, should only clear path/1/2/3/c + view.getBlobStore().clearContainer(containerName); + add5NestedBlobsToContainer(containerName); + options = new ListContainerOptions(); + options.prefix("path/1/2/3/c"); + view.getBlobStore().clearContainer(containerName, options); + assertConsistencyAwareContainerSize(containerName, 4); + } finally { + returnContainer(containerName); + } + } + @Test(groups = { "integration", "live" }) public void testListContainerMarker() throws InterruptedException { String containerName = getContainerName();