use of org.neo4j.graphdb.factory.GraphDatabaseFactory in project neo4j by neo4j.
the class StoreMigrationIT method createDb.
private static void createDb(RecordFormats recordFormat, File storeDir) throws IOException {
GraphDatabaseService database = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir).setConfig(GraphDatabaseSettings.allow_store_upgrade, Settings.TRUE).setConfig(GraphDatabaseSettings.record_format, recordFormat.storeVersion()).newGraphDatabase();
database.shutdown();
}
use of org.neo4j.graphdb.factory.GraphDatabaseFactory in project neo4j by neo4j.
the class BoltFailuresIT method throwsWhenMonitoredWorkerCreationFails.
@Test(timeout = TEST_TIMEOUT)
public void throwsWhenMonitoredWorkerCreationFails() {
ThrowingSessionMonitor sessionMonitor = new ThrowingSessionMonitor();
sessionMonitor.throwInSessionStarted();
Monitors monitors = newMonitorsSpy(sessionMonitor);
db = startDbWithBolt(new GraphDatabaseFactory().setMonitors(monitors));
driver = createDriver();
try {
driver.session();
fail("Exception expected");
} catch (Exception e) {
assertThat(e, instanceOf(ConnectionFailureException.class));
}
}
use of org.neo4j.graphdb.factory.GraphDatabaseFactory in project neo4j by neo4j.
the class DbStructureTool method main.
public static void main(String[] args) throws IOException {
if (args.length != 2 && args.length != 3) {
System.err.println("arguments: <generated class name> [<output source root>] <database dir>");
System.exit(1);
}
boolean writeToFile = args.length == 3;
String generatedClassWithPackage = args[0];
String dbDir = writeToFile ? args[2] : args[1];
Pair<String, String> parsedGenerated = parseClassNameWithPackage(generatedClassWithPackage);
String generatedClassPackage = parsedGenerated.first();
String generatedClassName = parsedGenerated.other();
String generator = format("%s %s [<output source root>] <db-dir>", DbStructureTool.class.getCanonicalName(), generatedClassWithPackage);
GraphDatabaseService graph = new GraphDatabaseFactory().newEmbeddedDatabase(new File(dbDir));
try {
if (writeToFile) {
File sourceRoot = new File(args[1]);
String outputPackageDir = generatedClassPackage.replace('.', File.separatorChar);
String outputFileName = generatedClassName + ".java";
File outputDir = new File(sourceRoot, outputPackageDir);
File outputFile = new File(outputDir, outputFileName);
try (PrintWriter writer = new PrintWriter(outputFile)) {
traceDb(generator, generatedClassPackage, generatedClassName, graph, writer);
}
} else {
traceDb(generator, generatedClassPackage, generatedClassName, graph, System.out);
}
} finally {
graph.shutdown();
}
}
use of org.neo4j.graphdb.factory.GraphDatabaseFactory in project neo4j by neo4j.
the class DeferredIndexedConflictResolutionTest method setUp.
@Before
public void setUp() {
GraphDatabaseFactory factory = new TestGraphDatabaseFactory();
db = factory.newEmbeddedDatabase(storePath.absolutePath());
GraphDatabaseAPI api = (GraphDatabaseAPI) db;
Label nodeLabel = Label.label("Label");
String propertyKey = "someProp";
long nodeId;
try (Transaction transaction = db.beginTx()) {
Node node = db.createNode(nodeLabel);
node.setProperty(propertyKey, "someVal");
nodeId = node.getId();
transaction.success();
}
DependencyResolver resolver = api.getDependencyResolver();
NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
nodeStore = neoStores.getNodeStore();
propertyStore = neoStores.getPropertyStore();
Map<String, Integer> propertyKeys = PropertyDeduplicatorTestUtil.indexPropertyKeys(neoStores.getPropertyKeyTokenStore());
nodeRecord = RecordStore.getRecord(nodeStore, nodeId);
int propertyKeyId = propertyKeys.get(propertyKey);
clusterToRemove = createDuplicateCluster(propertyKeyId, nodeRecord.getNextProp());
clusters = new ArrayList<>();
clusters.add(createDuplicateCluster(propertyKeyId + 1, nodeRecord.getNextProp()));
// This is the one we want to remove
clusters.add(clusterToRemove);
clusters.add(createDuplicateCluster(propertyKeyId + 2, nodeRecord.getNextProp()));
}
use of org.neo4j.graphdb.factory.GraphDatabaseFactory in project neo4j by neo4j.
the class TestLuceneSchemaBatchInsertIT method shouldLoadAndUseLuceneProvider.
@Test
public void shouldLoadAndUseLuceneProvider() throws Exception {
// GIVEN
File storeDir = testDirectory.graphDbDir();
BatchInserter inserter = BatchInserters.inserter(storeDir, fileSystemRule.get());
inserter.createDeferredSchemaIndex(LABEL).on("name").create();
// WHEN
inserter.createNode(map("name", "Mattias"), LABEL);
inserter.shutdown();
// THEN
GraphDatabaseFactory graphDatabaseFactory = new TestGraphDatabaseFactory();
GraphDatabaseAPI db = (GraphDatabaseAPI) graphDatabaseFactory.newEmbeddedDatabase(storeDir);
DependencyResolver dependencyResolver = db.getDependencyResolver();
SchemaIndexProvider schemaIndexProvider = dependencyResolver.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance());
// assert the indexProvider is a Lucene one
try (Transaction ignore = db.beginTx()) {
IndexDefinition indexDefinition = Iterables.single(db.schema().getIndexes(LABEL));
assertThat(db.schema().getIndexState(indexDefinition), is(Schema.IndexState.ONLINE));
assertThat(schemaIndexProvider, instanceOf(LuceneSchemaIndexProvider.class));
}
// CLEANUP
db.shutdown();
}
Aggregations