Search in sources :

Example 1 with DependencyResolver

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();
            }
        }
    };
}
Also used : UsageData(org.neo4j.udc.UsageData) HashMap(java.util.HashMap) AuthManager(org.neo4j.kernel.api.security.AuthManager) Statement(org.junit.runners.model.Statement) Setting(org.neo4j.graphdb.config.Setting) UserManagerSupplier(org.neo4j.kernel.api.security.UserManagerSupplier) DependencyResolver(org.neo4j.graphdb.DependencyResolver) BoltFactoryImpl(org.neo4j.bolt.v1.runtime.BoltFactoryImpl) BoltStateMachine(org.neo4j.bolt.v1.runtime.BoltStateMachine) Authentication(org.neo4j.bolt.security.auth.Authentication) BasicAuthentication(org.neo4j.bolt.security.auth.BasicAuthentication) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory)

Example 2 with DependencyResolver

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());
}
Also used : TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Test(org.junit.Test)

Example 3 with DependencyResolver

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;
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 4 with DependencyResolver

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();
}
Also used : RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 5 with DependencyResolver

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);
}
Also used : CanWrite(org.neo4j.kernel.impl.factory.CanWrite) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) Procedures(org.neo4j.kernel.impl.proc.Procedures) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Before(org.junit.Before)

Aggregations

DependencyResolver (org.neo4j.graphdb.DependencyResolver)51 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)18 Test (org.junit.Test)15 Transaction (org.neo4j.graphdb.Transaction)10 ThreadToStatementContextBridge (org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)9 Before (org.junit.Before)8 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)8 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)7 NeoStores (org.neo4j.kernel.impl.store.NeoStores)7 Monitors (org.neo4j.kernel.monitoring.Monitors)7 Node (org.neo4j.graphdb.Node)6 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)6 NeoStoreDataSource (org.neo4j.kernel.NeoStoreDataSource)5 Statement (org.neo4j.kernel.api.Statement)5 File (java.io.File)4 IOException (java.io.IOException)4 Label (org.neo4j.graphdb.Label)4 PageCache (org.neo4j.io.pagecache.PageCache)4 Guard (org.neo4j.kernel.guard.Guard)4 QueryExecutionEngine (org.neo4j.kernel.impl.query.QueryExecutionEngine)4