Search in sources :

Example 1 with InvalidTransactionTypeException

use of org.neo4j.graphdb.InvalidTransactionTypeException in project neo4j by neo4j.

the class ConstraintsInHAIT method creatingConstraintOnSlaveIsNotAllowed.

@Test
public void creatingConstraintOnSlaveIsNotAllowed() throws Exception {
    // given
    ClusterManager.ManagedCluster cluster = clusterRule.startCluster();
    HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
    slave.beginTx();
    try {
        ConstraintCreator constraintCreator = slave.schema().constraintFor(Label.label("LabelName")).assertPropertyIsUnique("PropertyName");
        // when
        constraintCreator.create();
        fail("should have thrown exception");
    } catch (InvalidTransactionTypeException e) {
        assertThat(e.getMessage(), equalTo("Modifying the database schema can only be done on the master server, " + "this server is a slave. Please issue schema modification commands directly to the master."));
    }
}
Also used : HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) ConstraintCreator(org.neo4j.graphdb.schema.ConstraintCreator) InvalidTransactionTypeException(org.neo4j.graphdb.InvalidTransactionTypeException) ClusterManager(org.neo4j.kernel.impl.ha.ClusterManager) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 InvalidTransactionTypeException (org.neo4j.graphdb.InvalidTransactionTypeException)1 ConstraintCreator (org.neo4j.graphdb.schema.ConstraintCreator)1 HighlyAvailableGraphDatabase (org.neo4j.kernel.ha.HighlyAvailableGraphDatabase)1 ClusterManager (org.neo4j.kernel.impl.ha.ClusterManager)1