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)
|
protected void assertEventuallyKeySize(final BaseS3Map<T> map, final int size)
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
assertEventually(new Runnable() {
|
assertEventually(new Runnable() {
|
||||||
|
|
|
@ -299,7 +299,8 @@ public class S3IntegrationTest {
|
||||||
if (keys.size() > 0) {
|
if (keys.size() > 0) {
|
||||||
map.clear();
|
map.clear();
|
||||||
assertEquals(map.size(), 0, String.format(
|
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) {
|
} catch (Exception e) {
|
||||||
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
|
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
|
||||||
|
|
|
@ -79,24 +79,35 @@ public class S3ObjectMapIntegrationTest extends BaseS3MapIntegrationTest<S3Objec
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testRemove() throws IOException, InterruptedException, ExecutionException,
|
public void testRemove() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
TimeoutException {
|
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
try {
|
try {
|
||||||
BaseS3Map<S3Object> map = createMap(context, bucketName);
|
BaseS3Map<S3Object> map = createMap(context, bucketName);
|
||||||
putString(map, "one", "two");
|
putString(map, "one", "two");
|
||||||
S3Object old = map.remove("one");
|
assertEventuallyContentEquals(map, "one", "two");
|
||||||
assertEquals(S3Utils.getContentAsStringAndClose(old), "two");
|
// TODO track how often this occurs and potentially update map implementation
|
||||||
old = map.remove("one");
|
assertEventuallyRemoveEquals(map, "one", S3Object.NOT_FOUND);
|
||||||
assert old == S3Object.NOT_FOUND;
|
assertEventuallyGetEquals(map, "one", S3Object.NOT_FOUND);
|
||||||
old = map.get("one");
|
|
||||||
assert old == S3Object.NOT_FOUND;
|
|
||||||
assertEventuallyKeySize(map, 0);
|
assertEventuallyKeySize(map, 0);
|
||||||
} finally {
|
} finally {
|
||||||
returnBucket(bucketName);
|
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
|
@Override
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testEntrySet() throws IOException, InterruptedException, ExecutionException,
|
public void testEntrySet() throws IOException, InterruptedException, ExecutionException,
|
||||||
|
|
Loading…
Reference in New Issue