コード例 #1
0
  public void testTransactionConsistentVersion() throws Exception {

    store(new Item(NEWER));
    db().commit();

    Item newer = itemByName(NEWER);
    Item original = itemByName(ORIGINAL);

    Assert.isGreater(version(original), version(newer));

    newer._name += " modified";
    original._name += " modified";

    store(newer);
    store(original);

    db().commit();

    Assert.areEqual(version(newer), version(original));

    reopen();

    newer = itemByName(newer._name);
    original = itemByName(original._name);

    Assert.areEqual(version(newer), version(original));
  }
コード例 #2
0
  public void testVersionIncrease() {

    Item item = (Item) retrieveOnlyInstance(Item.class);
    ObjectInfo objectInfo = db().getObjectInfo(item);
    long version1 = objectInfo.getCommitTimestamp();
    item._name = "modified";
    db().store(item);
    db().commit();
    long version2 = objectInfo.getCommitTimestamp();
    Assert.isGreater(version1, version2);
    db().store(item);
    db().commit();
    objectInfo = db().getObjectInfo(item);
    long version3 = objectInfo.getCommitTimestamp();
    Assert.isGreater(version2, version3);
  }