use of org.neo4j.graphdb.TransientDatabaseFailureException in project neo4j by neo4j.
the class TopLevelTransactionTest method shouldLetThroughTransientFailureException.
@Test
public void shouldLetThroughTransientFailureException() throws Exception {
// GIVEN
KernelTransaction kernelTransaction = mock(KernelTransaction.class);
when(kernelTransaction.isOpen()).thenReturn(true);
doThrow(new TransientDatabaseFailureException("Just a random failure")).when(kernelTransaction).close();
ThreadToStatementContextBridge bridge = new ThreadToStatementContextBridge();
TopLevelTransaction transaction = new TopLevelTransaction(kernelTransaction, bridge);
// WHEN
transaction.success();
try {
transaction.close();
fail("Should have failed");
} catch (TransientFailureException e) {
// THEN Good
}
}
use of org.neo4j.graphdb.TransientDatabaseFailureException in project neo4j by neo4j.
the class ClusterPartitionIT method ensureInstanceIsReadOnlyInPendingState.
/*
* This method must be called on an instance that has had addSomeData() called on it.
*/
private void ensureInstanceIsReadOnlyInPendingState(HighlyAvailableGraphDatabase instance) {
assertEquals(PENDING, instance.getInstanceState());
tx(instance, retryACoupleOfTimesOn(TRANSIENT_ERRORS), db -> assertEquals(testPropValue, instance.getNodeById(testNodeId).getProperty(testPropKey)));
try (Transaction ignored = instance.beginTx()) {
instance.getNodeById(testNodeId).delete();
fail("Should not be able to do write transactions when detached");
} catch (TransientDatabaseFailureException | TransactionFailureException expected) {
// expected
}
}
Aggregations