Search in sources :

Example 1 with EnterpriseGraphDatabaseFactory

use of org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory in project neo4j by neo4j.

the class ForeignStoreIdIT method createAnotherStore.

private File createAnotherStore(File directory, int transactions) {
    GraphDatabaseService db = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabase(directory);
    createNodes(db, transactions, "node");
    db.shutdown();
    return directory;
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) EnterpriseGraphDatabaseFactory(org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory)

Example 2 with EnterpriseGraphDatabaseFactory

use of org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory in project neo4j by neo4j.

the class MetricsKernelExtensionFactoryIT method mustBeAbleToStartWithNullTracer.

@Test
public void mustBeAbleToStartWithNullTracer() throws Exception {
    // Start the database
    File disabledTracerDb = clusterRule.directory("disabledTracerDb");
    GraphDatabaseBuilder builder = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabaseBuilder(disabledTracerDb);
    GraphDatabaseService nullTracerDatabase = builder.setConfig(MetricsSettings.neoEnabled, Settings.TRUE).setConfig(csvEnabled, Settings.TRUE).setConfig(csvPath, outputPath.getAbsolutePath()).setConfig(GraphDatabaseFacadeFactory.Configuration.tracer, // key point!
    "null").newGraphDatabase();
    try (Transaction tx = nullTracerDatabase.beginTx()) {
        Node node = nullTracerDatabase.createNode();
        node.setProperty("all", "is well");
        tx.success();
    } finally {
        nullTracerDatabase.shutdown();
    }
// We assert that no exception is thrown during startup or the operation of the database.
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) EnterpriseGraphDatabaseFactory(org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory) Node(org.neo4j.graphdb.Node) File(java.io.File) GraphDatabaseBuilder(org.neo4j.graphdb.factory.GraphDatabaseBuilder) Test(org.junit.Test)

Example 3 with EnterpriseGraphDatabaseFactory

use of org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory in project neo4j by neo4j.

the class StartupConstraintSemanticsTest method shouldNotAllowOpeningADatabaseWithPECInCommunityEdition.

@Test
public void shouldNotAllowOpeningADatabaseWithPECInCommunityEdition() throws Exception {
    // given
    GraphDatabaseService graphDb = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabase(dir.graphDbDir());
    try {
        graphDb.execute("CREATE CONSTRAINT ON (n:Draconian) ASSERT exists(n.required)");
    } finally {
        graphDb.shutdown();
    }
    graphDb = null;
    // when
    try {
        graphDb = new TestGraphDatabaseFactory().newEmbeddedDatabase(dir.graphDbDir());
        fail("should have failed to start!");
    }// then
     catch (Exception e) {
        Throwable error = Exceptions.rootCause(e);
        assertThat(error, instanceOf(IllegalStateException.class));
        assertEquals(StandardConstraintSemantics.ERROR_MESSAGE, error.getMessage());
    } finally {
        if (graphDb != null) {
            graphDb.shutdown();
        }
    }
}
Also used : EnterpriseGraphDatabaseFactory(org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Test(org.junit.Test)

Example 4 with EnterpriseGraphDatabaseFactory

use of org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory in project neo4j by neo4j.

the class StoreMigratorFrom20IT method shouldMigrate.

@Test
public void shouldMigrate() throws IOException, ConsistencyCheckIncompleteException {
    // WHEN
    StoreMigrator storeMigrator = new StoreMigrator(fs, pageCache, getConfig(), NullLogService.getInstance(), schemaIndexProvider);
    SchemaIndexMigrator indexMigrator = new SchemaIndexMigrator(fs, schemaIndexProvider, labelScanStoreProvider);
    upgrader(indexMigrator, storeMigrator).migrateIfNeeded(find20FormatStoreDirectory(storeDir.directory()));
    // THEN
    assertEquals(2, monitor.progresses().size());
    assertTrue(monitor.isStarted());
    assertTrue(monitor.isFinished());
    GraphDatabaseService database = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir.absolutePath()).newGraphDatabase();
    try {
        verifyDatabaseContents(database);
    } finally {
        // CLEANUP
        database.shutdown();
    }
    LogProvider logProvider = NullLogProvider.getInstance();
    StoreFactory storeFactory = new StoreFactory(storeDir.directory(), pageCache, fs, logProvider);
    try (NeoStores neoStores = storeFactory.openAllNeoStores(true)) {
        verifyNeoStore(neoStores);
    }
    assertConsistentStore(storeDir.directory());
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) NullLogProvider(org.neo4j.logging.NullLogProvider) LogProvider(org.neo4j.logging.LogProvider) EnterpriseGraphDatabaseFactory(org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory) NeoStores(org.neo4j.kernel.impl.store.NeoStores) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator) SchemaIndexMigrator(org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) Test(org.junit.Test)

Example 5 with EnterpriseGraphDatabaseFactory

use of org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory in project neo4j by neo4j.

the class BatchInsertEnterpriseTest method shouldInsertDifferentTypesOfThings.

@Test
public void shouldInsertDifferentTypesOfThings() throws Exception {
    // GIVEN
    BatchInserter inserter = BatchInserters.inserter(directory.directory(), fileSystemRule.get(), stringMap(GraphDatabaseSettings.log_queries.name(), "true", GraphDatabaseSettings.record_format.name(), recordFormat, GraphDatabaseSettings.log_queries_filename.name(), directory.file("query.log").getAbsolutePath()));
    long node1Id, node2Id, relationshipId;
    try {
        // WHEN
        node1Id = inserter.createNode(someProperties(1), Labels.values());
        node2Id = node1Id + 10;
        inserter.createNode(node2Id, someProperties(2), Labels.values());
        relationshipId = inserter.createRelationship(node1Id, node2Id, MyRelTypes.TEST, someProperties(3));
        inserter.createDeferredSchemaIndex(Labels.One).on("key").create();
        inserter.createDeferredConstraint(Labels.Two).assertPropertyIsUnique("key").create();
    } finally {
        inserter.shutdown();
    }
    // THEN
    GraphDatabaseService db = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabase(directory.directory());
    try (Transaction tx = db.beginTx()) {
        Node node1 = db.getNodeById(node1Id);
        Node node2 = db.getNodeById(node2Id);
        assertEquals(someProperties(1), node1.getAllProperties());
        assertEquals(someProperties(2), node2.getAllProperties());
        assertEquals(relationshipId, single(node1.getRelationships()).getId());
        assertEquals(relationshipId, single(node2.getRelationships()).getId());
        assertEquals(someProperties(3), single(node1.getRelationships()).getAllProperties());
        tx.success();
    } finally {
        db.shutdown();
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) EnterpriseGraphDatabaseFactory(org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory) Node(org.neo4j.graphdb.Node) Test(org.junit.Test)

Aggregations

EnterpriseGraphDatabaseFactory (org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory)5 Test (org.junit.Test)4 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)4 Node (org.neo4j.graphdb.Node)2 Transaction (org.neo4j.graphdb.Transaction)2 File (java.io.File)1 GraphDatabaseBuilder (org.neo4j.graphdb.factory.GraphDatabaseBuilder)1 NeoStores (org.neo4j.kernel.impl.store.NeoStores)1 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)1 SchemaIndexMigrator (org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator)1 StoreMigrator (org.neo4j.kernel.impl.storemigration.participant.StoreMigrator)1 LogProvider (org.neo4j.logging.LogProvider)1 NullLogProvider (org.neo4j.logging.NullLogProvider)1 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)1