Search in sources :

Example 1 with TestGraphDatabaseFactory

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

the class CountsComputerTest method setup.

@Before
public void setup() {
    fs = fsRule.get();
    dir = testDir.directory("dir").getAbsoluteFile();
    dbBuilder = new TestGraphDatabaseFactory().setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs)).newImpermanentDatabaseBuilder(dir);
    pageCache = pcRule.getPageCache(fs);
}
Also used : TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) UncloseableDelegatingFileSystemAbstraction(org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction) Before(org.junit.Before)

Example 2 with TestGraphDatabaseFactory

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

the class CountsRotationTest method setup.

@Before
public void setup() {
    fs = fsRule.get();
    dir = testDir.directory("dir").getAbsoluteFile();
    dbBuilder = new TestGraphDatabaseFactory().setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs)).newImpermanentDatabaseBuilder(dir);
    pageCache = pcRule.getPageCache(fs);
}
Also used : TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) UncloseableDelegatingFileSystemAbstraction(org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction) Before(org.junit.Before)

Example 3 with TestGraphDatabaseFactory

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

the class TestGraphProperties method produceUncleanStore.

private EphemeralFileSystemAbstraction produceUncleanStore(EphemeralFileSystemAbstraction fileSystem, File storeDir) {
    GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem(fileSystem).newImpermanentDatabase(storeDir);
    Transaction tx = db.beginTx();
    Node node = db.createNode();
    node.setProperty("name", "Something");
    properties((GraphDatabaseAPI) db).setProperty("prop", "Some value");
    tx.success();
    tx.close();
    EphemeralFileSystemAbstraction snapshot = fileSystem.snapshot();
    db.shutdown();
    return snapshot;
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) Node(org.neo4j.graphdb.Node) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory)

Example 4 with TestGraphDatabaseFactory

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

the class TestGraphProperties method twoUncleanInARow.

@Test
public void twoUncleanInARow() throws Exception {
    File storeDir = new File("dir");
    try (EphemeralFileSystemAbstraction snapshot = produceUncleanStore(fs.get(), storeDir)) {
        try (EphemeralFileSystemAbstraction snapshot2 = produceUncleanStore(snapshot, storeDir)) {
            GraphDatabaseAPI db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().setFileSystem(produceUncleanStore(snapshot2, storeDir)).newImpermanentDatabase(storeDir);
            assertThat(properties(db), inTx(db, hasProperty("prop").withValue("Some value")));
            db.shutdown();
        }
    }
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) Test(org.junit.Test)

Example 5 with TestGraphDatabaseFactory

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

the class RelationshipChainExplorerTest method createStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes.

private StoreAccess createStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes(int nDegreeTwoNodes) {
    File storeDirectory = storeLocation.graphDbDir();
    GraphDatabaseService database = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDirectory).setConfig(GraphDatabaseSettings.record_format, getRecordFormatName()).newGraphDatabase();
    try (Transaction transaction = database.beginTx()) {
        Node denseNode = database.createNode();
        for (int i = 0; i < nDegreeTwoNodes; i++) {
            Node degreeTwoNode = database.createNode();
            Node leafNode = database.createNode();
            if (i % 2 == 0) {
                denseNode.createRelationshipTo(degreeTwoNode, TestRelationshipType.CONNECTED);
            } else {
                degreeTwoNode.createRelationshipTo(denseNode, TestRelationshipType.CONNECTED);
            }
            degreeTwoNode.createRelationshipTo(leafNode, TestRelationshipType.CONNECTED);
        }
        transaction.success();
    }
    database.shutdown();
    PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
    StoreAccess storeAccess = new StoreAccess(fileSystemRule.get(), pageCache, storeDirectory, Config.empty());
    return storeAccess.initialize();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) Node(org.neo4j.graphdb.Node) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache)

Aggregations

TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)161 Test (org.junit.Test)72 Transaction (org.neo4j.graphdb.Transaction)65 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)62 File (java.io.File)34 Node (org.neo4j.graphdb.Node)30 BeforeClass (org.junit.BeforeClass)26 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)26 Before (org.junit.Before)24 EphemeralFileSystemAbstraction (org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction)9 Relationship (org.neo4j.graphdb.Relationship)8 Result (org.neo4j.graphdb.Result)7 GraphDatabaseBuilder (org.neo4j.graphdb.factory.GraphDatabaseBuilder)6 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)6 GraphDatabaseShellServer (org.neo4j.shell.kernel.GraphDatabaseShellServer)6 HashMap (java.util.HashMap)5 DependencyResolver (org.neo4j.graphdb.DependencyResolver)5 PageCache (org.neo4j.io.pagecache.PageCache)5 WrappedDatabase (org.neo4j.server.database.WrappedDatabase)5 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)4