mirror of https://github.com/apache/jclouds.git
Issue 64: more EC in tests
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1484 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
6829c4ace2
commit
bc52a66433
|
@ -135,6 +135,24 @@ public abstract class BaseS3MapIntegrationTest<T> extends S3IntegrationTest {
|
|||
});
|
||||
}
|
||||
|
||||
protected void assertEventuallyRemoveEquals(final BaseS3Map<T> map, final String key,
|
||||
final Object equals) throws InterruptedException {
|
||||
assertEventually(new Runnable() {
|
||||
public void run() {
|
||||
assertEquals(map.remove(key), equals);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void assertEventuallyGetEquals(final BaseS3Map<T> map, final String key,
|
||||
final Object equals) throws InterruptedException {
|
||||
assertEventually(new Runnable() {
|
||||
public void run() {
|
||||
assertEquals(map.get(key), equals);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void assertEventuallyKeySize(final BaseS3Map<T> map, final int size)
|
||||
throws InterruptedException {
|
||||
assertEventually(new Runnable() {
|
||||
|
|
|
@ -299,7 +299,8 @@ public class S3IntegrationTest {
|
|||
if (keys.size() > 0) {
|
||||
map.clear();
|
||||
assertEquals(map.size(), 0, String.format(
|
||||
"deleting %s, we still have %s left", keys, map.keySet()));
|
||||
"deleting %s, we still have %s left in bucket %s", keys,
|
||||
map.keySet(), name));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
|
||||
|
|
|
@ -79,24 +79,35 @@ public class S3ObjectMapIntegrationTest extends BaseS3MapIntegrationTest<S3Objec
|
|||
}
|
||||
|
||||
@Test(groups = { "integration", "live" })
|
||||
public void testRemove() throws IOException, InterruptedException, ExecutionException,
|
||||
TimeoutException {
|
||||
public void testRemove() throws InterruptedException, ExecutionException, TimeoutException {
|
||||
String bucketName = getBucketName();
|
||||
try {
|
||||
BaseS3Map<S3Object> map = createMap(context, bucketName);
|
||||
putString(map, "one", "two");
|
||||
S3Object old = map.remove("one");
|
||||
assertEquals(S3Utils.getContentAsStringAndClose(old), "two");
|
||||
old = map.remove("one");
|
||||
assert old == S3Object.NOT_FOUND;
|
||||
old = map.get("one");
|
||||
assert old == S3Object.NOT_FOUND;
|
||||
assertEventuallyContentEquals(map, "one", "two");
|
||||
// TODO track how often this occurs and potentially update map implementation
|
||||
assertEventuallyRemoveEquals(map, "one", S3Object.NOT_FOUND);
|
||||
assertEventuallyGetEquals(map, "one", S3Object.NOT_FOUND);
|
||||
assertEventuallyKeySize(map, 0);
|
||||
} finally {
|
||||
returnBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertEventuallyContentEquals(final BaseS3Map<S3Object> map, final String key,
|
||||
final String value) throws InterruptedException {
|
||||
assertEventually(new Runnable() {
|
||||
public void run() {
|
||||
S3Object old = map.remove(key);
|
||||
try {
|
||||
assertEquals(S3Utils.getContentAsStringAndClose(old), value);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test(groups = { "integration", "live" })
|
||||
public void testEntrySet() throws IOException, InterruptedException, ExecutionException,
|
||||
|
|
Loading…
Reference in New Issue