Search in sources :

Example 1 with DatabaseManagementServiceBuilder

use of org.neo4j.dbms.api.DatabaseManagementServiceBuilder in project neo4j by neo4j.

the class DefaultSchemaIndexConfigTest method indexShouldHaveIndexConfig.

@ParameterizedTest
@MethodSource("providers")
void indexShouldHaveIndexConfig(GraphDatabaseSettings.SchemaIndex provider) throws IndexNotFoundKernelException {
    DatabaseManagementServiceBuilder databaseManagementServiceBuilder = dbBuilder.setConfig(default_schema_provider, provider == null ? null : provider.providerName());
    DatabaseManagementService managementService = databaseManagementServiceBuilder.build();
    GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
    try {
        // when
        createIndex(db);
        // then
        validateIndexConfig(db);
    } finally {
        managementService.shutdown();
    }
    managementService = databaseManagementServiceBuilder.build();
    db = managementService.database(DEFAULT_DATABASE_NAME);
    try {
        validateIndexConfig(db);
    } finally {
        managementService.shutdown();
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with DatabaseManagementServiceBuilder

use of org.neo4j.dbms.api.DatabaseManagementServiceBuilder in project neo4j by neo4j.

the class IndexConfigMigrationIT method create3_5Database.

@Disabled("Here as reference for how 3.5 db was created")
@Test
void create3_5Database() throws Exception {
    Path storeDir = tempStoreDirectory();
    DatabaseManagementServiceBuilder builder = new TestDatabaseManagementServiceBuilder(storeDir);
    setSpatialConfig(builder);
    DatabaseManagementService dbms = builder.build();
    GraphDatabaseService db = dbms.database(DEFAULT_DATABASE_NAME);
    createIndex(db, NATIVE_BTREE10.providerName(), label1);
    // createIndex( db, NATIVE20.providerName(), label2 ); // <- Those index providers are removed in 4.0, but here for reference.
    // createIndex( db, NATIVE10.providerName(), label3 );
    // createIndex( db, LUCENE10.providerName(), label4 );
    createSpatialData(db, label1, label2, label3, label4);
    for (FulltextIndexDescription fulltextIndex : FulltextIndexDescription.values()) {
        createFulltextIndex(db, fulltextIndex.indexProcedure, fulltextIndex.indexName, fulltextIndex.tokenName, propKey, fulltextIndex.configMap);
    }
    dbms.shutdown();
    Path zipFile = storeDir.resolveSibling(storeDir.getFileName().toString() + ".zip");
    ZipUtils.zip(new DefaultFileSystemAbstraction(), storeDir, zipFile);
    System.out.println("Db created in " + zipFile.toAbsolutePath());
}
Also used : Path(java.nio.file.Path) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with DatabaseManagementServiceBuilder

use of org.neo4j.dbms.api.DatabaseManagementServiceBuilder in project neo4j by neo4j.

the class DatabaseStartupTest method startCommunityDatabaseOnProvidedNonAbsoluteFile.

@Test
void startCommunityDatabaseOnProvidedNonAbsoluteFile() {
    Path directory = Path.of("target/notAbsoluteDirectory");
    EphemeralCommunityManagementServiceFactory factory = new EphemeralCommunityManagementServiceFactory();
    DatabaseManagementServiceBuilder databaseFactory = new EphemeralDatabaseManagementServiceBuilder(directory, factory);
    DatabaseManagementService managementService = databaseFactory.build();
    managementService.database(DEFAULT_DATABASE_NAME);
    managementService.shutdown();
}
Also used : Path(java.nio.file.Path) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test)

Example 4 with DatabaseManagementServiceBuilder

use of org.neo4j.dbms.api.DatabaseManagementServiceBuilder in project neo4j by neo4j.

the class TestLogPruning method newDb.

private GraphDatabaseAPI newDb(String logPruning, int rotateEveryNTransactions) {
    this.rotateEveryNTransactions = rotateEveryNTransactions;
    fs = new EphemeralFileSystemAbstraction();
    TestDatabaseManagementServiceBuilder gdf = new TestDatabaseManagementServiceBuilder();
    gdf.setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs));
    DatabaseManagementServiceBuilder builder = gdf.impermanent();
    builder.setConfig(keep_logical_logs, logPruning);
    managementService = builder.build();
    this.db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
    files = db.getDependencyResolver().resolveDependency(LogFiles.class);
    return db;
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) EphemeralFileSystemAbstraction(org.neo4j.io.fs.EphemeralFileSystemAbstraction) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) UncloseableDelegatingFileSystemAbstraction(org.neo4j.io.fs.UncloseableDelegatingFileSystemAbstraction)

Example 5 with DatabaseManagementServiceBuilder

use of org.neo4j.dbms.api.DatabaseManagementServiceBuilder in project neo4j by neo4j.

the class AuthProceduresIT method setup.

@BeforeEach
void setup() throws InvalidAuthTokenException {
    fs = new EphemeralFileSystemAbstraction();
    DatabaseManagementServiceBuilder graphDatabaseFactory = new TestDatabaseManagementServiceBuilder().setFileSystem(fs).impermanent().setConfig(GraphDatabaseSettings.auth_enabled, true);
    managementService = graphDatabaseFactory.build();
    db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
    systemDb = (GraphDatabaseAPI) managementService.database(SYSTEM_DATABASE_NAME);
    authManager = db.getDependencyResolver().resolveDependency(BasicSystemGraphRealm.class);
    assertSuccess(login("neo4j", "neo4j"), "ALTER CURRENT USER SET PASSWORD FROM 'neo4j' TO 'temp'");
    assertSuccess(login("neo4j", "temp"), "ALTER CURRENT USER SET PASSWORD FROM 'temp' TO 'neo4j'");
    admin = login("neo4j", "neo4j");
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) EphemeralFileSystemAbstraction(org.neo4j.io.fs.EphemeralFileSystemAbstraction) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) BasicSystemGraphRealm(org.neo4j.server.security.systemgraph.BasicSystemGraphRealm) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

DatabaseManagementServiceBuilder (org.neo4j.dbms.api.DatabaseManagementServiceBuilder)30 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)19 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)13 Transaction (org.neo4j.graphdb.Transaction)11 Node (org.neo4j.graphdb.Node)10 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)10 Test (org.junit.jupiter.api.Test)9 Path (java.nio.file.Path)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStream (java.io.OutputStream)2 Test (org.junit.Test)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Disabled (org.junit.jupiter.api.Disabled)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 Relationship (org.neo4j.graphdb.Relationship)2 RelationshipType (org.neo4j.graphdb.RelationshipType)2 Result (org.neo4j.graphdb.Result)2 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)2 EphemeralFileSystemAbstraction (org.neo4j.io.fs.EphemeralFileSystemAbstraction)2