Search in sources :

Example 1 with IndexFolderLayout

use of org.neo4j.kernel.api.impl.index.storage.layout.IndexFolderLayout in project neo4j by neo4j.

the class ConstraintCreationIT method shouldNotLeaveLuceneIndexFilesHangingAroundIfConstraintCreationFails.

@Test
public void shouldNotLeaveLuceneIndexFilesHangingAroundIfConstraintCreationFails() {
    // given
    GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
    try (Transaction tx = db.beginTx()) {
        for (int i = 0; i < 2; i++) {
            Node node1 = db.createNode(LABEL);
            node1.setProperty("prop", true);
        }
        tx.success();
    }
    // when
    try (Transaction tx = db.beginTx()) {
        db.schema().constraintFor(LABEL).assertPropertyIsUnique("prop").create();
        fail("Should have failed with ConstraintViolationException");
        tx.success();
    } catch (ConstraintViolationException ignored) {
    }
    // then
    try (Transaction ignore = db.beginTx()) {
        assertEquals(0, Iterables.count(db.schema().getIndexes()));
    }
    SchemaIndexProvider schemaIndexProvider = db.getDependencyResolver().resolveDependency(SchemaIndexProvider.class);
    File schemaStoreDir = schemaIndexProvider.getSchemaIndexStoreDirectory(new File(db.getStoreDir()));
    assertFalse(new IndexFolderLayout(schemaStoreDir, INDEX_IDENTIFIER).getIndexFolder().exists());
}
Also used : SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Transaction(org.neo4j.graphdb.Transaction) IndexFolderLayout(org.neo4j.kernel.api.impl.index.storage.layout.IndexFolderLayout) Node(org.neo4j.graphdb.Node) ConstraintViolationException(org.neo4j.graphdb.ConstraintViolationException) File(java.io.File) Test(org.junit.Test)

Example 2 with IndexFolderLayout

use of org.neo4j.kernel.api.impl.index.storage.layout.IndexFolderLayout in project neo4j by neo4j.

the class FailureStorageTest method before.

@Before
public void before() {
    File rootDirectory = new File("dir");
    fs.get().mkdirs(rootDirectory);
    indexFolderLayout = new IndexFolderLayout(rootDirectory, indexIdentifier);
}
Also used : IndexFolderLayout(org.neo4j.kernel.api.impl.index.storage.layout.IndexFolderLayout) File(java.io.File) Before(org.junit.Before)

Aggregations

File (java.io.File)2 IndexFolderLayout (org.neo4j.kernel.api.impl.index.storage.layout.IndexFolderLayout)2 Before (org.junit.Before)1 Test (org.junit.Test)1 ConstraintViolationException (org.neo4j.graphdb.ConstraintViolationException)1 Node (org.neo4j.graphdb.Node)1 Transaction (org.neo4j.graphdb.Transaction)1 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)1 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)1