use of org.neo4j.test.mockito.matcher.RootCauseMatcher in project neo4j by neo4j.
the class CommunityLockAcquisitionTimeoutIT method timeoutOnAcquiringSharedLock.
@Test(timeout = TEST_TIMEOUT)
public void timeoutOnAcquiringSharedLock() throws Exception {
expectedException.expect(new RootCauseMatcher<>(LockAcquisitionTimeoutException.class, "The transaction has been terminated. " + "Retry your operation in a new transaction, and you should see a successful result. " + "Unable to acquire lock within configured timeout. " + "Unable to acquire lock for resource: SCHEMA with id: 0 within 2000 millis."));
try (Transaction ignored = database.beginTx()) {
database.schema().indexFor(marker).on(TEST_PROPERTY_NAME).create();
Future<Void> propertySetFuture = secondTransactionExecutor.executeDontWait(state -> {
try (Transaction nestedTransaction = database.beginTx()) {
ResourceIterator<Node> nodes = database.findNodes(marker);
Node node = nodes.next();
node.addLabel(Label.label("anotherLabel"));
nestedTransaction.success();
}
return null;
});
secondTransactionExecutor.waitUntilWaiting(sharedLockWaitingPredicate());
clockExecutor.execute((OtherThreadExecutor.WorkerCommand<Void, Void>) state -> {
fakeClock.forward(3, TimeUnit.SECONDS);
return null;
});
propertySetFuture.get();
fail("Should throw termination exception.");
}
}
use of org.neo4j.test.mockito.matcher.RootCauseMatcher in project neo4j by neo4j.
the class CommunityLockAcquisitionTimeoutIT method timeoutOnAcquiringExclusiveLock.
@Test(timeout = 5000)
public void timeoutOnAcquiringExclusiveLock() throws Exception {
expectedException.expect(new RootCauseMatcher<>(LockAcquisitionTimeoutException.class, "The transaction has been terminated. " + "Retry your operation in a new transaction, and you should see a successful result. " + "Unable to acquire lock within configured timeout. " + "Unable to acquire lock for resource: NODE with id: 0 within 2000 millis."));
try (Transaction ignored = database.beginTx()) {
ResourceIterator<Node> nodes = database.findNodes(marker);
Node node = nodes.next();
node.setProperty(TEST_PROPERTY_NAME, "b");
Future<Void> propertySetFuture = secondTransactionExecutor.executeDontWait(state -> {
try (Transaction transaction1 = database.beginTx()) {
node.setProperty(TEST_PROPERTY_NAME, "b");
transaction1.success();
}
return null;
});
secondTransactionExecutor.waitUntilWaiting(exclusiveLockWaitingPredicate());
clockExecutor.execute((OtherThreadExecutor.WorkerCommand<Void, Void>) state -> {
fakeClock.forward(3, TimeUnit.SECONDS);
return null;
});
propertySetFuture.get();
fail("Should throw termination exception.");
}
}
Aggregations