use of org.neo4j.driver.v1.exceptions.ClientException in project neo4j by neo4j.
the class BoltCausalClusteringIT method shouldNotBeAbleToWriteOnAReadSession.
@Test
public void shouldNotBeAbleToWriteOnAReadSession() throws Exception {
// given
cluster = clusterRule.withNumberOfReadReplicas(0).startCluster();
assertEventually("Failed to execute write query on read server", () -> {
switchLeader(cluster.awaitLeader());
CoreClusterMember leader = cluster.awaitLeader();
Driver driver = GraphDatabase.driver(leader.routingURI(), AuthTokens.basic("neo4j", "neo4j"));
try (Session session = driver.session(AccessMode.READ)) {
// when
session.run("CREATE (n:Person {name: 'Jim'})").consume();
return false;
} catch (ClientException ex) {
assertEquals("Write queries cannot be performed in READ access mode.", ex.getMessage());
return true;
} finally {
driver.close();
}
}, is(true), 30, SECONDS);
}
Aggregations