@Test
public void testChecksum() {

    assertEquals(record.checksum(), record.computeChecksum());
    assertEquals(record.checksum(), Record.computeChecksum(
        this.timestamp,
        this.key == null ? null : this.key.array(),
        this.value == null ? null : this.value.array(),
        this.compression, 0, -1));
    assertTrue(record.isValid());
    for (int i = Record.CRC_OFFSET + Record.CRC_LENGTH; i < record.size(); i++) {
        Record copy = copyOf(record);
        copy.buffer().put(i, (byte) 69);
        assertFalse(copy.isValid());
        try {
            copy.ensureValid();
            fail("Should fail the above test.");
        } catch (InvalidRecordException e) {
            // this is good
        }
    }
}