Search in sources :

Example 86 with TestDatabaseManagementServiceBuilder

use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.

the class TestReadOnlyNeo4j method createSomeData.

private DbRepresentation createSomeData() {
    RelationshipType type = withName("KNOWS");
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs)).impermanent().build();
    GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
    try (Transaction tx = db.beginTx()) {
        Node prevNode = tx.createNode();
        for (int i = 0; i < 100; i++) {
            Node node = tx.createNode();
            Relationship rel = prevNode.createRelationshipTo(node, type);
            node.setProperty("someKey" + i % 10, i % 15);
            rel.setProperty("since", System.currentTimeMillis());
        }
        tx.commit();
    }
    DbRepresentation result = DbRepresentation.of(db);
    managementService.shutdown();
    return result;
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) RelationshipType(org.neo4j.graphdb.RelationshipType) UncloseableDelegatingFileSystemAbstraction(org.neo4j.io.fs.UncloseableDelegatingFileSystemAbstraction) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) DbRepresentation(org.neo4j.test.DbRepresentation)

Example 87 with TestDatabaseManagementServiceBuilder

use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.

the class ShutdownSequenceIT method getTestGraphDatabaseFactory.

private TestDatabaseManagementServiceBuilder getTestGraphDatabaseFactory() {
    TestDatabaseManagementServiceBuilder factory = new TestDatabaseManagementServiceBuilder();
    factory.setInternalLogProvider(internalLogProvider);
    factory.setUserLogProvider(userLogProvider);
    return factory;
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder)

Example 88 with TestDatabaseManagementServiceBuilder

use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.

the class BatchInserterImplTest method shouldCorrectlyMarkHighIds.

@Test
void shouldCorrectlyMarkHighIds() throws Exception {
    // given
    DatabaseLayout layout = databaseLayout;
    long[] nodeIds = new long[10];
    try (var inserter = BatchInserters.inserter(layout, fileSystem, config)) {
        Map<String, Object> properties = new HashMap<>();
        properties.put("name", "Just some name");
        properties.put("some_array", new String[] { "this", "is", "a", "string", "which", "really", "is", "an", "array" });
        for (int i = 0; i < nodeIds.length; i++) {
            nodeIds[i] = inserter.createNode(properties);
        }
    }
    MutableLongSet nodeIdsSet = LongSets.mutable.of(nodeIds);
    // when/then
    DatabaseManagementService dbms = new TestDatabaseManagementServiceBuilder(layout.getNeo4jLayout().homeDirectory()).setFileSystem(fileSystem).build();
    try {
        GraphDatabaseService db = dbms.database(DEFAULT_DATABASE_NAME);
        for (long nodeId : nodeIds) {
            try (Transaction tx = db.beginTx()) {
                tx.getNodeById(nodeId).addLabel(TestLabels.LABEL_ONE);
                tx.commit();
            }
        }
        for (int i = 0; i < 5; i++) {
            try (Transaction tx = db.beginTx()) {
                Node node = tx.createNode();
                assertFalse(nodeIdsSet.contains(node.getId()));
                tx.commit();
            }
        }
        for (long nodeId : nodeIds) {
            try (Transaction tx = db.beginTx()) {
                tx.getNodeById(nodeId).delete();
                tx.commit();
            }
        }
    } finally {
        dbms.shutdown();
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) HashMap(java.util.HashMap) Node(org.neo4j.graphdb.Node) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Transaction(org.neo4j.graphdb.Transaction) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test)

Example 89 with TestDatabaseManagementServiceBuilder

use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.

the class BoltChannelAutoReadLimiterIT method getTestGraphDatabaseFactory.

protected TestDatabaseManagementServiceBuilder getTestGraphDatabaseFactory() {
    TestDatabaseManagementServiceBuilder factory = new TestDatabaseManagementServiceBuilder();
    logProvider = new AssertableLogProvider();
    factory.setInternalLogProvider(logProvider);
    return factory;
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider)

Example 90 with TestDatabaseManagementServiceBuilder

use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.

the class IndexProviderApprovalTest method init.

@BeforeAll
public static void init() {
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder().impermanent().build();
    GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
    for (TestValue value : TestValue.values()) {
        createNode(db, PROPERTY_KEY, value.value);
    }
    noIndexRun = runFindByLabelAndProperty(db);
    createIndex(db, label(LABEL), PROPERTY_KEY);
    indexRun = runFindByLabelAndProperty(db);
    managementService.shutdown();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)135 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)74 Test (org.junit.jupiter.api.Test)48 Transaction (org.neo4j.graphdb.Transaction)42 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)38 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)30 Path (java.nio.file.Path)23 BeforeEach (org.junit.jupiter.api.BeforeEach)18 Node (org.neo4j.graphdb.Node)18 EphemeralFileSystemAbstraction (org.neo4j.io.fs.EphemeralFileSystemAbstraction)13 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)11 PageCache (org.neo4j.io.pagecache.PageCache)10 UncloseableDelegatingFileSystemAbstraction (org.neo4j.io.fs.UncloseableDelegatingFileSystemAbstraction)9 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)8 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)7 TokenIndexProviderFactory (org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Dependencies (org.neo4j.collection.Dependencies)6 Config (org.neo4j.configuration.Config)6 DatabaseManagementServiceBuilder (org.neo4j.dbms.api.DatabaseManagementServiceBuilder)6