@Test
public void testSwitchLogFile() throws Exception {

    
    final AtomicInteger count = new AtomicInteger(0);
    
    SyncListener sl = new SyncListener() {
        
        public void synced(LSN lsn) {
            synchronized (count) {
                count.incrementAndGet();
                count.notifyAll();
            }
        }
        
        public void failed(Exception ex) {
            synchronized (count) {
                count.incrementAndGet();
                count.notifyAll();
            }
        }
    };
    
    for (int i = 0; i < 100; i++) {
        String pl = "Entry " + (i + 1);
        ReusableBuffer plb = ReusableBuffer.wrap(pl.getBytes());
        l.append(new LogEntry(plb, sl, LogEntry.PAYLOAD_TYPE_INSERT));
    }
    synchronized (count) {
        if (count.get() < 100)
            count.wait(1000);
    }
    
    try {
        l.lock();
        l.switchLogFile(false);
    } finally {
        l.unlock();
    }
    
    for (int i = 0; i < 100; i++) {
        String pl = "Entry " + (i + 100 + 1);
        ReusableBuffer plb = ReusableBuffer.wrap(pl.getBytes());
        l.append(new LogEntry(plb, sl, LogEntry.PAYLOAD_TYPE_INSERT));
    }
    
    synchronized (count) {
        if (count.get() < 200)
            count.wait(1000);
    }
}