@Test
public void testDeleteExpiredFileByOffset() {

    MappedFileQueue mappedFileQueue =
        new MappedFileQueue("target/unit_test_store/e", 5120, null);
    for (int i = 0; i < 2048; i++) {
        MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0);
        assertThat(mappedFile).isNotNull();
        ByteBuffer byteBuffer = ByteBuffer.allocate(ConsumeQueue.CQ_STORE_UNIT_SIZE);
        byteBuffer.putLong(i);
        byte[] padding = new byte[12];
        Arrays.fill(padding, (byte) '0');
        byteBuffer.put(padding);
        byteBuffer.flip();
        assertThat(mappedFile.appendMessage(byteBuffer.array())).isTrue();
    }
    MappedFile first = mappedFileQueue.getFirstMappedFile();
    first.hold();
    assertThat(mappedFileQueue.deleteExpiredFileByOffset(20480, ConsumeQueue.CQ_STORE_UNIT_SIZE)).isEqualTo(0);
    first.release();
    assertThat(mappedFileQueue.deleteExpiredFileByOffset(20480, ConsumeQueue.CQ_STORE_UNIT_SIZE)).isGreaterThan(0);
    first = mappedFileQueue.getFirstMappedFile();
    assertThat(first.getFileFromOffset()).isGreaterThan(0);
    mappedFileQueue.shutdown(1000);
    mappedFileQueue.destroy();
}