Issue 64: map.containsValue() is subject to eventual consistency delays as it compares state against the md5 sums in the bucket listing

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1442 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-06-18 00:17:55 +00:00
parent fb67368738
commit 4ec1b14408
3 changed files with 22 additions and 10 deletions

View File

@ -137,6 +137,18 @@ public abstract class BaseS3MapIntegrationTest<T> extends S3IntegrationTest {
assertEventuallyContainsKey();
}
/**
* containsValue() uses md5 comparison to bucket contents, so this can be subject to eventual
* consistency problems.
*/
protected void assertEventuallyContainsValue(final Object value) throws InterruptedException {
assertEventually(new Runnable() {
public void run() {
assert map.containsValue(value);
}
});
}
protected void assertEventuallyContainsKey() throws InterruptedException {
assertEventually(new Runnable() {
public void run() {

View File

@ -96,27 +96,27 @@ public class S3InputStreamMapIntegrationTest extends BaseS3MapIntegrationTest<In
}
@Test(groups = { "integration", "live" })
public void testContainsStringValue() {
public void testContainsStringValue() throws InterruptedException {
map.putString("one", "apple");
assert map.containsValue(fiveStrings.get("one"));
assertEventuallyContainsValue(fiveStrings.get("one"));
}
@Test(groups = { "integration", "live" })
public void testContainsFileValue() {
public void testContainsFileValue() throws InterruptedException {
map.putString("one", "apple");
assert map.containsValue(fiveFiles.get("one"));
assertEventuallyContainsValue(fiveFiles.get("one"));
}
@Test(groups = { "integration", "live" })
public void testContainsInputStreamValue() {
public void testContainsInputStreamValue() throws InterruptedException {
map.putString("one", "apple");
assert map.containsValue(this.fiveInputs.get("one"));
assertEventuallyContainsValue(this.fiveInputs.get("one"));
}
@Test(groups = { "integration", "live" })
public void testContainsBytesValue() {
public void testContainsBytesValue() throws InterruptedException {
map.putString("one", "apple");
assert map.containsValue(this.fiveBytes.get("one"));
assertEventuallyContainsValue(this.fiveBytes.get("one"));
}
@Override

View File

@ -102,11 +102,11 @@ public class S3ObjectMapIntegrationTest extends BaseS3MapIntegrationTest<S3Objec
}
@Test(groups = { "integration", "live" })
public void testContains() {
public void testContains() throws InterruptedException {
putString("one", "apple");
S3Object object = new S3Object("one");
object.setData("apple");
assert map.containsValue(object);
assertEventuallyContainsValue(object);
}
void getOneReturnsAppleAndOldValueIsNull(S3Object old) throws IOException, InterruptedException {