private void stopDb() throws TransactionFailureException { if ( transaction != null && transaction.isOpen() ) { transaction.close(); } db.shutdown(); }
@Test public void txReturnsCorrectIdWhenRolledBack() throws Exception { executeDummyTxs( db, 42 ); org.neo4j.internal.kernel.api.Transaction tx = newTransaction( AUTH_DISABLED ); tx.dataWrite().nodeCreate(); tx.failure(); assertEquals( KernelTransaction.ROLLBACK, tx.closeTransaction() ); assertFalse( tx.isOpen() ); }
@Test public void txReturnsCorrectIdWhenMarkedForTermination() throws Exception { executeDummyTxs( db, 42 ); org.neo4j.internal.kernel.api.Transaction tx = newTransaction( AUTH_DISABLED ); tx.dataWrite().nodeCreate(); tx.markForTermination( Status.Transaction.Terminated ); assertEquals( KernelTransaction.ROLLBACK, tx.closeTransaction() ); assertFalse( tx.isOpen() ); }
@Test public void txReturnsCorrectIdWhenFailedAndMarkedForTermination() throws Exception { executeDummyTxs( db, 42 ); org.neo4j.internal.kernel.api.Transaction tx = newTransaction( AUTH_DISABLED ); tx.dataWrite().nodeCreate(); tx.failure(); tx.markForTermination( Status.Transaction.Terminated ); assertEquals( KernelTransaction.ROLLBACK, tx.closeTransaction() ); assertFalse( tx.isOpen() ); }
@Test public void txReturnsCorrectIdWhenCommitted() throws Exception { executeDummyTxs( db, 42 ); org.neo4j.internal.kernel.api.Transaction tx = newTransaction( AUTH_DISABLED ); tx.dataWrite().nodeCreate(); tx.success(); long previousCommittedTxId = lastCommittedTxId( db ); assertEquals( previousCommittedTxId + 1, tx.closeTransaction() ); assertFalse( tx.isOpen() ); }
@Test public void txReturnsCorrectIdWhenReadOnly() throws Exception { executeDummyTxs( db, 42 ); org.neo4j.internal.kernel.api.Transaction tx = newTransaction(); try ( NodeCursor node = tx.cursors().allocateNodeCursor() ) { tx.dataRead().singleNode( 1, node ); node.next(); } tx.success(); assertEquals( KernelTransaction.READ_ONLY, tx.closeTransaction() ); assertFalse( tx.isOpen() ); }