diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java index 4db5244958..8561ecdf06 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java @@ -46,6 +46,11 @@ public class AtmosContainerIntegrationLiveTest extends BaseContainerIntegrationT throw new SkipException("cannot specify arbitrary markers"); } + @Override + public void testListMarkerPrefix() throws Exception { + throw new SkipException("cannot specify arbitrary markers"); + } + @Override public void testListContainerWithZeroMaxResults() throws Exception { throw new SkipException("Atmos requires a positive integer for max results"); diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java index 56b91ffacc..63f2e3eef2 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java @@ -276,21 +276,11 @@ public final class LocalBlobStore implements BlobStore { if (options.getMarker() != null) { final String finalMarker = options.getMarker(); String delimiter = storageStrategy.getSeparator(); - Optional lastMarkerMetadata; - if (finalMarker.endsWith(delimiter)) { - lastMarkerMetadata = tryFind(contents, new Predicate() { - public boolean apply(StorageMetadata metadata) { - int length = finalMarker.length() - 1; - return metadata.getName().substring(0, length).compareTo(finalMarker.substring(0, length)) > 0; - } - }); - } else { - lastMarkerMetadata = tryFind(contents, new Predicate() { - public boolean apply(StorageMetadata metadata) { - return metadata.getName().compareTo(finalMarker) > 0; - } - }); - } + Optional lastMarkerMetadata = tryFind(contents, new Predicate() { + public boolean apply(StorageMetadata metadata) { + return metadata.getName().compareTo(finalMarker) > 0; + } + }); if (lastMarkerMetadata.isPresent()) { contents = contents.tailSet(lastMarkerMetadata.get()); } else { 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 6ed679ba8e..735784aaa3 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 @@ -577,6 +577,24 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { } } + /** Test that listing with a marker prefix matches the first key with that prefix. */ + @Test + public void testListMarkerPrefix() throws Exception { + BlobStore blobStore = view.getBlobStore(); + final String container = getContainerName(); + try { + blobStore.createContainerInLocation(null, container); + blobStore.putBlob(container, blobStore.blobBuilder("a/a").payload("").build()); + blobStore.putBlob(container, blobStore.blobBuilder("b/b").payload("").build()); + ListContainerOptions options = new ListContainerOptions().afterMarker("b/").recursive(); + PageSet res = blobStore.list(container, options); + assertThat(res).hasSize(1); + assertThat(res.iterator().next().getName()).isEqualTo("b/b"); + } finally { + returnContainer(container); + } + } + @DataProvider public Object[][] getBlobsToEscape() { ImmutableSet testNames = ImmutableSet.of("%20", "%20 ", " %20", " "); diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerIntegrationLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerIntegrationLiveTest.java index 925e40b552..2c23ab9078 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerIntegrationLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerIntegrationLiveTest.java @@ -35,4 +35,9 @@ public class AzureBlobContainerIntegrationLiveTest extends BaseContainerIntegrat public void testListContainerWithZeroMaxResults() throws Exception { throw new SkipException("Azure requires a positive integer for max results"); } + + @Override + public void testListMarkerPrefix() throws Exception { + throw new SkipException("cannot specify arbitrary markers"); + } }