Search in sources :

Example 66 with KernelTransaction

use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.

the class KernelTransactionImplementationTest method shouldThrowOnTerminationInCommit.

@Test(expected = TransactionTerminatedException.class)
public void shouldThrowOnTerminationInCommit() throws Exception {
    KernelTransaction transaction = newTransaction(securityContext());
    transactionInitializer.accept(transaction);
    transaction.success();
    transaction.markForTermination(Status.General.UnknownError);
    transaction.close();
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Test(org.junit.Test)

Example 67 with KernelTransaction

use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.

the class KernelTransactionImplementationTest method shouldNotDowngradeFailureState.

@Test
public void shouldNotDowngradeFailureState() throws Exception {
    try (KernelTransaction transaction = newTransaction(securityContext())) {
        // WHEN
        transactionInitializer.accept(transaction);
        transaction.markForTermination(Status.General.UnknownError);
        transaction.failure();
        assertEquals(Status.General.UnknownError, transaction.getReasonIfTerminated().get());
    }
    // THEN
    verify(transactionMonitor, times(1)).transactionFinished(false, isWriteTx);
    verify(transactionMonitor, times(1)).transactionTerminated(isWriteTx);
    verifyExtraInteractionWithTheMonitor(transactionMonitor, isWriteTx);
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Test(org.junit.Test)

Example 68 with KernelTransaction

use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.

the class KernelSchemaStateFlushingTest method createConstraint.

private ConstraintDescriptor createConstraint() throws KernelException {
    try (KernelTransaction transaction = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
        Statement statement = transaction.acquireStatement()) {
        ConstraintDescriptor descriptor = statement.schemaWriteOperations().uniquePropertyConstraintCreate(SchemaDescriptorFactory.forLabel(1, 1));
        transaction.success();
        return descriptor;
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Statement(org.neo4j.kernel.api.Statement) ConstraintDescriptor(org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor)

Example 69 with KernelTransaction

use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.

the class KernelSchemaStateFlushingTest method createIndex.

private NewIndexDescriptor createIndex() throws KernelException {
    try (KernelTransaction transaction = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
        Statement statement = transaction.acquireStatement()) {
        NewIndexDescriptor descriptor = statement.schemaWriteOperations().indexCreate(SchemaDescriptorFactory.forLabel(1, 1));
        transaction.success();
        return descriptor;
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Statement(org.neo4j.kernel.api.Statement)

Example 70 with KernelTransaction

use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.

the class KernelSchemaStateFlushingTest method awaitIndexOnline.

private void awaitIndexOnline(NewIndexDescriptor descriptor, String keyForProbing) throws IndexNotFoundKernelException, TransactionFailureException {
    try (KernelTransaction transaction = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
        Statement statement = transaction.acquireStatement()) {
        SchemaIndexTestHelper.awaitIndexOnline(statement.readOperations(), descriptor);
        transaction.success();
    }
    awaitSchemaStateCleared(keyForProbing);
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Statement(org.neo4j.kernel.api.Statement)

Aggregations

KernelTransaction (org.neo4j.kernel.api.KernelTransaction)77 Test (org.junit.Test)37 Statement (org.neo4j.kernel.api.Statement)30 TransactionFailureException (org.neo4j.kernel.api.exceptions.TransactionFailureException)14 ThreadToStatementContextBridge (org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)14 KernelAPI (org.neo4j.kernel.api.KernelAPI)9 TopLevelTransaction (org.neo4j.kernel.impl.coreapi.TopLevelTransaction)8 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)7 TransactionTerminatedException (org.neo4j.graphdb.TransactionTerminatedException)6 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)6 QueryRegistryOperations (org.neo4j.kernel.api.QueryRegistryOperations)4 SecurityContext (org.neo4j.kernel.api.security.SecurityContext)4 KernelStatement (org.neo4j.kernel.impl.api.KernelStatement)4 RemoteException (java.rmi.RemoteException)3 ExpectedException (org.junit.rules.ExpectedException)3 DependencyResolver (org.neo4j.graphdb.DependencyResolver)3 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)3 ShellException (org.neo4j.shell.ShellException)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2