Search in sources :

Example 71 with TestGraphDatabaseFactory

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

the class TestConcurrentRelationshipChainLoadingIssue method tryToTriggerRelationshipLoadingStoppingMidWay.

private void tryToTriggerRelationshipLoadingStoppingMidWay(int denseNodeThreshold) throws Throwable {
    GraphDatabaseAPI db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().setConfig(dense_node_threshold, "" + denseNodeThreshold).newGraphDatabase();
    Node node = createNodeWithRelationships(db);
    checkStateToHelpDiagnoseFlakeyTest(db, node);
    long end = currentTimeMillis() + SECONDS.toMillis(5);
    int iterations = 0;
    while (currentTimeMillis() < end && iterations < 100) {
        tryOnce(db, node);
        iterations++;
    }
    db.shutdown();
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Node(org.neo4j.graphdb.Node) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory)

Example 72 with TestGraphDatabaseFactory

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

the class TestExceptionTypeOnInvalidIds method createDatabase.

@BeforeClass
public static void createDatabase() {
    graphdb = new TestGraphDatabaseFactory().newEmbeddedDatabase(getRandomStoreDir());
    File storeDir = getRandomStoreDir();
    new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir).shutdown();
    graphDbReadOnly = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir).setConfig(GraphDatabaseSettings.read_only, TRUE).newGraphDatabase();
}
Also used : TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 73 with TestGraphDatabaseFactory

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

the class TestLogPruning method newDb.

private GraphDatabaseAPI newDb(String logPruning, int rotateEveryNTransactions) {
    this.rotateEveryNTransactions = rotateEveryNTransactions;
    fs = new EphemeralFileSystemAbstraction();
    TestGraphDatabaseFactory gdf = new TestGraphDatabaseFactory();
    gdf.setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs));
    GraphDatabaseBuilder builder = gdf.newImpermanentDatabaseBuilder();
    builder.setConfig(keep_logical_logs, logPruning);
    this.db = (GraphDatabaseAPI) builder.newGraphDatabase();
    files = new PhysicalLogFiles(new File(db.getStoreDir()), PhysicalLogFile.DEFAULT_NAME, fs);
    return db;
}
Also used : EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) UncloseableDelegatingFileSystemAbstraction(org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction) File(java.io.File) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) GraphDatabaseBuilder(org.neo4j.graphdb.factory.GraphDatabaseBuilder) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)

Example 74 with TestGraphDatabaseFactory

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

the class RestoreClusterUtils method createClassicNeo4jStore.

public static File createClassicNeo4jStore(File base, FileSystemAbstraction fileSystem, int nodesToCreate, String recordFormat) {
    File existingDbDir = new File(base, "existing");
    GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem(fileSystem).newEmbeddedDatabaseBuilder(existingDbDir).setConfig(GraphDatabaseSettings.record_format, recordFormat).newGraphDatabase();
    for (int i = 0; i < (nodesToCreate / 2); i++) {
        try (Transaction tx = db.beginTx()) {
            Node node1 = db.createNode(Label.label("Label-" + i));
            Node node2 = db.createNode(Label.label("Label-" + i));
            node1.createRelationshipTo(node2, RelationshipType.withName("REL-" + i));
            tx.success();
        }
    }
    db.shutdown();
    return existingDbDir;
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File)

Example 75 with TestGraphDatabaseFactory

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

the class UserFunctionIT method shouldLogLikeThereIsNoTomorrow.

@Test
public void shouldLogLikeThereIsNoTomorrow() throws Throwable {
    // Given
    AssertableLogProvider logProvider = new AssertableLogProvider();
    db.shutdown();
    db = new TestGraphDatabaseFactory().setInternalLogProvider(logProvider).setUserLogProvider(logProvider).newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.plugin_dir, plugins.getRoot().getAbsolutePath()).newGraphDatabase();
    // When
    try (Transaction ignore = db.beginTx()) {
        Result res = db.execute("RETURN org.neo4j.procedure.logAround()");
        while (res.hasNext()) {
            res.next();
        }
    }
    // Then
    AssertableLogProvider.LogMatcherBuilder match = inLog(Procedures.class);
    logProvider.assertAtLeastOnce(match.debug("1"), match.info("2"), match.warn("3"), match.error("4"));
}
Also used : Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Result(org.neo4j.graphdb.Result) Test(org.junit.Test)

Aggregations

TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)154 Test (org.junit.Test)83 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)77 Transaction (org.neo4j.graphdb.Transaction)56 File (java.io.File)40 Node (org.neo4j.graphdb.Node)32 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)25 Before (org.junit.Before)23 Result (org.neo4j.graphdb.Result)13 EphemeralFileSystemAbstraction (org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction)11 Relationship (org.neo4j.graphdb.Relationship)9 GraphDatabaseBuilder (org.neo4j.graphdb.factory.GraphDatabaseBuilder)9 UncloseableDelegatingFileSystemAbstraction (org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction)9 BeforeClass (org.junit.BeforeClass)8 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)8 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)8 HashMap (java.util.HashMap)7 Point (org.neo4j.graphdb.spatial.Point)7 DependencyResolver (org.neo4j.graphdb.DependencyResolver)6 PageCache (org.neo4j.io.pagecache.PageCache)6