Exemple #1
0
 @AfterMethod
 protected void deleteLog() {
   try {
     if (log.isOpen()) log.close();
   } catch (Exception ignore) {
   } finally {
     assertFalse(log.isOpen());
     assertTrue(log.isClosed());
     log.delete();
   }
 }
Exemple #2
0
 @Test(expected = RuntimeException.class)
 public void testCorruptTxn() throws Exception {
   if (logClass == (Class<?>) SimpleLog.class) {
     Log log = getLog();
     appendTxns(log, new Zxid(0, 0), 1);
     // Corrupts Transaction.
     corruptFile(20);
     // Iterating the log will trigger the checksum error.
     log.getIterator(log.getLatestZxid());
     log.close();
   } else {
     throw new RuntimeException("Simulated exception for RollingLog.");
   }
 }
Exemple #3
0
 @Test
 public void testRecoverFromExistingLog() throws Exception {
   Log log = getLog();
   // Appends  100 transactions.
   appendTxns(log, new Zxid(0, 0), 100);
   log.close();
   // Reopen the log.
   log = getLog();
   List<Zxid> zxids = getZxids(log, Zxid.ZXID_NOT_EXIST);
   // Check all the transactions are still in log.
   Assert.assertEquals(100, zxids.size());
   // Check all the transactions are in correct order.
   for (int i = 0; i < zxids.size(); ++i) {
     Zxid zxid = new Zxid(0, i);
     Assert.assertEquals(zxid, zxids.get(i));
   }
 }
Exemple #4
0
 @Test
 public void testSyncEmptyLog() throws Exception {
   Log log = getLog();
   log.sync();
   log.close();
 }