use of org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory in project neo4j by neo4j.
the class ForeignStoreIdIT method createAnotherStore.
private File createAnotherStore(File directory, int transactions) {
GraphDatabaseService db = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabase(directory);
createNodes(db, transactions, "node");
db.shutdown();
return directory;
}
use of org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory in project neo4j by neo4j.
the class MetricsKernelExtensionFactoryIT method mustBeAbleToStartWithNullTracer.
@Test
public void mustBeAbleToStartWithNullTracer() throws Exception {
// Start the database
File disabledTracerDb = clusterRule.directory("disabledTracerDb");
GraphDatabaseBuilder builder = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabaseBuilder(disabledTracerDb);
GraphDatabaseService nullTracerDatabase = builder.setConfig(MetricsSettings.neoEnabled, Settings.TRUE).setConfig(csvEnabled, Settings.TRUE).setConfig(csvPath, outputPath.getAbsolutePath()).setConfig(GraphDatabaseFacadeFactory.Configuration.tracer, // key point!
"null").newGraphDatabase();
try (Transaction tx = nullTracerDatabase.beginTx()) {
Node node = nullTracerDatabase.createNode();
node.setProperty("all", "is well");
tx.success();
} finally {
nullTracerDatabase.shutdown();
}
// We assert that no exception is thrown during startup or the operation of the database.
}
use of org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory in project neo4j by neo4j.
the class StartupConstraintSemanticsTest method shouldNotAllowOpeningADatabaseWithPECInCommunityEdition.
@Test
public void shouldNotAllowOpeningADatabaseWithPECInCommunityEdition() throws Exception {
// given
GraphDatabaseService graphDb = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabase(dir.graphDbDir());
try {
graphDb.execute("CREATE CONSTRAINT ON (n:Draconian) ASSERT exists(n.required)");
} finally {
graphDb.shutdown();
}
graphDb = null;
// when
try {
graphDb = new TestGraphDatabaseFactory().newEmbeddedDatabase(dir.graphDbDir());
fail("should have failed to start!");
}// then
catch (Exception e) {
Throwable error = Exceptions.rootCause(e);
assertThat(error, instanceOf(IllegalStateException.class));
assertEquals(StandardConstraintSemantics.ERROR_MESSAGE, error.getMessage());
} finally {
if (graphDb != null) {
graphDb.shutdown();
}
}
}
use of org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory in project neo4j by neo4j.
the class StoreMigratorFrom20IT method shouldMigrate.
@Test
public void shouldMigrate() throws IOException, ConsistencyCheckIncompleteException {
// WHEN
StoreMigrator storeMigrator = new StoreMigrator(fs, pageCache, getConfig(), NullLogService.getInstance(), schemaIndexProvider);
SchemaIndexMigrator indexMigrator = new SchemaIndexMigrator(fs, schemaIndexProvider, labelScanStoreProvider);
upgrader(indexMigrator, storeMigrator).migrateIfNeeded(find20FormatStoreDirectory(storeDir.directory()));
// THEN
assertEquals(2, monitor.progresses().size());
assertTrue(monitor.isStarted());
assertTrue(monitor.isFinished());
GraphDatabaseService database = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir.absolutePath()).newGraphDatabase();
try {
verifyDatabaseContents(database);
} finally {
// CLEANUP
database.shutdown();
}
LogProvider logProvider = NullLogProvider.getInstance();
StoreFactory storeFactory = new StoreFactory(storeDir.directory(), pageCache, fs, logProvider);
try (NeoStores neoStores = storeFactory.openAllNeoStores(true)) {
verifyNeoStore(neoStores);
}
assertConsistentStore(storeDir.directory());
}
use of org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory in project neo4j by neo4j.
the class BatchInsertEnterpriseTest method shouldInsertDifferentTypesOfThings.
@Test
public void shouldInsertDifferentTypesOfThings() throws Exception {
// GIVEN
BatchInserter inserter = BatchInserters.inserter(directory.directory(), fileSystemRule.get(), stringMap(GraphDatabaseSettings.log_queries.name(), "true", GraphDatabaseSettings.record_format.name(), recordFormat, GraphDatabaseSettings.log_queries_filename.name(), directory.file("query.log").getAbsolutePath()));
long node1Id, node2Id, relationshipId;
try {
// WHEN
node1Id = inserter.createNode(someProperties(1), Labels.values());
node2Id = node1Id + 10;
inserter.createNode(node2Id, someProperties(2), Labels.values());
relationshipId = inserter.createRelationship(node1Id, node2Id, MyRelTypes.TEST, someProperties(3));
inserter.createDeferredSchemaIndex(Labels.One).on("key").create();
inserter.createDeferredConstraint(Labels.Two).assertPropertyIsUnique("key").create();
} finally {
inserter.shutdown();
}
// THEN
GraphDatabaseService db = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabase(directory.directory());
try (Transaction tx = db.beginTx()) {
Node node1 = db.getNodeById(node1Id);
Node node2 = db.getNodeById(node2Id);
assertEquals(someProperties(1), node1.getAllProperties());
assertEquals(someProperties(2), node2.getAllProperties());
assertEquals(relationshipId, single(node1.getRelationships()).getId());
assertEquals(relationshipId, single(node2.getRelationships()).getId());
assertEquals(someProperties(3), single(node1.getRelationships()).getAllProperties());
tx.success();
} finally {
db.shutdown();
}
}
Aggregations