}
private void _testOverwrite(String name, boolean expSuccess, OverwriteChecker checker)
throws Exception
{
TimeMasterForSimpleTesting timeMaster = new TimeMasterForSimpleTesting(START_TIME_0);
StorableStore store = createStore("bdb-"+name, timeMaster);
final StorableKey KEY1 = storableKey("data/overwrite1");
// big enough not to get inlined
final byte[] DATA_ORIG = biggerCompressibleData(200 * 1000).getBytes("UTF-8");
final byte[] CUSTOM_METADATA_ORIG = new byte[] { 'a', 'b', 'c', 'd' };
final byte[] DATA_REPLACE = biggerCompressibleData(190 * 1000).getBytes("UTF-8");
final byte[] CUSTOM_METADATA_REPLACE = new byte[] { 'd', 'e' };
try {
StorableCreationMetadata metadata = new StorableCreationMetadata(null,
calcChecksum32(DATA_ORIG), HashConstants.NO_CHECKSUM);
metadata.uncompressedSize = -1L;
StorableCreationResult resp = store.insert(StoreOperationSource.REQUEST, null,
KEY1, new ByteArrayInputStream(DATA_ORIG),
metadata, ByteContainer.simple(CUSTOM_METADATA_ORIG));
assertTrue(resp.succeeded());
assertNull(resp.getPreviousEntry());
_verifyCounts(1L, store);
// Then try to overwrite with a newer timestamp
timeMaster.advanceCurrentTimeMillis(1000);
StorableCreationMetadata metadata2 = new StorableCreationMetadata(null,
calcChecksum32(DATA_REPLACE), HashConstants.NO_CHECKSUM);
metadata.uncompressedSize = -1L;
resp = store.upsertConditionally(StoreOperationSource.REQUEST, null,