@Test
public void testDeleteExpiredFileByTime() throws Exception {

    MappedFileQueue mappedFileQueue =
        new MappedFileQueue("target/unit_test_store/f/", 1024, null);
    for (int i = 0; i < 100; i++) {
        MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0);
        assertThat(mappedFile).isNotNull();
        byte[] bytes = new byte[512];
        assertThat(mappedFile.appendMessage(bytes)).isTrue();
    }
    assertThat(mappedFileQueue.getMappedFiles().size()).isEqualTo(50);
    long expiredTime =  100 * 1000;
    for (int i = 0; i < mappedFileQueue.getMappedFiles().size(); i++) {
        MappedFile mappedFile = mappedFileQueue.getMappedFiles().get(i);
       if (i < 5) {
           mappedFile.getFile().setLastModified(System.currentTimeMillis() - expiredTime * 2);
       }
       if (i > 20) {
           mappedFile.getFile().setLastModified(System.currentTimeMillis() - expiredTime * 2);
       }
    }
    mappedFileQueue.deleteExpiredFileByTime(expiredTime, 0, 0, false);
    assertThat(mappedFileQueue.getMappedFiles().size()).isEqualTo(45);
}