protected void commit() throws TransactionFailureException { transaction.success(); try { transaction.close(); } finally { transaction = null; } }
protected void rollback() throws TransactionFailureException { transaction.failure(); try { transaction.close(); } finally { transaction = null; } }
protected void commit() throws TransactionFailureException { transaction.success(); try { transaction.close(); } finally { transaction = null; } }
private void stopDb() throws TransactionFailureException { if ( transaction != null && transaction.isOpen() ) { transaction.close(); } db.shutdown(); }
@After public void closeTransaction() throws Exception { tx.success(); tx.close(); }
@Test public void shouldRollbackAndThrowWhenTxIsBothFailedAndSuccess() throws Exception { // GIVEN long nodeId; int labelId; Transaction tx = beginTransaction(); nodeId = tx.dataWrite().nodeCreate(); labelId = tx.tokenWrite().labelGetOrCreateForName( "labello" ); tx.dataWrite().nodeAddLabel( nodeId, labelId ); tx.failure(); tx.success(); // WHEN try { tx.close(); fail( "Expected TransactionFailureException" ); } catch ( TransactionFailureException e ) { // wanted } // THEN assertNoNode( nodeId ); }
@After public void clean() throws Exception { if ( transaction != null ) { transaction.close(); } newTransaction(); transaction.schemaWrite() .constraintDrop( ConstraintDescriptorFactory.uniqueForLabel( label, propertyIds() ) ); commit(); try ( Transaction tx = kernel.beginTransaction( Transaction.Type.implicit, LoginContext.AUTH_DISABLED ); NodeCursor node = tx.cursors().allocateNodeCursor() ) { tx.dataRead().allNodesScan( node ); while ( node.next() ) { tx.dataWrite().nodeDelete( node.nodeReference() ); } tx.success(); } }