Ejemplo n.º 1
0
  @Test
  public void overflow_byte_array() {
    File f = TT.tempDbFile();
    f.delete();
    File f0 = new File(f.getPath() + ".wal.0");
    File f1 = new File(f.getPath() + ".wal.1");
    WriteAheadLog wal = new WriteAheadLog(f.getPath());
    wal.open(WriteAheadLog.NOREPLAY);

    long lastPos = 0;
    while (!f1.exists()) {
      lastPos = wal.fileOffset;
      wal.walPutByteArray(111L, new byte[100], 0, 100);
      assertTrue(f0.exists());
    }
    assertTrue(WriteAheadLog.MAX_FILE_SIZE - 1000 < lastPos);
    assertTrue(WriteAheadLog.MAX_FILE_SIZE + 120 > lastPos);
    wal.destroyWalFiles();
  }