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));
}
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();
}
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();
}
}
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();
}
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();
}
Aggregations