Search in sources :

Example 1 with Procedures

use of org.neo4j.kernel.impl.proc.Procedures 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)

Example 2 with Procedures

use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.

the class GraphDatabaseServiceExecuteTest method shouldBeAbleToUseResultsOfPointGeometryProcedureAsInputToDistanceFunction.

@Test
public void shouldBeAbleToUseResultsOfPointGeometryProcedureAsInputToDistanceFunction() throws Exception {
    // given procedure that produces a point
    GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
    Procedures procedures = ((GraphDatabaseAPI) graphDb).getDependencyResolver().resolveDependency(Procedures.class);
    procedures.registerProcedure(PointProcs.class);
    // when calling procedure that produces a point
    Result result = graphDb.execute("CALL spatial.pointGeometry(144.317718, -37.031738) YIELD geometry " + "RETURN distance(point({longitude: 144.317718, latitude: -37.031738}), geometry) AS dist");
    // then
    Double dist = (Double) result.next().get("dist");
    assertThat(dist, equalTo(0.0));
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Procedures(org.neo4j.kernel.impl.proc.Procedures) Result(org.neo4j.graphdb.Result) Test(org.junit.Test)

Example 3 with Procedures

use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.

the class EditionModule method setupSecurityModule.

protected static void setupSecurityModule(PlatformModule platformModule, Log log, Procedures procedures, String key) {
    for (SecurityModule candidate : Service.load(SecurityModule.class)) {
        if (candidate.matches(key)) {
            try {
                candidate.setup(new SecurityModule.Dependencies() {

                    @Override
                    public LogService logService() {
                        return platformModule.logging;
                    }

                    @Override
                    public Config config() {
                        return platformModule.config;
                    }

                    @Override
                    public Procedures procedures() {
                        return procedures;
                    }

                    @Override
                    public JobScheduler scheduler() {
                        return platformModule.jobScheduler;
                    }

                    @Override
                    public FileSystemAbstraction fileSystem() {
                        return platformModule.fileSystem;
                    }

                    @Override
                    public LifeSupport lifeSupport() {
                        return platformModule.life;
                    }

                    @Override
                    public DependencySatisfier dependencySatisfier() {
                        return platformModule.dependencies;
                    }
                });
                return;
            } catch (Exception e) {
                String errorMessage = "Failed to load security module.";
                log.error(errorMessage);
                throw new RuntimeException(errorMessage, e);
            }
        }
    }
    String errorMessage = "Failed to load security module with key '" + key + "'.";
    log.error(errorMessage);
    throw new IllegalArgumentException(errorMessage);
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) Procedures(org.neo4j.kernel.impl.proc.Procedures) KernelException(org.neo4j.kernel.api.exceptions.KernelException) SecurityModule(org.neo4j.kernel.api.security.SecurityModule) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DependencySatisfier(org.neo4j.kernel.impl.util.DependencySatisfier) LogService(org.neo4j.kernel.impl.logging.LogService)

Example 4 with Procedures

use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.

the class KernelStatementTest method assertStatementIsNotOpenWhileAcquireIsNotInvoked.

@Test(expected = NotInTransactionException.class)
public void assertStatementIsNotOpenWhileAcquireIsNotInvoked() {
    KernelTransactionImplementation transaction = mock(KernelTransactionImplementation.class);
    TxStateHolder txStateHolder = mock(TxStateHolder.class);
    StorageStatement storeStatement = mock(StorageStatement.class);
    AccessCapability accessCapability = mock(AccessCapability.class);
    Procedures procedures = mock(Procedures.class);
    KernelStatement statement = new KernelStatement(transaction, txStateHolder, storeStatement, procedures, accessCapability, LockTracer.NONE);
    statement.assertOpen();
}
Also used : TxStateHolder(org.neo4j.kernel.api.txstate.TxStateHolder) AccessCapability(org.neo4j.kernel.impl.factory.AccessCapability) StorageStatement(org.neo4j.storageengine.api.StorageStatement) Procedures(org.neo4j.kernel.impl.proc.Procedures) Test(org.junit.Test)

Example 5 with Procedures

use of org.neo4j.kernel.impl.proc.Procedures 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();
}
Also used : CanWrite(org.neo4j.kernel.impl.factory.CanWrite) StorageStatement(org.neo4j.storageengine.api.StorageStatement) Procedures(org.neo4j.kernel.impl.proc.Procedures) Test(org.junit.Test)

Aggregations

Procedures (org.neo4j.kernel.impl.proc.Procedures)16 Test (org.junit.Test)9 QualifiedName (org.neo4j.kernel.api.proc.QualifiedName)5 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)3 ProcedureSignature (org.neo4j.kernel.api.proc.ProcedureSignature)3 Config (org.neo4j.kernel.configuration.Config)3 CanWrite (org.neo4j.kernel.impl.factory.CanWrite)3 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 Result (org.neo4j.graphdb.Result)2 KernelException (org.neo4j.kernel.api.exceptions.KernelException)2 UserFunctionSignature (org.neo4j.kernel.api.proc.UserFunctionSignature)2 SchemaWriteGuard (org.neo4j.kernel.impl.api.SchemaWriteGuard)2 JobScheduler (org.neo4j.kernel.impl.util.JobScheduler)2 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)2 LogProvider (org.neo4j.logging.LogProvider)2 StorageStatement (org.neo4j.storageengine.api.StorageStatement)2 File (java.io.File)1 Supplier (java.util.function.Supplier)1 Before (org.junit.Before)1 Pool (org.neo4j.collection.pool.Pool)1