Search in sources :

Example 51 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestChangingOfLogFormat method inabilityToStartFromOldFormatFromNonCleanShutdown.

@Test
public void inabilityToStartFromOldFormatFromNonCleanShutdown() throws Exception {
    String storeDir = "target/var/oldlog";
    deleteFileOrDirectory(storeDir);
    GraphDatabaseService db = new EmbeddedGraphDatabase(storeDir);
    Transaction tx = db.beginTx();
    db.createNode();
    tx.success();
    tx.finish();
    Pair<Pair<File, File>, Pair<File, File>> copy = copyLogicalLog(storeDir);
    decrementLogFormat(copy.other().other());
    db.shutdown();
    renameCopiedLogicalLog(storeDir);
    try {
        db = new EmbeddedGraphDatabase(storeDir);
        fail("Shouldn't be able to do recovery (and upgrade log format version) on non-clean shutdown");
    } catch (Exception e) {
        // Good
        e.printStackTrace();
    }
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) IOException(java.io.IOException) Pair(org.neo4j.helpers.Pair) Test(org.junit.Test)

Example 52 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestExceptionTypeOnInvalidIds method createDatabase.

@BeforeClass
public static void createDatabase() {
    String storeDir = "target/var/id_test";
    AbstractNeo4jTestCase.deleteFileOrDirectory(new File(storeDir));
    graphdb = new EmbeddedGraphDatabase(storeDir);
    graphDbReadOnly = new EmbeddedReadOnlyGraphDatabase(storeDir);
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) EmbeddedReadOnlyGraphDatabase(org.neo4j.kernel.EmbeddedReadOnlyGraphDatabase) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 53 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestReadOnlyNeo4j method createSomeData.

private DbRepresentation createSomeData() {
    DynamicRelationshipType type = withName("KNOWS");
    GraphDatabaseService db = new EmbeddedGraphDatabase(PATH);
    Transaction tx = db.beginTx();
    Node prevNode = db.getReferenceNode();
    for (int i = 0; i < 100; i++) {
        Node node = db.createNode();
        Relationship rel = prevNode.createRelationshipTo(node, type);
        node.setProperty("someKey" + i % 10, i % 15);
        rel.setProperty("since", System.currentTimeMillis());
    }
    tx.success();
    tx.finish();
    DbRepresentation result = DbRepresentation.of(db);
    db.shutdown();
    return result;
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) DynamicRelationshipType(org.neo4j.graphdb.DynamicRelationshipType) DbRepresentation(org.neo4j.test.DbRepresentation)

Example 54 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestShortString method doBefore.

@Before
public void doBefore() {
    AbstractNeo4jTestCase.deleteFileOrDirectory(new File(PATH));
    db = new EmbeddedGraphDatabase(PATH);
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) File(java.io.File) Before(org.junit.Before)

Example 55 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class ManualTestPrepare method main.

public static void main(String[] args) throws Exception {
    FileUtils.deleteDirectory(ManualTest1.PATH.getParentFile());
    new EmbeddedGraphDatabase(ManualTest1.PATH.getAbsolutePath()).shutdown();
    FileUtils.copyDirectory(ManualTest1.PATH, ManualTest2.PATH);
    FileUtils.deleteDirectory(ManualZooKeepers.PATH);
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase)

Aggregations

EmbeddedGraphDatabase (org.neo4j.kernel.EmbeddedGraphDatabase)84 Test (org.junit.Test)50 File (java.io.File)35 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)32 Node (org.neo4j.graphdb.Node)26 Transaction (org.neo4j.graphdb.Transaction)17 Relationship (org.neo4j.graphdb.Relationship)14 BeforeClass (org.junit.BeforeClass)13 HashMap (java.util.HashMap)7 BatchInserterImpl (org.neo4j.kernel.impl.batchinsert.BatchInserterImpl)6 RandomAccessFile (java.io.RandomAccessFile)5 BatchInserter (org.neo4j.kernel.impl.batchinsert.BatchInserter)5 BatchInserterIndex (org.neo4j.graphdb.index.BatchInserterIndex)4 TransactionManager (javax.transaction.TransactionManager)3 Before (org.junit.Before)3 DynamicRelationshipType (org.neo4j.graphdb.DynamicRelationshipType)3 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)3 BatchInserterIndexProvider (org.neo4j.graphdb.index.BatchInserterIndexProvider)3 IndexManager (org.neo4j.graphdb.index.IndexManager)3 Transaction (javax.transaction.Transaction)2