Search in sources :

Example 16 with TestGraphDatabaseFactory

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

the class IndexingServiceIntegrationTest method setUp.

@Before
public void setUp() {
    EphemeralFileSystemAbstraction fileSystem = fileSystemRule.get();
    database = new TestGraphDatabaseFactory().setFileSystem(fileSystem).addKernelExtension(new LuceneSchemaIndexProviderFactory()).newImpermanentDatabase();
    createData(database, 100);
}
Also used : EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) LuceneSchemaIndexProviderFactory(org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProviderFactory) Before(org.junit.Before)

Example 17 with TestGraphDatabaseFactory

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

the class TestMigrateToDenseNodeSupport method migrateDbWithDenseNodes.

@Test
public void migrateDbWithDenseNodes() throws Exception {
    // migrate
    new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(dir).setConfig(allow_store_upgrade, "true").newGraphDatabase().shutdown();
    // check consistency
    assertConsistentStore(dir);
    // open again to do extra checks
    GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(dir).newGraphDatabase();
    try (Transaction tx = db.beginTx()) {
        ResourceIterator<Node> allNodesWithLabel = db.findNodes(referenceNode);
        Node refNode = Iterators.single(allNodesWithLabel);
        int sparseCount = 0;
        for (Relationship relationship : refNode.getRelationships(Types.SPARSE, OUTGOING)) {
            verifySparseNode(db, relationship.getEndNode());
            sparseCount++;
        }
        int denseCount = 0;
        for (Relationship relationship : refNode.getRelationships(Types.DENSE, OUTGOING)) {
            verifyDenseNode(db, relationship.getEndNode());
            denseCount++;
        }
        assertEquals(10, sparseCount);
        assertEquals(10, denseCount);
        tx.success();
    }
    db.shutdown();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Test(org.junit.Test)

Example 18 with TestGraphDatabaseFactory

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

the class TestConfiguration method testEnableDefaultsInConfig.

@Test
public void testEnableDefaultsInConfig() throws Exception {
    GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(SOURCE_DIR).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.TRUE).newGraphDatabase();
    OnlineBackup.from(HOST_ADDRESS).full(BACKUP_DIR);
    db.shutdown();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Test(org.junit.Test)

Example 19 with TestGraphDatabaseFactory

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

the class InProcessBuilderTest method shouldRunBuilderOnExistingStoreDir.

@Test
public void shouldRunBuilderOnExistingStoreDir() throws Exception {
    // When
    // create graph db with one node upfront
    Path dir = Files.createTempDirectory(getClass().getSimpleName() + "_shouldRunBuilderOnExistingStorageDir");
    File storeDir = Config.embeddedDefaults(stringMap(DatabaseManagementSystemSettings.data_directory.name(), dir.toString())).get(DatabaseManagementSystemSettings.database_path);
    try {
        GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir);
        try {
            db.execute("create ()");
        } finally {
            db.shutdown();
        }
        try (ServerControls server = getTestServerBuilder(testDir.directory()).copyFrom(dir.toFile()).newServer()) {
            // Then
            try (Transaction tx = server.graph().beginTx()) {
                ResourceIterable<Node> allNodes = Iterables.asResourceIterable(server.graph().getAllNodes());
                assertTrue(Iterables.count(allNodes) > 0);
                // When: create another node
                server.graph().createNode();
                tx.success();
            }
        }
        // Then: we still only have one node since the server is supposed to work on a copy
        db = new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir);
        try {
            try (Transaction tx = db.beginTx()) {
                assertEquals(1, Iterables.count(db.getAllNodes()));
                tx.success();
            }
        } finally {
            db.shutdown();
        }
    } finally {
        FileUtils.forceDelete(dir.toFile());
    }
}
Also used : Path(java.nio.file.Path) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) JsonNode(org.codehaus.jackson.JsonNode) Node(org.neo4j.graphdb.Node) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) Test(org.junit.Test)

Example 20 with TestGraphDatabaseFactory

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

the class PropertySettingStrategyTest method createDb.

@BeforeClass
public static void createDb() {
    db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase();
    propSetter = new PropertySettingStrategy(db);
}
Also used : TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) BeforeClass(org.junit.BeforeClass)

Aggregations

TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)156 Test (org.junit.Test)70 Transaction (org.neo4j.graphdb.Transaction)62 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)61 File (java.io.File)34 Node (org.neo4j.graphdb.Node)28 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)26 BeforeClass (org.junit.BeforeClass)25 Before (org.junit.Before)22 EphemeralFileSystemAbstraction (org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction)9 Relationship (org.neo4j.graphdb.Relationship)8 Result (org.neo4j.graphdb.Result)6 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