@Test
public void testTxnLogElapsedSyncTime() throws IOException {

    File tmpDir = ClientBase.createTmpDir();
    FileTxnSnapLog fileTxnSnapLog = new FileTxnSnapLog(new File(tmpDir, "data"),
            new File(tmpDir, "data_txnlog"));
    ZooKeeperServer zks = new ZooKeeperServer();
    zks.setTxnLogFactory(fileTxnSnapLog);
    ZooKeeperServerBean serverBean = new ZooKeeperServerBean(zks);
    long elapsedTime = serverBean.getTxnLogElapsedSyncTime();
    assertEquals(-1, elapsedTime);
    TxnHeader hdr = new TxnHeader(1, 1, 1, 1, ZooDefs.OpCode.setData);
    Record txn = new SetDataTxn("/foo", new byte[0], 1);
    Request req = new Request(0, 0, 0, hdr, txn, 0);
    try {
        zks.getTxnLogFactory().append(req);
        zks.getTxnLogFactory().commit();
        elapsedTime = serverBean.getTxnLogElapsedSyncTime();
        assertNotEquals(-1, elapsedTime);
        assertEquals(elapsedTime, serverBean.getTxnLogElapsedSyncTime());
    } finally {
        fileTxnSnapLog.close();
    }
}