use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class IndexPopulationJobTest method getPropertyKeyForName.
private int getPropertyKeyForName(String name) throws TransactionFailureException {
try (KernelTransaction tx = kernel.newTransaction(KernelTransaction.Type.implicit, AnonymousContext.read());
Statement statement = tx.acquireStatement()) {
int result = statement.readOperations().propertyKeyGetForName(name);
tx.success();
return result;
}
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class KernelIT method txReturnsCorrectIdWhenRolledBack.
@Test
public void txReturnsCorrectIdWhenRolledBack() throws Exception {
executeDummyTxs(db, 42);
KernelTransaction tx = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
try (Statement statement = tx.acquireStatement()) {
statement.dataWriteOperations().nodeCreate();
}
tx.failure();
assertEquals(KernelTransaction.ROLLBACK, tx.closeTransaction());
assertFalse(tx.isOpen());
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class KernelIT method shouldKillTransactionsOnShutdown.
@Test
public void shouldKillTransactionsOnShutdown() throws Throwable {
// Given
assumeThat(kernel, instanceOf(Kernel.class));
// Then
try (KernelTransaction tx = kernel.newTransaction(KernelTransaction.Type.implicit, AnonymousContext.read())) {
((Kernel) kernel).stop();
tx.acquireStatement().readOperations().nodeExists(0L);
fail("Should have been terminated.");
} catch (TransactionTerminatedException e) {
// Success
}
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class KernelIT method txReturnsCorrectIdWhenCommitted.
@Test
public void txReturnsCorrectIdWhenCommitted() throws Exception {
executeDummyTxs(db, 42);
KernelTransaction tx = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
try (Statement statement = tx.acquireStatement()) {
statement.dataWriteOperations().nodeCreate();
}
tx.success();
long previousCommittedTxId = lastCommittedTxId(db);
assertEquals(previousCommittedTxId + 1, tx.closeTransaction());
assertFalse(tx.isOpen());
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class KernelIT method txReturnsCorrectIdWhenFailedlAndMarkedForTermination.
@Test
public void txReturnsCorrectIdWhenFailedlAndMarkedForTermination() throws Exception {
executeDummyTxs(db, 42);
KernelTransaction tx = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
try (Statement statement = tx.acquireStatement()) {
statement.dataWriteOperations().nodeCreate();
}
tx.failure();
tx.markForTermination(Status.Transaction.Terminated);
assertEquals(KernelTransaction.ROLLBACK, tx.closeTransaction());
assertFalse(tx.isOpen());
}
Aggregations