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)); }
public static Item newItem(int depth) { if (depth == 0) { return null; } Item header = new Item(depth); header._next = TAItem.newTAITem(depth - 1); return header; }
protected void store() { Item dd1 = new Item(); dd1.atom = new Atom("justone"); store(dd1); Item dd2 = new Item(); dd2.atom = dd1.atom; store(dd2); }
protected Object[] createValues() { Item[] values = new Item[data.length + 1]; for (int i = 0; i < data.length; i++) { Item item = new Item(); item._typedPrimitive = data[i]; item._typedWrapper = new Short(data[i]); item._untyped = new Short(data[i]); values[i] = item; } values[values.length - 1] = new Item(); return values; }
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 testRefresh() { ExtObjectContainer client1 = openNewSession(); ExtObjectContainer client2 = openNewSession(); Item item1 = retrieveInstance(client1); Item item2 = retrieveInstance(client2); Item next1 = item1; int value = 10; while (next1 != null) { Assert.areEqual(value, next1.getValue()); next1 = next1.next(); value--; } Item next2 = item2; value = 10; while (next2 != null) { Assert.areEqual(value, next2.getValue()); next2 = next2.next(); value--; } item1.setValue(100); item1.next().setValue(200); client1.store(item1, 2); client1.commit(); Assert.areEqual(100, item1.getValue()); Assert.areEqual(200, item1.next().getValue()); Assert.areEqual(10, item2.getValue()); Assert.areEqual(9, item2.next().getValue()); // refresh 0 client2.refresh(item2, 0); Assert.areEqual(10, item2.getValue()); Assert.areEqual(9, item2.next().getValue()); // refresh 1 client2.refresh(item2, 1); Assert.areEqual(100, item2.getValue()); Assert.areEqual(9, item2.next().getValue()); // refresh 2 client2.refresh(item2, 2); Assert.areEqual(100, item2.getValue()); // FIXME: maybe a bug // Assert.areEqual(200, item2.next().getValue()); next1 = item1; value = 1000; while (next1 != null) { next1.setValue(value); next1 = next1.next(); value++; } client1.store(item1, 5); client1.commit(); client2.refresh(item2, 5); next2 = item2; for (int i = 1000; i < 1005; i++) { Assert.areEqual(i, next2.getValue()); next2 = next2.next(); } client1.close(); client2.close(); }
protected void store() throws Exception { Item item = TAItem.newItem(ITEM_DEPTH); item._isRoot = true; store(item); }