/*existing compression*/ null,
calcChecksum32(DATA), HashConstants.NO_CHECKSUM);
// important: throttle input reading, to force chunking (and maybe tease out bugs)
StorableCreationResult resp = store.insert(StoreOperationSource.REQUEST, null,
KEY1, new ThrottlingByteArrayInputStream(DATA, 97),
metadata0.clone(), ByteContainer.simple(CUSTOM_METADATA_IN));
assertTrue(resp.succeeded());
assertNull(resp.getPreviousEntry());
_verifyCounts(1L, store);
// and then verify entry
Storable entry = store.findEntry(StoreOperationSource.REQUEST, null, KEY1);
assertNotNull(entry);
assertEquals(startTime, entry.getLastModified());
// big enough so it can't be inlined:
assertFalse(entry.hasInlineData());
assertTrue(entry.hasExternalData());
// allegedly no compression (to disable any other automatic handling):
assertEquals(Compression.LZF, entry.getCompression());
int expCompressedSize = COMPRESSED_DATA.length;
assertEquals(expCompressedSize, entry.getStorageLength());
assertEquals(DATA.length, entry.getOriginalLength());
_verifyHash(COMPRESSED_DATA, entry.getCompressedHash(), "Compressed LZF data");
// we passed bit of custom metadata, verify:
_verifyMetadata(entry, CUSTOM_METADATA_IN);
// and external path should also work; verify some naming aspects
// (where 'Z' is compression indicator" and 123 sequence number)
File file = entry.getExternalFile(store.getFileManager());
assertNotNull(file);
String path = file.getAbsolutePath();
String filename = path.substring(path.lastIndexOf('/')+1);
String suffix = filename.substring(filename.lastIndexOf('.'));
assertEquals(".L", suffix);
assertEquals("0000:data_1", filename.substring(0, filename.lastIndexOf('.')));
// but as importantly, check that file is there and contains data...
assertTrue(file.exists());
byte[] fileData = readFile(file);
assertArrayEquals(COMPRESSED_DATA, fileData);
/* Let's also verify checksum handling: should have one for compressed
* data at least...
*/
_verifyHash(fileData, entry.getCompressedHash(), "file checksum for large data");
// Actually, let's also verify handling of dups...
StorableCreationResult resp2 = store.insert(StoreOperationSource.REQUEST, null,
KEY1, new ThrottlingByteArrayInputStream(DATA, 77),
metadata0.clone(), ByteContainer.simple(CUSTOM_METADATA_IN));
assertFalse(resp2.succeeded());
assertNotNull(resp2.getPreviousEntry());
_verifyCounts(1L, store);
// should we see if multiple files exist?