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); }
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)); }
private void assertHandlerComparison(Comparable4 handler, Object smaller, Object greater) { PreparedComparison comparable = handler.prepareComparison(context(), smaller); Assert.isNotNull(comparable); Assert.areEqual(0, comparable.compareTo(smaller)); Assert.isSmaller(0, comparable.compareTo(greater)); Assert.isGreater(0, comparable.compareTo(null)); comparable = handler.prepareComparison(context(), greater); Assert.isNotNull(comparable); Assert.areEqual(0, comparable.compareTo(greater)); Assert.isGreater(0, comparable.compareTo(smaller)); Assert.isGreater(0, comparable.compareTo(null)); comparable = handler.prepareComparison(context(), null); Assert.isNotNull(comparable); Assert.areEqual(0, comparable.compareTo(null)); Assert.isSmaller(0, comparable.compareTo(smaller)); }