use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class ExtensionInitializer method initializePackages.
public Collection<Injectable<?>> initializePackages(Iterable<String> packageNames) {
GraphDatabaseAPI graphDatabaseService = neoServer.getDatabase().getGraph();
Config configuration = neoServer.getConfig();
Collection<Injectable<?>> injectables = new HashSet<>();
for (PluginLifecycle lifecycle : lifecycles) {
if (hasPackage(lifecycle, packageNames)) {
if (lifecycle instanceof SPIPluginLifecycle) {
SPIPluginLifecycle lifeCycleSpi = (SPIPluginLifecycle) lifecycle;
injectables.addAll(lifeCycleSpi.start(neoServer));
} else {
injectables.addAll(lifecycle.start(graphDatabaseService, new ConfigAdapter(configuration)));
}
}
}
return injectables;
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class ProcedureIT method shouldNotBeAbleToCallSchemaProcedureThroughWriteProcedureInWriteTransaction.
@Test
public void shouldNotBeAbleToCallSchemaProcedureThroughWriteProcedureInWriteTransaction() throws Throwable {
// Expect
exception.expect(QueryExecutionException.class);
exception.expectMessage("Schema operations are not allowed");
GraphDatabaseAPI gdapi = (GraphDatabaseAPI) db;
// When
try (Transaction tx = gdapi.beginTransaction(KernelTransaction.Type.explicit, AnonymousContext.write())) {
db.execute("CALL org.neo4j.procedure.writeProcedureCallingSchemaProcedure").next();
}
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class ProcedureIT method shouldNotAllowSchemaWriteProcedureInWriteTransaction.
@Test
public void shouldNotAllowSchemaWriteProcedureInWriteTransaction() throws Throwable {
// Expect
exception.expect(AuthorizationViolationException.class);
exception.expectMessage("Schema operations are not allowed");
GraphDatabaseAPI gdapi = (GraphDatabaseAPI) db;
// When
try (Transaction tx = gdapi.beginTransaction(KernelTransaction.Type.explicit, AnonymousContext.write())) {
db.execute("CALL org.neo4j.procedure.schemaProcedure()");
tx.success();
}
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI 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.kernel.internal.GraphDatabaseAPI 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;
}
Aggregations