Skip to content

Commit

Permalink
Tests for AccessMode.WRITE
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaverner committed Feb 17, 2016
1 parent 8c9b15b commit 61098f6
Showing 1 changed file with 30 additions and 1 deletion.
Expand Up @@ -26,6 +26,7 @@
import org.neo4j.kernel.api.AccessMode; import org.neo4j.kernel.api.AccessMode;
import org.neo4j.kernel.api.DataWriteOperations; import org.neo4j.kernel.api.DataWriteOperations;
import org.neo4j.kernel.api.KernelTransactionTestBase; import org.neo4j.kernel.api.KernelTransactionTestBase;
import org.neo4j.kernel.api.SchemaWriteOperations;
import org.neo4j.kernel.api.exceptions.KernelException; import org.neo4j.kernel.api.exceptions.KernelException;


import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -62,6 +63,34 @@ public void shouldNotAllowSchemaWriteAccessInReadMode() throws Throwable
tx.acquireStatement().schemaWriteOperations(); tx.acquireStatement().schemaWriteOperations();
} }


@Test
public void shouldNotAllowSchemaWriteAccessInWriteMode() throws Throwable
{
// Given
KernelTransactionImplementation tx = newTransaction();
tx.setMode( AccessMode.WRITE );

// Expect
exception.expect( KernelException.class );

// When
tx.acquireStatement().schemaWriteOperations();
}

@Test
public void shouldAllowWritesInWriteMode() throws Throwable
{
// Given
KernelTransactionImplementation tx = newTransaction();
tx.setMode( AccessMode.WRITE );

// When
DataWriteOperations writes = tx.acquireStatement().dataWriteOperations();

// Then
assertNotNull( writes );
}

@Test @Test
public void shouldAllowWritesInFullMode() throws Throwable public void shouldAllowWritesInFullMode() throws Throwable
{ {
Expand All @@ -84,7 +113,7 @@ public void shoulAllowSchemaWriteAccessInFullMode() throws Throwable
tx.setMode( AccessMode.FULL ); tx.setMode( AccessMode.FULL );


// When // When
DataWriteOperations writes = tx.acquireStatement().dataWriteOperations(); SchemaWriteOperations writes = tx.acquireStatement().schemaWriteOperations();


// Then // Then
assertNotNull( writes ); assertNotNull( writes );
Expand Down

0 comments on commit 61098f6

Please sign in to comment.