Search in sources :

Example 61 with TestGraphDatabaseFactory

use of org.neo4j.test.TestGraphDatabaseFactory 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 62 with TestGraphDatabaseFactory

use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.

the class CypherLoggingTest method shouldNotLogQueries.

@Test
public void shouldNotLogQueries() throws Exception {
    // given
    AssertableLogProvider logProvider = new AssertableLogProvider();
    GraphDatabaseService database = new TestGraphDatabaseFactory().setUserLogProvider(logProvider).newImpermanentDatabase();
    // when
    database.execute("CREATE (n:Reference) CREATE (foo {test:'me'}) RETURN n");
    database.execute("MATCH (n) RETURN n");
    // then
    inLog(org.neo4j.cypher.internal.ExecutionEngine.class);
    logProvider.assertNoLoggingOccurred();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.Test)

Example 63 with TestGraphDatabaseFactory

use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.

the class IndexPopulationJobTest method before.

@Before
public void before() throws Exception {
    db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase();
    kernel = db.getDependencyResolver().resolveDependency(KernelAPI.class);
    stateHolder = new KernelSchemaStateStore(NullLogProvider.getInstance());
    indexStoreView = indexStoreView();
    try (KernelTransaction tx = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
        Statement statement = tx.acquireStatement()) {
        labelId = statement.tokenWriteOperations().labelGetOrCreateForName(FIRST.name());
        statement.tokenWriteOperations().labelGetOrCreateForName(SECOND.name());
        tx.success();
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Statement(org.neo4j.kernel.api.Statement) KernelSchemaStateStore(org.neo4j.kernel.impl.api.KernelSchemaStateStore) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) KernelAPI(org.neo4j.kernel.api.KernelAPI) Before(org.junit.Before)

Example 64 with TestGraphDatabaseFactory

use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.

the class IndexRecoveryIT method startDb.

@SuppressWarnings("deprecation")
private void startDb() {
    if (db != null) {
        db.shutdown();
    }
    TestGraphDatabaseFactory factory = new TestGraphDatabaseFactory();
    factory.setFileSystem(fs.get());
    factory.addKernelExtensions(Arrays.<KernelExtensionFactory<?>>asList(mockedIndexProviderFactory));
    db = (GraphDatabaseAPI) factory.newImpermanentDatabase();
}
Also used : TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory)

Example 65 with TestGraphDatabaseFactory

use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.

the class FirstStartupIT method shouldBeEmptyWhenFirstStarted.

@Test
public void shouldBeEmptyWhenFirstStarted() throws Exception {
    // When
    File storeDir = testDir.absolutePath();
    GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir);
    // Then
    try (Transaction ignore = db.beginTx()) {
        assertEquals(0, count(db.getAllNodes()));
        assertEquals(0, count(db.getAllRelationships()));
        assertEquals(0, count(db.getAllRelationshipTypes()));
        assertEquals(0, count(db.getAllLabels()));
        assertEquals(0, count(db.getAllPropertyKeys()));
    }
    db.shutdown();
}
Also used : TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) Test(org.junit.Test)

Aggregations

TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)154 Test (org.junit.Test)83 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)77 Transaction (org.neo4j.graphdb.Transaction)56 File (java.io.File)40 Node (org.neo4j.graphdb.Node)32 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)25 Before (org.junit.Before)23 Result (org.neo4j.graphdb.Result)13 EphemeralFileSystemAbstraction (org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction)11 Relationship (org.neo4j.graphdb.Relationship)9 GraphDatabaseBuilder (org.neo4j.graphdb.factory.GraphDatabaseBuilder)9 UncloseableDelegatingFileSystemAbstraction (org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction)9 BeforeClass (org.junit.BeforeClass)8 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)8 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)8 HashMap (java.util.HashMap)7 Point (org.neo4j.graphdb.spatial.Point)7 DependencyResolver (org.neo4j.graphdb.DependencyResolver)6 PageCache (org.neo4j.io.pagecache.PageCache)6