Search in sources :

Example 11 with EmbeddedGraphDatabase

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

the class TestCacheTypes method testDefaultCache.

@Test
public void testDefaultCache() {
    GraphDatabaseService db = newDb(null);
    assertEquals(CacheType.soft, ((EmbeddedGraphDatabase) db).getConfig().getGraphDbModule().getNodeManager().getCacheType());
    db.shutdown();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Test(org.junit.Test)

Example 12 with EmbeddedGraphDatabase

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

the class TestShortString method getSizeOfStringStore.

private long getSizeOfStringStore() {
    db.shutdown();
    long size = new File(PATH, "neostore.propertystore.db.strings").length();
    db = new EmbeddedGraphDatabase(PATH);
    return size;
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) File(java.io.File)

Example 13 with EmbeddedGraphDatabase

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

the class TestNeo4jCacheAndPersistence method testTxCacheLoadIsolation.

@Test
public void testTxCacheLoadIsolation() throws Exception {
    Node node = getGraphDb().createNode();
    node.setProperty("someproptest", "testing");
    Node node1 = getGraphDb().createNode();
    node1.setProperty("someotherproptest", 2);
    commit();
    EmbeddedGraphDatabase graphDb = (EmbeddedGraphDatabase) getGraphDb();
    TransactionManager txManager = graphDb.getConfig().getTxModule().getTxManager();
    NodeManager nodeManager = graphDb.getConfig().getGraphDbModule().getNodeManager();
    txManager.begin();
    node.setProperty("someotherproptest", "testing2");
    Relationship rel = node.createRelationshipTo(node1, MyRelTypes.TEST);
    javax.transaction.Transaction txA = txManager.suspend();
    txManager.begin();
    assertEquals("testing", node.getProperty("someproptest"));
    assertTrue(!node.hasProperty("someotherproptest"));
    assertTrue(!node.hasRelationship());
    nodeManager.clearCache();
    assertEquals("testing", node.getProperty("someproptest"));
    assertTrue(!node.hasProperty("someotherproptest"));
    javax.transaction.Transaction txB = txManager.suspend();
    txManager.resume(txA);
    assertEquals("testing", node.getProperty("someproptest"));
    assertTrue(node.hasProperty("someotherproptest"));
    assertTrue(node.hasRelationship());
    nodeManager.clearCache();
    assertEquals("testing", node.getProperty("someproptest"));
    assertTrue(node.hasProperty("someotherproptest"));
    assertTrue(node.hasRelationship());
    txManager.suspend();
    txManager.resume(txB);
    assertEquals("testing", node.getProperty("someproptest"));
    assertTrue(!node.hasProperty("someotherproptest"));
    assertTrue(!node.hasRelationship());
    txManager.rollback();
    txManager.resume(txA);
    node.delete();
    node1.delete();
    rel.delete();
    txManager.commit();
    newTransaction();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) TransactionManager(javax.transaction.TransactionManager) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) Test(org.junit.Test)

Example 14 with EmbeddedGraphDatabase

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

the class TestOsSpecificLocks method testDatabaseLocking.

@Test
public void testDatabaseLocking() {
    assumeTrue(Config.osIsWindows());
    EmbeddedGraphDatabase db = new EmbeddedGraphDatabase(path);
    Transaction tx = db.beginTx();
    db.createNode();
    tx.success();
    tx.finish();
    assertTrue(new File(path + "\\lock").exists());
    try {
        new EmbeddedGraphDatabase(path);
        fail("Should not be able to start up another db in the same dir");
    } catch (Exception e) {
    // Good
    }
    db.shutdown();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) Transaction(org.neo4j.graphdb.Transaction) File(java.io.File) Test(org.junit.Test)

Example 15 with EmbeddedGraphDatabase

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

the class TestUpgradeStore method makeSureLogsAreMovedWhenUpgrading.

@Test
public void makeSureLogsAreMovedWhenUpgrading() throws Exception {
    // Generate some logical logs
    String path = path(10);
    for (int i = 0; i < 3; i++) {
        new EmbeddedGraphDatabase(path, stringMap(KEEP_LOGICAL_LOGS, "true")).shutdown();
    }
    setOlderNeoStoreVersion(path);
    new EmbeddedGraphDatabase(path, stringMap(ALLOW_STORE_UPGRADE, "true")).shutdown();
    File oldLogDir = new File(path, "1.2-logs");
    assertTrue(oldLogDir.exists());
    assertTrue(new File(oldLogDir, "nioneo_logical.log.v0").exists());
    assertTrue(new File(oldLogDir, "nioneo_logical.log.v1").exists());
    assertTrue(new File(oldLogDir, "nioneo_logical.log.v2").exists());
    assertFalse(new File(path, "nioneo_logical.log.v0").exists());
    assertFalse(new File(path, "nioneo_logical.log.v1").exists());
    assertFalse(new File(path, "nioneo_logical.log.v2").exists());
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

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