use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class StorageLayerTest method readOps.
protected ReadOperations readOps() {
DependencyResolver dependencyResolver = db.getDependencyResolver();
Statement statement = dependencyResolver.resolveDependency(ThreadToStatementContextBridge.class).get();
return statement.readOperations();
}
use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class DependencyResolverSupplierTest method shouldReturnTheDependencyResolveFromTheRegisteredDatasource.
@Test
public void shouldReturnTheDependencyResolveFromTheRegisteredDatasource() throws Exception {
// given
DataSourceManager dataSourceManager = new DataSourceManager();
DependencyResolverSupplier supplier = new DependencyResolverSupplier(dataSourceManager);
NeoStoreDataSource neoStoreDataSource = mock(NeoStoreDataSource.class);
DependencyResolver dependencyResolver = mock(DependencyResolver.class);
when(neoStoreDataSource.getDependencyResolver()).thenReturn(dependencyResolver);
// when
dataSourceManager.register(neoStoreDataSource);
// then
assertEquals(dependencyResolver, supplier.get());
}
use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class CypherExecutor method start.
@Override
public void start() throws Throwable {
DependencyResolver resolver = database.getGraph().getDependencyResolver();
this.executionEngine = (ExecutionEngine) resolver.resolveDependency(QueryExecutionEngine.class);
this.service = resolver.resolveDependency(GraphDatabaseQueryService.class);
this.contextFactory = Neo4jTransactionalContextFactory.create(this.service, locker);
}
use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class SessionRule method apply.
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
Map<Setting<?>, String> config = new HashMap<>();
config.put(GraphDatabaseSettings.auth_enabled, Boolean.toString(authEnabled));
gdb = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase(config);
DependencyResolver resolver = gdb.getDependencyResolver();
Authentication authentication = authentication(resolver.resolveDependency(AuthManager.class), resolver.resolveDependency(UserManagerSupplier.class));
boltFactory = new BoltFactoryImpl(gdb, new UsageData(null), NullLogService.getInstance(), resolver.resolveDependency(ThreadToStatementContextBridge.class), authentication, BoltConnectionTracker.NOOP, Config.defaults());
boltFactory.start();
try {
base.evaluate();
} finally {
try {
if (runningMachines != null) {
runningMachines.forEach(BoltStateMachine::close);
}
} catch (Throwable e) {
e.printStackTrace();
}
gdb.shutdown();
}
}
};
}
use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class BoltFactoryImplTest method txIdStoreRefreshedAfterRestart.
@Test
public void txIdStoreRefreshedAfterRestart() throws Throwable {
GraphDatabaseAPI db = newDbMock();
DependencyResolver dependencyResolver = db.getDependencyResolver();
TransactionIdStore txIdStoreBeforeRestart = mock(TransactionIdStore.class);
when(txIdStoreBeforeRestart.getLastClosedTransactionId()).thenReturn(42L);
TransactionIdStore txIdStoreAfterRestart = mock(TransactionIdStore.class);
when(txIdStoreAfterRestart.getLastClosedTransactionId()).thenReturn(4242L);
when(dependencyResolver.resolveDependency(TransactionIdStore.class)).thenReturn(txIdStoreBeforeRestart).thenReturn(txIdStoreAfterRestart);
BoltFactoryImpl boltFactory = newBoltFactory(db);
boltFactory.start();
BoltStateMachine stateMachine1 = boltFactory.newMachine(CONNECTION_DESCRIPTOR, mock(Runnable.class), CLOCK);
assertEquals(42, stateMachine1.spi.transactionSpi().newestEncounteredTxId());
boltFactory.stop();
boltFactory.start();
BoltStateMachine stateMachine2 = boltFactory.newMachine(CONNECTION_DESCRIPTOR, mock(Runnable.class), CLOCK);
assertEquals(4242, stateMachine2.spi.transactionSpi().newestEncounteredTxId());
}
Aggregations