mirror of https://github.com/apache/jclouds.git
fixed thread safety in test
This commit is contained in:
parent
d6bf96d898
commit
2bff310db2
|
@ -18,14 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.blobstore;
|
||||
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.easymock.classextension.EasyMock;
|
||||
import org.easymock.EasyMock;
|
||||
import org.jclouds.blobstore.domain.PageSet;
|
||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||
import org.jclouds.blobstore.domain.internal.PageSetImpl;
|
||||
|
@ -38,6 +38,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
@Test(singleThreaded = true, testName = "BlobStoresTest")
|
||||
public class BlobStoresTest {
|
||||
|
||||
private final String containerName = "mycontainer";
|
||||
|
@ -98,13 +99,16 @@ public class BlobStoresTest {
|
|||
}
|
||||
|
||||
ListAllOptions listAllOptions = ListAllOptions.Builder.eager(eager);
|
||||
Iterable<StorageMetadata> iterable = BlobStores.listAll(blobStore, containerName, containerOptions, listAllOptions);
|
||||
Iterable<StorageMetadata> iterable = BlobStores.listAll(blobStore, containerName, containerOptions,
|
||||
listAllOptions);
|
||||
|
||||
for (int i = 0; i < numTimesToIterate; i++) {
|
||||
Iterable<String> iterableNames = Iterables.transform(iterable, new Function<StorageMetadata, String>() {
|
||||
@Override public String apply(StorageMetadata input) {
|
||||
@Override
|
||||
public String apply(StorageMetadata input) {
|
||||
return input.getName();
|
||||
}});
|
||||
}
|
||||
});
|
||||
|
||||
// Note that blob.getMetadata being put does not equal blob metadata being retrieved
|
||||
// because uri is null in one and populated in the other.
|
||||
|
@ -112,7 +116,8 @@ public class BlobStoresTest {
|
|||
assertEquals(ImmutableSet.copyOf(iterableNames), expectedNames);
|
||||
}
|
||||
} finally {
|
||||
if (blobStore != null) blobStore.deleteContainer(containerName);
|
||||
if (blobStore != null)
|
||||
blobStore.deleteContainer(containerName);
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +129,8 @@ public class BlobStoresTest {
|
|||
StorageMetadata v1 = createMock(StorageMetadata.class);
|
||||
PageSet<StorageMetadata> pageSet = new PageSetImpl<StorageMetadata>(Collections.singletonList(v1), null);
|
||||
|
||||
EasyMock.<PageSet<? extends StorageMetadata>>expect(blobStore.list(containerName, options)).andReturn(pageSet).once();
|
||||
EasyMock.<PageSet<? extends StorageMetadata>> expect(blobStore.list(containerName, options)).andReturn(pageSet)
|
||||
.once();
|
||||
EasyMock.replay(blobStore);
|
||||
|
||||
Iterable<StorageMetadata> iterable = BlobStores.listAll(blobStore, containerName, options);
|
||||
|
@ -141,8 +147,10 @@ public class BlobStoresTest {
|
|||
PageSet<StorageMetadata> pageSet = new PageSetImpl<StorageMetadata>(Collections.singletonList(v1), "marker1");
|
||||
PageSet<StorageMetadata> pageSet2 = new PageSetImpl<StorageMetadata>(Collections.singletonList(v2), null);
|
||||
|
||||
EasyMock.<PageSet<? extends StorageMetadata>>expect(blobStore.list(containerName, options)).andReturn(pageSet).once();
|
||||
EasyMock.<PageSet<? extends StorageMetadata>>expect(blobStore.list(containerName, options2)).andReturn(pageSet2).once();
|
||||
EasyMock.<PageSet<? extends StorageMetadata>> expect(blobStore.list(containerName, options)).andReturn(pageSet)
|
||||
.once();
|
||||
EasyMock.<PageSet<? extends StorageMetadata>> expect(blobStore.list(containerName, options2)).andReturn(pageSet2)
|
||||
.once();
|
||||
EasyMock.replay(blobStore);
|
||||
|
||||
Iterable<StorageMetadata> iterable = BlobStores.listAll(blobStore, containerName, options);
|
||||
|
|
Loading…
Reference in New Issue