Search in sources :

Example 1 with UncloseableDelegatingFileSystemAbstraction

use of org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction 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 2 with UncloseableDelegatingFileSystemAbstraction

use of org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction 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 3 with UncloseableDelegatingFileSystemAbstraction

use of org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction 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 4 with UncloseableDelegatingFileSystemAbstraction

use of org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction in project neo4j by neo4j.

the class TestReadOnlyNeo4j method testSimple.

@Test
public void testSimple() {
    DbRepresentation someData = createSomeData();
    GraphDatabaseService readGraphDb = new TestGraphDatabaseFactory().setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs.get())).newImpermanentDatabaseBuilder(PATH).setConfig(GraphDatabaseSettings.read_only, Settings.TRUE).newGraphDatabase();
    assertEquals(someData, DbRepresentation.of(readGraphDb));
    try (Transaction tx = readGraphDb.beginTx()) {
        readGraphDb.createNode();
        tx.success();
    } catch (WriteOperationsNotAllowedException e) {
    // good
    }
    readGraphDb.shutdown();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) UncloseableDelegatingFileSystemAbstraction(org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction) DbRepresentation(org.neo4j.test.DbRepresentation) WriteOperationsNotAllowedException(org.neo4j.graphdb.security.WriteOperationsNotAllowedException) Test(org.junit.Test)

Example 5 with UncloseableDelegatingFileSystemAbstraction

use of org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction in project neo4j by neo4j.

the class BatchingNeoStoresTest method someDataInTheDatabase.

private void someDataInTheDatabase() {
    GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fsr.get())).newImpermanentDatabase(storeDir);
    try (Transaction tx = db.beginTx()) {
        db.createNode().createRelationshipTo(db.createNode(), MyRelTypes.TEST);
        tx.success();
    } finally {
        db.shutdown();
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) UncloseableDelegatingFileSystemAbstraction(org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction)

Aggregations

UncloseableDelegatingFileSystemAbstraction (org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction)10 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)9 Before (org.junit.Before)5 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)3 Transaction (org.neo4j.graphdb.Transaction)3 File (java.io.File)2 DbRepresentation (org.neo4j.test.DbRepresentation)2 Test (org.junit.Test)1 Node (org.neo4j.graphdb.Node)1 Relationship (org.neo4j.graphdb.Relationship)1 RelationshipType (org.neo4j.graphdb.RelationshipType)1 GraphDatabaseBuilder (org.neo4j.graphdb.factory.GraphDatabaseBuilder)1 EphemeralFileSystemAbstraction (org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction)1 WriteOperationsNotAllowedException (org.neo4j.graphdb.security.WriteOperationsNotAllowedException)1 InMemoryIndexProviderFactory (org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProviderFactory)1 PhysicalLogFile (org.neo4j.kernel.impl.transaction.log.PhysicalLogFile)1 PhysicalLogFiles (org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)1 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)1 TestEnterpriseGraphDatabaseFactory (org.neo4j.test.TestEnterpriseGraphDatabaseFactory)1