Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  test_persist_journal.js   Sprache: JAVA

 
/* Any copyright is dedicated to the Public Domain.
 * https://creativecommons.org/publicdomain/zero/1.0/ */


// Tests the journal persists on close.

async function check_journal_persists(db, journal) {
  let path = db.databaseFile.path;
  info(`testing ${path}`);
  await new Promise(resolve => {
    db.executeSimpleSQLAsync(`PRAGMA journal_mode = ${journal}`, {
      handleCompletion: resolve,
    });
  });

  await new Promise(resolve => {
    db.executeSimpleSQLAsync("CREATE TABLE test (id INTEGER PRIMARY KEY)", {
      handleCompletion: resolve,
    });
  });

  if (journal == "wal") {
    Assert.ok(await IOUtils.exists(path + "-wal"), "-wal exists before close");
    Assert.greater(
      (await IOUtils.stat(path + "-wal")).size,
      0,
      "-wal size is non-zero"
    );
  } else {
    Assert.ok(
      await IOUtils.exists(path + "-journal"),
      "-journal exists before close"
    );
    Assert.equal(
      (await IOUtils.stat(path + "-journal")).size,
      0,
      "-journal is truncated after every transaction"
    );
  }

  await new Promise(resolve => db.asyncClose(resolve));

  if (journal == "wal") {
    Assert.ok(await IOUtils.exists(path + "-wal"), "-wal persists after close");
    Assert.equal(
      (await IOUtils.stat(path + "-wal")).size,
      0,
      "-wal has been truncated"
    );
  } else {
    Assert.ok(
      await IOUtils.exists(path + "-journal"),
      "-journal persists after close"
    );
    Assert.equal(
      (await IOUtils.stat(path + "-journal")).size,
      0,
      "-journal has been truncated"
    );
  }
}

async function getDbPath(name) {
  let path = PathUtils.join(PathUtils.profileDir, name + ".sqlite");
  Assert.ok(!(await IOUtils.exists(path)), "database should not exist");
  return path;
}

add_task(async function () {
  for (let journal of ["truncate""wal"]) {
    await check_journal_persists(
      Services.storage.openDatabase(
        new FileUtils.File(await getDbPath(`shared-${journal}`))
      ),
      journal
    );
    await check_journal_persists(
      Services.storage.openUnsharedDatabase(
        new FileUtils.File(await getDbPath(`unshared-${journal}`))
      ),
      journal
    );
    await check_journal_persists(
      await openAsyncDatabase(
        new FileUtils.File(await getDbPath(`async-${journal}`))
      ),
      journal
    );
  }
});

Messung V0.5
C=95 H=74 G=84

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge