Search in sources :

Example 6 with Transaction

use of org.apache.jena.tdb.transaction.Transaction 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);
}
Also used : NodeTableTrans(org.apache.jena.tdb.transaction.NodeTableTrans) Transaction(org.apache.jena.tdb.transaction.Transaction) NodeId(org.apache.jena.tdb.store.NodeId) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 7 with Transaction

use of org.apache.jena.tdb.transaction.Transaction 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);
}
Also used : NodeTableTrans(org.apache.jena.tdb.transaction.NodeTableTrans) Transaction(org.apache.jena.tdb.transaction.Transaction) NodeId(org.apache.jena.tdb.store.NodeId) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 8 with Transaction

use of org.apache.jena.tdb.transaction.Transaction in project jena by apache.

the class AbstractTestObjectFileTrans method setup.

@Before
public void setup() {
    txn = new Transaction(null, 5, ReadWrite.WRITE, ++count, null, tm);
    file1 = createFile("base");
    file2 = createFile("log");
}
Also used : Transaction(org.apache.jena.tdb.transaction.Transaction) Before(org.junit.Before)

Aggregations

Transaction (org.apache.jena.tdb.transaction.Transaction)8 BaseTest (org.apache.jena.atlas.junit.BaseTest)7 NodeTableTrans (org.apache.jena.tdb.transaction.NodeTableTrans)7 Test (org.junit.Test)7 NodeId (org.apache.jena.tdb.store.NodeId)5 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)3 Before (org.junit.Before)1