use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class TestExtension method dependenciesCanBeRetrieved.
/**
* Check that dependencies can be accessed
*/
@Test
void dependenciesCanBeRetrieved() {
GraphDatabaseAPI graphdb = graphDb();
try {
GlobalExtensions globalExtensions = graphdb.getDependencyResolver().resolveDependency(GlobalExtensions.class);
assertNotNull(globalExtensions.resolveDependency(DummyExtension.class).getDependencies().getConfig());
assertEquals(graphdb.getDependencyResolver().resolveDependency(DatabaseManager.class), globalExtensions.resolveDependency(DummyExtension.class).getDependencies().getDatabaseManager());
} finally {
managementService.shutdown();
}
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class CountsStoreRecoveryTest method flushNeoStoreOnly.
private void flushNeoStoreOnly() {
NeoStores neoStores = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
MetaDataStore metaDataStore = neoStores.getMetaDataStore();
metaDataStore.flush(NULL);
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class RecoveryLogIT method transactionsRecoveryLogContainsTimeSpent.
@Test
void transactionsRecoveryLogContainsTimeSpent() throws IOException {
// Create database with forced recovery
Path tmpLogDir = testDirectory.directory("logs");
managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).build();
GraphDatabaseAPI db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
StorageEngineFactory storageEngineFactory = db.getDependencyResolver().resolveDependency(StorageEngineFactory.class);
try (Transaction tx = db.beginTx()) {
Node node1 = tx.createNode();
Node node2 = tx.createNode();
node1.createRelationshipTo(node2, RelationshipType.withName("likes"));
tx.commit();
}
Path[] txLogs = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseLayout.getTransactionLogsDirectory(), fileSystem).withCommandReaderFactory(storageEngineFactory.commandReaderFactory()).build().logFiles();
for (Path file : txLogs) {
fileSystem.copyToDirectory(file, tmpLogDir);
}
managementService.shutdown();
for (Path txLog : fileSystem.listFiles(databaseLayout.getTransactionLogsDirectory())) {
fileSystem.deleteFile(txLog);
}
for (Path file : LogFilesBuilder.logFilesBasedOnlyBuilder(tmpLogDir, fileSystem).withCommandReaderFactory(storageEngineFactory.commandReaderFactory()).build().logFiles()) {
fileSystem.moveToDirectory(file, databaseLayout.getTransactionLogsDirectory());
}
AssertableLogProvider provider = new AssertableLogProvider();
managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setInternalLogProvider(provider).build();
managementService.database(DEFAULT_DATABASE_NAME);
assertThat(provider).containsMessages("Recovery completed", "time spent");
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class JUnitRuleTestIT method contentOf.
private String contentOf(String file) throws IOException {
GraphDatabaseAPI api = (GraphDatabaseAPI) neo4j.defaultDatabaseService();
Config config = api.getDependencyResolver().resolveDependency(Config.class);
Path homeDir = config.get(GraphDatabaseSettings.neo4j_home);
return Files.readString(homeDir.resolve(file));
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class BaseBootstrapperIT method shouldHaveSameLayoutAsEmbedded.
@Test
public void shouldHaveSameLayoutAsEmbedded() throws Exception {
Path serverDir = testDirectory.directory("server-dir");
NeoBootstrapper.start(bootstrapper, withConnectorsOnRandomPortsConfig("--home-dir", serverDir.toAbsolutePath().toString()));
assertEventually("Server was not started", bootstrapper::isRunning, Conditions.TRUE, 1, TimeUnit.MINUTES);
var databaseAPI = (GraphDatabaseAPI) bootstrapper.getDatabaseManagementService().database(DEFAULT_DATABASE_NAME);
var serverLayout = databaseAPI.databaseLayout().getNeo4jLayout();
bootstrapper.stop();
Path embeddedDir = testDirectory.directory("embedded-dir");
DatabaseManagementService dbms = newEmbeddedDbms(embeddedDir);
Neo4jLayout embeddedLayout = ((GraphDatabaseAPI) dbms.database(DEFAULT_DATABASE_NAME)).databaseLayout().getNeo4jLayout();
dbms.shutdown();
assertEquals(serverDir.relativize(serverLayout.homeDirectory()), embeddedDir.relativize(embeddedLayout.homeDirectory()));
assertEquals(serverDir.relativize(serverLayout.databasesDirectory()), embeddedDir.relativize(embeddedLayout.databasesDirectory()));
assertEquals(serverDir.relativize(serverLayout.transactionLogsRootDirectory()), embeddedDir.relativize(embeddedLayout.transactionLogsRootDirectory()));
}
Aggregations