use of org.neo4j.kernel.impl.factory.CanWrite in project neo4j by neo4j.
the class StorageLayerTest method before.
@SuppressWarnings("deprecation")
@Before
public void before() {
db = (GraphDatabaseAPI) createGraphDatabase();
DependencyResolver resolver = db.getDependencyResolver();
this.disk = resolver.resolveDependency(StorageEngine.class).storeReadLayer();
this.state = new KernelStatement(null, null, disk.newStatement(), new Procedures(), new CanWrite(), LockTracer.NONE);
}
use of org.neo4j.kernel.impl.factory.CanWrite in project neo4j by neo4j.
the class NeoStoreDataSourceRule method getDataSource.
public NeoStoreDataSource getDataSource(File storeDir, FileSystemAbstraction fs, IdGeneratorFactory idGeneratorFactory, IdTypeConfigurationProvider idConfigurationProvider, PageCache pageCache, Config config, DatabaseHealth databaseHealth, LogService logService) {
if (dataSource != null) {
dataSource.stop();
dataSource.shutdown();
}
StatementLocksFactory locksFactory = mock(StatementLocksFactory.class);
StatementLocks statementLocks = mock(StatementLocks.class);
Locks.Client locks = mock(Locks.Client.class);
when(statementLocks.optimistic()).thenReturn(locks);
when(statementLocks.pessimistic()).thenReturn(locks);
when(locksFactory.newInstance()).thenReturn(statementLocks);
JobScheduler jobScheduler = mock(JobScheduler.class, RETURNS_MOCKS);
Monitors monitors = new Monitors();
LabelScanStoreProvider labelScanStoreProvider = nativeLabelScanStoreProvider(storeDir, fs, pageCache, config, logService);
SystemNanoClock clock = Clocks.nanoClock();
dataSource = new NeoStoreDataSource(storeDir, config, idGeneratorFactory, IdReuseEligibility.ALWAYS, idConfigurationProvider, logService, mock(JobScheduler.class, RETURNS_MOCKS), mock(TokenNameLookup.class), dependencyResolverForNoIndexProvider(labelScanStoreProvider), mock(PropertyKeyTokenHolder.class), mock(LabelTokenHolder.class), mock(RelationshipTypeTokenHolder.class), locksFactory, mock(SchemaWriteGuard.class), mock(TransactionEventHandlers.class), IndexingService.NO_MONITOR, fs, mock(TransactionMonitor.class), databaseHealth, mock(PhysicalLogFile.Monitor.class), TransactionHeaderInformationFactory.DEFAULT, new StartupStatisticsProvider(), null, new CommunityCommitProcessFactory(), mock(InternalAutoIndexing.class), pageCache, new StandardConstraintSemantics(), monitors, new Tracers("null", NullLog.getInstance(), monitors, jobScheduler), mock(Procedures.class), IOLimiter.unlimited(), new AvailabilityGuard(clock, NullLog.getInstance()), clock, new CanWrite(), new StoreCopyCheckPointMutex());
return dataSource;
}
use of org.neo4j.kernel.impl.factory.CanWrite in project neo4j by neo4j.
the class KernelStatementTest method shouldReleaseStorageStatementWhenForceClosed.
@Test
public void shouldReleaseStorageStatementWhenForceClosed() throws Exception {
// given
StorageStatement storeStatement = mock(StorageStatement.class);
KernelStatement statement = new KernelStatement(mock(KernelTransactionImplementation.class), null, storeStatement, new Procedures(), new CanWrite(), LockTracer.NONE);
statement.acquire();
// when
statement.forceClose();
// then
verify(storeStatement).release();
}
use of org.neo4j.kernel.impl.factory.CanWrite in project neo4j by neo4j.
the class KernelStatementTest method shouldThrowTerminateExceptionWhenTransactionTerminated.
@Test(expected = TransactionTerminatedException.class)
public void shouldThrowTerminateExceptionWhenTransactionTerminated() throws Exception {
KernelTransactionImplementation transaction = mock(KernelTransactionImplementation.class);
when(transaction.getReasonIfTerminated()).thenReturn(Optional.of(Status.Transaction.Terminated));
when(transaction.securityContext()).thenReturn(AUTH_DISABLED);
KernelStatement statement = new KernelStatement(transaction, null, mock(StorageStatement.class), null, new CanWrite(), LockTracer.NONE);
statement.acquire();
statement.readOperations().nodeExists(0);
}
use of org.neo4j.kernel.impl.factory.CanWrite in project neo4j by neo4j.
the class KernelTransactionFactory method kernelTransactionWithInternals.
static Instances kernelTransactionWithInternals(SecurityContext securityContext) {
TransactionHeaderInformation headerInformation = new TransactionHeaderInformation(-1, -1, new byte[0]);
TransactionHeaderInformationFactory headerInformationFactory = mock(TransactionHeaderInformationFactory.class);
when(headerInformationFactory.create()).thenReturn(headerInformation);
StorageEngine storageEngine = mock(StorageEngine.class);
StoreReadLayer storeReadLayer = mock(StoreReadLayer.class);
StorageStatement storageStatement = mock(StorageStatement.class);
when(storeReadLayer.newStatement()).thenReturn(storageStatement);
when(storageEngine.storeReadLayer()).thenReturn(storeReadLayer);
KernelTransactionImplementation transaction = new KernelTransactionImplementation(mock(StatementOperationContainer.class), mock(SchemaWriteGuard.class), new TransactionHooks(), mock(ConstraintIndexCreator.class), new Procedures(), headerInformationFactory, mock(TransactionRepresentationCommitProcess.class), mock(TransactionMonitor.class), mock(Supplier.class), mock(Pool.class), Clocks.systemClock(), NULL, LockTracer.NONE, PageCursorTracerSupplier.NULL, storageEngine, new CanWrite());
StatementLocks statementLocks = new SimpleStatementLocks(new NoOpClient());
transaction.initialize(0, 0, statementLocks, KernelTransaction.Type.implicit, securityContext, 0L);
return new Instances(transaction, storageEngine, storeReadLayer, storageStatement);
}
Aggregations