use of org.neo4j.graphdb.security.WriteOperationsNotAllowedException in project neo4j by neo4j.
the class CoreReplicationIT method shouldNotAllowTokenCreationFromAFollowerWithNoInitialTokens.
@Test
public void shouldNotAllowTokenCreationFromAFollowerWithNoInitialTokens() throws Exception {
// given
CoreClusterMember leader = cluster.coreTx((db, tx) -> {
db.createNode();
tx.success();
});
awaitForDataToBeApplied(leader);
dataMatchesEventually(leader, cluster.coreMembers());
CoreGraphDatabase follower = cluster.getDbWithRole(Role.FOLLOWER).database();
// when
try (Transaction tx = follower.beginTx()) {
follower.getAllNodes().iterator().next().setProperty("name", "Mark");
tx.success();
fail("Should have thrown exception");
} catch (WriteOperationsNotAllowedException ignored) {
// expected
assertThat(ignored.getMessage(), containsString("No write operations are allowed"));
}
}
use of org.neo4j.graphdb.security.WriteOperationsNotAllowedException in project neo4j by neo4j.
the class ReadOnlySlaveTest method givenClusterWithReadOnlySlaveWhenChangePropertyOnSlaveThenThrowException.
@Test
public void givenClusterWithReadOnlySlaveWhenChangePropertyOnSlaveThenThrowException() throws Throwable {
// Given
ManagedCluster cluster = clusterRule.startCluster();
Node node;
HighlyAvailableGraphDatabase master = cluster.getMaster();
try (Transaction tx = master.beginTx()) {
node = master.createNode();
tx.success();
}
// When
HighlyAvailableGraphDatabase readOnlySlave = cluster.getMemberByServerId(new InstanceId(2));
try (Transaction tx = readOnlySlave.beginTx()) {
Node slaveNode = readOnlySlave.getNodeById(node.getId());
// Then
slaveNode.setProperty("foo", "bar");
tx.success();
fail("Should have thrown exception");
} catch (WriteOperationsNotAllowedException ex) {
// Ok!
}
}
Aggregations