use of org.apache.jena.graph.TransactionHandler in project jena by apache.
the class TransactionHandlerContractTest method testTransactionsExistAsPerTransactionSupported.
/**
* Test that Graphs have transaction support methods, and that if they fail
* on some g they fail because they do not support the operation.
*/
@SuppressWarnings("deprecation")
@ContractTest
public void testTransactionsExistAsPerTransactionSupported() {
// Write out explicitly
Command cmd = new Command() {
@Override
public Object execute() {
return null;
}
};
TransactionHandler th = getTransactionHandlerProducer().newInstance();
if (th.transactionsSupported()) {
th.begin();
th.abort();
th.begin();
th.commit();
th.execute(() -> {
});
th.calculate(() -> null);
th.executeInTransaction(cmd);
th.executeInTransaction(() -> null);
} else {
try {
th.begin();
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.abort();
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.commit();
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
/* */
try {
th.execute(() -> {
});
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.calculate(() -> null);
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.executeInTransaction(cmd);
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.executeInTransaction(() -> null);
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
}
}
use of org.apache.jena.graph.TransactionHandler in project jena by apache.
the class TestSpecials method zero_graph_txn_5.
@Test(expected = JenaException.class)
public void zero_graph_txn_5() {
DatasetGraph dsg = DatasetGraphZero.create();
Graph g = dsg.getDefaultGraph();
TransactionHandler h = g.getTransactionHandler();
h.commit();
}
use of org.apache.jena.graph.TransactionHandler in project jena by apache.
the class TransactionHandlerContractTest method testExecuteInTransactionCatchesThrowable.
@SuppressWarnings("deprecation")
@ContractTest
public void testExecuteInTransactionCatchesThrowable() {
TransactionHandler th = getTransactionHandlerProducer().newInstance();
if (th.transactionsSupported()) {
Command cmd = new Command() {
@Override
public Object execute() throws Error {
throw new Error();
}
};
try {
th.executeInTransaction(cmd);
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
try {
th.execute(() -> {
throw new Error();
});
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
try {
th.calculate(() -> {
throw new Error();
});
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
}
}
use of org.apache.jena.graph.TransactionHandler in project jena by apache.
the class TxnDataset2Graph method addHandler.
private static void addHandler(Map<Object, TransactionHandler> handlers, Graph graph) {
TransactionHandler th = graph.getTransactionHandler();
if (!th.transactionsSupported())
return;
Object key = calcKey(graph);
if (th.transactionsSupported())
handlers.put(key, th);
}
use of org.apache.jena.graph.TransactionHandler in project jena by apache.
the class TestSpecials method zero_graph_txn_3.
@Test(expected = JenaException.class)
public void zero_graph_txn_3() {
DatasetGraph dsg = DatasetGraphZero.create();
Graph g = dsg.getDefaultGraph();
TransactionHandler h = g.getTransactionHandler();
h.begin();
h.begin();
}
Aggregations