[TEST] add a dedicated test for empty files

This commit is contained in:
Simon Willnauer 2016-06-08 15:38:11 +02:00
parent a2372778dd
commit bec26015b2
1 changed files with 13 additions and 0 deletions

View File

@ -199,6 +199,19 @@ public class StoreTests extends ESTestCase {
IOUtils.close(indexInput, verifyingOutput, dir);
}
public void testVerifyingIndexOutputOnEmptyFile() throws IOException {
Directory dir = newDirectory();
IndexOutput verifyingOutput = new Store.LuceneVerifyingIndexOutput(new StoreFileMetaData("foo.bar", 0, Store.digestToString(0)),
dir.createOutput("foo1.bar", IOContext.DEFAULT));
try {
Store.verify(verifyingOutput);
fail("should be a corrupted index");
} catch (CorruptIndexException | IndexFormatTooOldException | IndexFormatTooNewException ex) {
// ok
}
IOUtils.close(verifyingOutput, dir);
}
public void testChecksumCorrupted() throws IOException {
Directory dir = newDirectory();
IndexOutput output = dir.createOutput("foo.bar", IOContext.DEFAULT);