Search in sources :

Example 21 with ConstraintViolationException

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

the class UniqueConstraintCompatibility method onlineConstraintShouldRejectChangingEntryToAlreadyIndexedValueThatOtherTransactionsAreRemoving.

@Test
public void onlineConstraintShouldRejectChangingEntryToAlreadyIndexedValueThatOtherTransactionsAreRemoving() throws Exception {
    // Given
    givenOnlineConstraint();
    transaction(setProperty(b, "b"), success);
    Transaction otherTx = db.beginTx();
    a.removeLabel(label);
    suspend(otherTx);
    // When
    try {
        transaction(setProperty(b, "a"), success, fail("Changing a property to an already indexed value should have thrown"));
    } catch (ConstraintViolationException ignore) {
    // we're happy
    } finally {
        resume(otherTx);
        otherTx.failure();
        otherTx.close();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ConstraintViolationException(org.neo4j.graphdb.ConstraintViolationException) Test(org.junit.Test)

Aggregations

ConstraintViolationException (org.neo4j.graphdb.ConstraintViolationException)21 Test (org.junit.Test)14 BatchInserter (org.neo4j.unsafe.batchinsert.BatchInserter)8 Transaction (org.neo4j.graphdb.Transaction)6 Label (org.neo4j.graphdb.Label)4 File (java.io.File)3 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)3 Node (org.neo4j.graphdb.Node)3 NotFoundException (org.neo4j.graphdb.NotFoundException)3 Statement (org.neo4j.kernel.api.Statement)3 EntityNotFoundException (org.neo4j.kernel.api.exceptions.EntityNotFoundException)3 InvalidTransactionTypeKernelException (org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException)3 PropertyNotFoundException (org.neo4j.kernel.api.exceptions.PropertyNotFoundException)2 IllegalTokenNameException (org.neo4j.kernel.api.exceptions.schema.IllegalTokenNameException)2 HighlyAvailableGraphDatabase (org.neo4j.kernel.ha.HighlyAvailableGraphDatabase)2 IOException (java.io.IOException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 ComException (org.neo4j.com.ComException)1 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)1 TransientTransactionFailureException (org.neo4j.graphdb.TransientTransactionFailureException)1