TruncateTest.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:fuck_zookeeper 作者:
@Test
public void testTruncationNullLog() throws Exception {
    File tmpdir = ClientBase.createTmpDir();
    FileTxnSnapLog snaplog = new FileTxnSnapLog(tmpdir, tmpdir);
    ZKDatabase zkdb = new ZKDatabase(snaplog);

    for (int i = 1; i <= 100; i++) {
        append(zkdb, i);
    }
    zkdb.close();
    File[] logs = snaplog.getDataDir().listFiles();
    for(int i = 0; i < logs.length; i++) {
        LOG.debug("Deleting: {}", logs[i].getName());
        Assert.assertTrue("Failed to delete log file: " + logs[i].getName(), logs[i].delete());
    }
    try {
        zkdb.truncateLog(1);
        Assert.assertTrue("Should not get here", false);
    }
    catch(IOException e) {
        Assert.assertTrue("Should have received an IOException", true);
    }
    catch(NullPointerException npe) {
        Assert.fail("This should not throw NPE!");
    }

    ClientBase.recursiveDelete(tmpdir);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号