use of org.neo4j.bolt.testing.client.TransportConnection in project neo4j by neo4j.
the class ConcurrentAccessIT method newWorker.
private Callable<Void> newWorker(final int iterationsToRun) throws Exception {
return new Callable<Void>() {
private final byte[] init = util.defaultAuth();
private final byte[] createAndRollback = util.defaultRunExplicitCommitTxAndRollBack("CREATE (n)");
private final byte[] matchAll = util.defaultRunAutoCommitTx("MATCH (n) RETURN n");
@Override
public Void call() throws Exception {
// Connect
TransportConnection client = newConnection();
client.connect(server.lookupDefaultConnector()).send(util.defaultAcceptedVersions());
assertThat(client).satisfies(util.eventuallyReceivesSelectedProtocolVersion());
init(client);
for (int i = 0; i < iterationsToRun; i++) {
createAndRollback(client);
}
return null;
}
private void init(TransportConnection client) throws Exception {
client.send(init);
assertThat(client).satisfies(util.eventuallyReceives(msgSuccess()));
}
private void createAndRollback(TransportConnection client) throws Exception {
client.send(createAndRollback);
assertThat(client).satisfies(util.eventuallyReceives(// begin
msgSuccess(), msgSuccess(message -> assertThat(message).containsKeys("t_first", "qid").containsEntry("fields", // run
emptyList())), // pull_all
msgSuccess(message -> assertThat(message).containsKeys("t_last", "db")), // roll_back
msgSuccess()));
client.send(matchAll);
assertThat(client).satisfies(util.eventuallyReceives(msgSuccess(message -> assertThat(message).containsKey("t_first").containsEntry("fields", // run
singletonList("n"))), // pull_all
msgSuccess(message -> assertThat(message).containsKeys("t_last", "db"))));
}
};
}
Aggregations