try {
assertTrue("Not registered" + i, nigori.register());
assertTrue("Not a clean store " + i, nigori.getIndices().isEmpty());
for (IndexValue iv : testCases) {// once round for each
final Index index = iv.index;
final Revision revision = iv.revvalue.getRevision();
final byte[] value = iv.revvalue.getValue();
assertTrue("Not put " + i, nigori.put(index, revision, value));
List<RevValue> revs = nigori.get(index);
assertFalse("Revisions must exist" + i, revs.isEmpty());
assertThat(revs, hasItem(iv.revvalue));
assertEquals("Not one revision " + i, 1, revs.size());
assertTrue("Not deleted" + i, nigori.delete(index, NULL_DELETE_TOKEN));
assertNull("Not deleted" + i, nigori.get(index));
assertFalse("Could redelete", nigori.delete(index, NULL_DELETE_TOKEN));
}
// allow them to accumulate
for (IndexValue iv : testCases) {
final Index index = iv.index;
final byte[] value = iv.revvalue.getValue();
final Revision revision = iv.revvalue.getRevision();
assertTrue("Not put" + i, nigori.put(index, revision, value));
}
try {
for (IndexValue iv : testCases) {
final Index index = iv.index;
final byte[] value = iv.revvalue.getValue();
final Revision revision = iv.revvalue.getRevision();
assertArrayEquals("Got different" + i, value, nigori.getRevision(index, revision));
}
} finally {
for (IndexValue iv : testCases) {
final Index index = iv.index;
if (!iv.later) {
assertTrue("Not deleted" + i, nigori.delete(index, NULL_DELETE_TOKEN));
} else {// should have already been deleted
assertFalse("Not deleted" + i, nigori.delete(index, NULL_DELETE_TOKEN));
}
}
}
for (IndexValue iv : testCases) {
final Index index = iv.index;
assertNull("Still there after deletion " + i, nigori.get(index));
}
} finally {
assertTrue("Not unregistered", nigori.unregister());
}