use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class NeoWebServerJAXRSIT method createSimpleDatabase.
private static int createSimpleDatabase(final GraphDatabaseAPI graph) {
final var numberOfNodes = 10;
new Transactor(graph, tx -> {
for (var i = 0; i < numberOfNodes; i++) {
tx.createNode();
}
for (var node1 : tx.getAllNodes()) {
for (var node2 : tx.getAllNodes()) {
if (node1.equals(node2)) {
continue;
}
node1.createRelationshipTo(node2, RelationshipType.withName("REL"));
}
}
}).execute();
return numberOfNodes;
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class UniqueIndexSeekIT method uniqueIndexSeekDoNotLeakIndexReaders.
@ParameterizedTest
@MethodSource("indexProviderFactories")
void uniqueIndexSeekDoNotLeakIndexReaders(AbstractIndexProviderFactory providerFactory) throws KernelException {
TrackingIndexExtensionFactory indexExtensionFactory = new TrackingIndexExtensionFactory(providerFactory);
GraphDatabaseAPI database = createDatabase(indexExtensionFactory, providerFactory.descriptor());
DependencyResolver dependencyResolver = database.getDependencyResolver();
Config config = dependencyResolver.resolveDependency(Config.class);
try {
Label label = label("spaceship");
String nameProperty = "name";
createUniqueConstraint(database, label, nameProperty);
generateRandomData(database, label, nameProperty);
assertNotNull(indexExtensionFactory.getIndexProvider(config.get(default_database)));
assertThat(numberOfClosedReaders()).isGreaterThan(0L);
assertThat(numberOfOpenReaders()).isGreaterThan(0L);
assertThat(numberOfClosedReaders()).isCloseTo(numberOfOpenReaders(), within(1L));
lockNodeUsingUniqueIndexSeek(database, nameProperty);
assertThat(numberOfClosedReaders()).isCloseTo(numberOfOpenReaders(), within(1L));
} finally {
managementService.shutdown();
}
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class DbmsSupportController method startDatabase.
public void startDatabase(String databaseName) {
if (!dbms.listDatabases().contains(databaseName)) {
dbms.createDatabase(databaseName);
}
var db = (GraphDatabaseAPI) dbms.database(databaseName);
var dependencyResolver = db.getDependencyResolver();
injectDependencies(dependencyResolver);
// Also inject DbmsController into the test.
Dependencies deps = new Dependencies();
deps.satisfyDependencies(asDbmsController());
injectDependencies(deps);
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class TestDatabaseManagementServiceBuilderTest method databaseStartsWithSystemAndDefaultDatabase.
@Test
void databaseStartsWithSystemAndDefaultDatabase() {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).build();
GraphDatabaseAPI database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
try {
checkAvailableDatabases(database);
} finally {
managementService.shutdown();
}
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class Neo4jWithSocket method ensureDatabase.
public void ensureDatabase(Consumer<Map<Setting<?>, Object>> overrideSettingsFunction) {
if (gdb != null) {
return;
}
Map<Setting<?>, Object> settings = configure(overrideSettingsFunction);
Path storeDir = workingDirectory.resolve("storeDir");
installSelfSignedCertificateIfEncryptionEnabled(settings);
graphDatabaseFactory.setFileSystem(fileSystemProvider.get());
managementService = graphDatabaseFactory.setDatabaseRootDirectory(storeDir).impermanent().setConfig(settings).build();
gdb = managementService.database(DEFAULT_DATABASE_NAME);
connectorRegister = ((GraphDatabaseAPI) gdb).getDependencyResolver().resolveDependency(ConnectorPortRegister.class);
}
Aggregations