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());
}
use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class BoltFactoryImplTest method newDbMock.
private static GraphDatabaseAPI newDbMock() {
GraphDatabaseAPI db = mock(GraphDatabaseAPI.class);
DependencyResolver dependencyResolver = mock(DependencyResolver.class);
when(db.getDependencyResolver()).thenReturn(dependencyResolver);
GraphDatabaseQueryService queryService = mock(GraphDatabaseQueryService.class);
when(queryService.getDependencyResolver()).thenReturn(dependencyResolver);
when(dependencyResolver.resolveDependency(GraphDatabaseQueryService.class)).thenReturn(queryService);
return db;
}
use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class StorageLayerRelTypesAndDegreeTest method resolveNeoStores.
private NeoStores resolveNeoStores() {
DependencyResolver resolver = db.getDependencyResolver();
RecordStorageEngine storageEngine = resolver.resolveDependency(RecordStorageEngine.class);
return storageEngine.testAccessNeoStores();
}
use of org.neo4j.graphdb.DependencyResolver 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);
}
Aggregations