Search in sources :

Example 76 with EmbeddedGraphDatabase

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

the class TestTxSuspendResume method testMultipleTxSameThread.

@Test
public void testMultipleTxSameThread() throws Exception {
    String storePath = getStorePath("test-neo2");
    deleteFileOrDirectory(storePath);
    EmbeddedGraphDatabase neo2 = new EmbeddedGraphDatabase(storePath);
    TransactionManager tm = neo2.getConfig().getTxModule().getTxManager();
    tm.begin();
    Node refNode = neo2.getReferenceNode();
    Transaction tx1 = tm.suspend();
    tm.begin();
    refNode.setProperty("test2", "test");
    Transaction tx2 = tm.suspend();
    tm.resume(tx1);
    CommitThread thread = new CommitThread(tm, tx2);
    thread.start();
    // would wait for ever since tx2 has write lock but now we have other
    // thread thread that will commit tx2
    refNode.removeProperty("test2");
    assertTrue(thread.success());
    tm.commit();
    neo2.shutdown();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) Transaction(javax.transaction.Transaction) TransactionManager(javax.transaction.TransactionManager) Node(org.neo4j.graphdb.Node) Test(org.junit.Test)

Example 77 with EmbeddedGraphDatabase

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

the class AbstractTestBase method beforeSuite.

@BeforeClass
public static final void beforeSuite() {
    deleteFileOrDirectory(new File(TARGET_NEODB));
    graphdb = new EmbeddedGraphDatabase(TARGET_NEODB);
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 78 with EmbeddedGraphDatabase

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

the class TestUpgradeStore method makeSureStoreWithTooBigStringBlockSizeCannotBeUpgraded.

@Test
public void makeSureStoreWithTooBigStringBlockSizeCannotBeUpgraded() throws Exception {
    String path = path(6);
    new EmbeddedGraphDatabase(path).shutdown();
    setBlockSize(new File(path, "neostore.propertystore.db.strings"), 0x10000, "StringPropertyStore v0.9.5");
    assertCannotStart(path, "Shouldn't be able to upgrade with block size that big");
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 79 with EmbeddedGraphDatabase

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

the class TestUpgradeStore method assertCannotStart.

private void assertCannotStart(String path, String failMessage) {
    GraphDatabaseService db = null;
    try {
        db = new EmbeddedGraphDatabase(path);
        fail(failMessage);
    } catch (TransactionFailureException e) {
        if (!(e.getCause() instanceof IllegalStoreVersionException)) {
            throw e;
        }
    // Good
    } finally {
        if (db != null) {
            db.shutdown();
        }
    }
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TransactionFailureException(org.neo4j.graphdb.TransactionFailureException)

Example 80 with EmbeddedGraphDatabase

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

the class TestUpgradeStore method makeSureStoreWithTooManyRelationshipTypesCannotBeUpgraded.

@Test
public void makeSureStoreWithTooManyRelationshipTypesCannotBeUpgraded() throws Exception {
    String path = path(0);
    new EmbeddedGraphDatabase(path).shutdown();
    createManyRelationshipTypes(path, 0x10000);
    assertCannotStart(path, "Shouldn't be able to upgrade with that many types set");
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) 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