use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class DatabaseManagementServiceBuilderIT method startSystemAndDefaultDatabase.
@Test
void startSystemAndDefaultDatabase() {
DatabaseManagementService managementService = getDbmsBuilderWithLimitedTxLogSize(testDirectory.homePath()).build();
GraphDatabaseAPI database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
try {
DependencyResolver dependencyResolver = database.getDependencyResolver();
DatabaseManager<?> databaseManager = dependencyResolver.resolveDependency(DatabaseManager.class);
assertThat(databaseManager.getDatabaseContext(DEFAULT_DATABASE_NAME)).isNotEmpty();
assertThat(databaseManager.getDatabaseContext(NAMED_SYSTEM_DATABASE_ID)).isNotEmpty();
} finally {
managementService.shutdown();
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class ConsistencyCheckWithCorruptGBPTreeIT method dbmsAction.
/**
* Open dbms with schemaIndex as default index provider on provided file system abstraction and apply dbSetup to DEFAULT_DATABASE.
*/
private void dbmsAction(Path neo4jHome, FileSystemAbstraction fs, GraphDatabaseSettings.SchemaIndex schemaIndex, Consumer<GraphDatabaseService> dbSetup, Consumer<DatabaseManagementServiceBuilder> dbConfiguration) {
TestDatabaseManagementServiceBuilder builder = new TestDatabaseManagementServiceBuilder(neo4jHome).setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs));
dbConfiguration.accept(builder);
final DatabaseManagementService dbms = builder.setConfig(GraphDatabaseSettings.default_schema_provider, schemaIndex.providerName()).build();
try {
final GraphDatabaseService db = dbms.database(DEFAULT_DATABASE_NAME);
dbSetup.accept(db);
} finally {
dbms.shutdown();
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class FirstStartupIT method shouldBeEmptyWhenFirstStarted.
@Test
void shouldBeEmptyWhenFirstStarted() {
// When
var storeDir = testDir.absolutePath();
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDir).build();
GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
// Then
try (Transaction transaction = db.beginTx()) {
assertEquals(0, count(transaction.getAllNodes()));
assertEquals(0, count(transaction.getAllRelationships()));
assertEquals(0, count(transaction.getAllRelationshipTypes()));
assertEquals(0, count(transaction.getAllLabels()));
assertEquals(0, count(transaction.getAllPropertyKeys()));
} finally {
managementService.shutdown();
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class RecordFormatMigrationIT method failToDowngradeFormatWhenUpgradeNotAllowed.
@Test
void failToDowngradeFormatWhenUpgradeNotAllowed() {
DatabaseManagementService managementService = startManagementService(StandardV4_3.NAME);
GraphDatabaseAPI database = getDefaultDatabase(managementService);
try (Transaction transaction = database.beginTx()) {
Node node = transaction.createNode();
node.setProperty("a", "b");
transaction.commit();
}
managementService.shutdown();
managementService = startManagementService(StandardV4_0.NAME);
database = getDefaultDatabase(managementService);
try {
Throwable throwable = assertDefaultDatabaseFailed(database);
assertSame(UpgradeNotAllowedException.class, getRootCause(throwable).getClass());
} finally {
managementService.shutdown();
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class RecordFormatMigrationIT method latestRecordNotMigratedWhenFormatBumped.
@Test
void latestRecordNotMigratedWhenFormatBumped() {
DatabaseManagementService managementService = startManagementService(StandardV4_0.NAME);
GraphDatabaseAPI database = getDefaultDatabase(managementService);
try (Transaction transaction = database.beginTx()) {
Node node = transaction.createNode();
node.setProperty("a", "b");
transaction.commit();
}
managementService.shutdown();
managementService = startManagementService(Standard.LATEST_NAME);
database = getDefaultDatabase(managementService);
try {
Throwable exception = assertDefaultDatabaseFailed(database);
assertSame(UpgradeNotAllowedException.class, getRootCause(exception).getClass());
} finally {
managementService.shutdown();
}
}
Aggregations