use of org.apache.jena.tdb.transaction.NodeTableTrans in project jena by apache.
the class AbstractTestNodeTableTrans method nodetrans_03.
@Test
public void nodetrans_03() {
Transaction txn = createTxn(11);
NodeTableTrans ntt = create(txn);
NodeTable nt0 = ntt.getBaseNodeTable();
ntt.begin(txn);
// Add a node
NodeId nodeId = ntt.getAllocateNodeId(node1);
// Check not in the base.
assertEquals(NodeId.NodeDoesNotExist, nt0.getNodeIdForNode(node1));
assertNull(nt0.getNodeForNodeId(nodeId));
// Check is in the transaction node table.
assertEquals(node1, ntt.getNodeForNodeId(nodeId));
ntt.abort(txn);
// Check it is not in the base.
assertEquals(NodeId.NodeDoesNotExist, nt0.getNodeIdForNode(node1));
assertNull(nt0.getNodeForNodeId(nodeId));
ntt.commitClearup(txn);
}
use of org.apache.jena.tdb.transaction.NodeTableTrans in project jena by apache.
the class AbstractTestNodeTableTrans method nodetrans_04.
@Test
public void nodetrans_04() {
Transaction txn = createTxn(11);
NodeTableTrans ntt = create(txn, node1);
NodeTable nt0 = ntt.getBaseNodeTable();
ntt.begin(txn);
// Add a node
NodeId nodeId = ntt.getAllocateNodeId(node2);
// Not here
assertEquals(NodeId.NodeDoesNotExist, nt0.getNodeIdForNode(node2));
// Is here
assertEquals(nodeId, ntt.getNodeIdForNode(node2));
ntt.commitPrepare(txn);
ntt.commitEnact(txn);
assertEquals(nodeId, nt0.getNodeIdForNode(node2));
ntt.commitClearup(txn);
}
use of org.apache.jena.tdb.transaction.NodeTableTrans in project jena by apache.
the class AbstractTestNodeTableTrans method create.
private NodeTableTrans create(Transaction txn, NodeTable base) {
RecordFactory recordFactory = new RecordFactory(SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId);
Index idx = new IndexMap(recordFactory);
ObjectFile objectFile = createObjectFile();
NodeTableTrans ntt = new NodeTableTrans(txn, "test", base, idx, objectFile);
return ntt;
}
Aggregations