Examples of GraphDatabaseService


Examples of org.neo4j.graphdb.GraphDatabaseService

  @Test
  public void testEmbeddedIsTheDefaultGraphDatabaseService() throws Exception {
    Properties properties = new Properties();
    properties.put( Neo4jProperties.DATABASE_PATH, Neo4jTestHelper.dbLocation() );
    Neo4jGraphDatabaseServiceFactoryProvider graphService = new Neo4jGraphDatabaseServiceFactoryProvider();
    GraphDatabaseService db = graphService.load( properties, new ClassLoaderServiceImpl() ).create();
    db.shutdown();
    assertThat( db.getClass() ). isEqualTo( EmbeddedGraphDatabase.class );
  }
View Full Code Here

Examples of org.neo4j.graphdb.GraphDatabaseService

  public void testSelectedGraphDatabaseServiceIsLoaded() throws Exception {
    Properties properties = new Properties();
    properties.put( Neo4jProperties.DATABASE_PATH, Neo4jTestHelper.dbLocation() );
    properties.put( InternalProperties.NEO4J_GRAPHDB_FACTORYCLASS, MockGraphServiceFactory.class.getName() );
    Neo4jGraphDatabaseServiceFactoryProvider graphService = new Neo4jGraphDatabaseServiceFactoryProvider();
    GraphDatabaseService db = graphService.load( properties, new ClassLoaderServiceImpl() ).create();
    db.shutdown();
    assertThat( db.getClass() ). isEqualTo( MockGraphDatabaseService.class );
  }
View Full Code Here

Examples of org.neo4j.graphdb.GraphDatabaseService

    @Test
    public void testGetDatabaseFactory() throws Exception {
        final FilterConfig config = mock(FilterConfig.class);
        final ServletContext context = mock(ServletContext.class);
        final GraphDatabaseService database = mock(GraphDatabaseService.class);
        when(context.getAttribute(argThat(is(ConsoleFilter.DATABASE_ATTRIBUTE)))).thenReturn(DatabaseInfo.sandbox(database));
        when(config.getServletContext()).thenReturn(context);
        when(config.getInitParameter(argThat(is("applicationClass")))).thenReturn(TestApplication.class.getName());
        new ConsoleFilter().init(config);
        assertThat(databaseInfo.getDatabase(),is(database));
View Full Code Here

Examples of org.neo4j.graphdb.GraphDatabaseService

        SessionService.cleanSessions();
    }

    @Test
    public void testGetService() throws Exception {
        final GraphDatabaseService database = mock(GraphDatabaseService.class);
        SessionService.setDatabaseInfo(DatabaseInfo.expose(database));
        final DatabaseInfo newDatabase = SessionService.getDatabaseInfo();
        assertThat(newDatabase.getDatabase(),is(database));
        assertThat(newDatabase.isSandbox(),is(false));
        assertThat(newDatabase.shouldImport(),is(false));
View Full Code Here

Examples of org.neo4j.graphdb.GraphDatabaseService

        assertThat(newDatabase.shouldCreateNew(),is(false));
    }

    @Test
    public void testGetSessionFromService() throws Exception {
        final GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase();
        SessionService.setDatabaseInfo(DatabaseInfo.expose(database));
        serviceForId(SESSION_ID, true);
        serviceForId(SESSION_ID, false);
        noServiceForId(SESSION_ID+"foo",false);
    }
View Full Code Here

Examples of org.neo4j.graphdb.GraphDatabaseService

        consoleService.initFromUrl(service, new URL(CYPHER_URL), "start n=node(" + remoteNode.getId() + ") return n");
        checkImportedNode(NAME, VALUE);
    }

    private void checkImportedNode(String prop, String value) {
        GraphDatabaseService gdb = service.getGraphDatabase();
        try (Transaction tx = gdb.beginTx()) {
            Node imported = IteratorUtil.single(GlobalGraphOperations.at(gdb).getAllNodes());
            assertEquals(value, imported.getProperty(prop));
            tx.success();
        }
    }
View Full Code Here

Examples of org.neo4j.graphdb.GraphDatabaseService

    public static void main(String[] args) throws Exception
    {
        System.setProperty("file.encoding","UTF-8");
        int port = (args.length>0) ? Integer.parseInt(args[0]): getPort();
        boolean expose = args.length>2 && args[2].equalsIgnoreCase("expose");
        GraphDatabaseService database = (args.length>1) ? embeddedGraphDatabase(args[1],expose) : null;
        final Console console = expose ? Console.expose(database) : Console.sandbox(database);
        console.start(port);
        console.join();
    }
View Full Code Here

Examples of org.neo4j.graphdb.GraphDatabaseService

      assertEquals(a.getMax(i), b.getMax(i), 0);
    }
  } 
 
  protected RTreeIndex createIndex() {
        GraphDatabaseService db = graphDb();
        return new RTreeIndex(db, ReferenceNodes.getReferenceNode(db),
        new EnvelopeDecoderFromDoubleArray("bbox"));
  }
View Full Code Here

Examples of org.neo4j.graphdb.GraphDatabaseService

public class TestSearchFilter extends SpatialTestCase {
 
  @Test
  public void searchIndexWithFilter() {
        GraphDatabaseService db = graphDb();
        RTreeIndex index = new RTreeIndex(db, ReferenceNodes.getReferenceNode(db),
        new EnvelopeDecoderFromDoubleArray("bbox"));

    // equal bbox test
    index.add(createGeomNode(0, 0, 2, 3));
View Full Code Here

Examples of org.neo4j.graphdb.GraphDatabaseService

            index.flush();
        }
    }

    private void removeReferenceNodeAndFinalizeKeyIndices() {
        GraphDatabaseService rawGraphDB = null;
        try {
            GraphDatabaseBuilder builder = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(this.rawGraph.getStoreDir());
            if (this.vertexIndexKeys.size() > 0)
                builder.setConfig(GraphDatabaseSettings.node_keys_indexable, vertexIndexKeys.toString().replace("[", "").replace("]", "")).setConfig(GraphDatabaseSettings.node_auto_indexing, "true");
            if (this.edgeIndexKeys.size() > 0)
                builder.setConfig(GraphDatabaseSettings.relationship_keys_indexable, edgeIndexKeys.toString().replace("[", "").replace("]", "")).setConfig(GraphDatabaseSettings.relationship_auto_indexing, "true");

            rawGraphDB = builder.newGraphDatabase();

            Transaction tx = rawGraphDB.beginTx();
            try {
                GlobalGraphOperations graphOperations = GlobalGraphOperations.at(rawGraphDB);
                if (this.vertexIndexKeys.size() > 0)
                    populateKeyIndices(rawGraphDB, rawGraphDB.index().getNodeAutoIndexer(), graphOperations.getAllNodes(), Vertex.class);
                if (this.edgeIndexKeys.size() > 0)
                    populateKeyIndices(rawGraphDB, rawGraphDB.index().getRelationshipAutoIndexer(), graphOperations.getAllRelationships(), Edge.class);
                tx.success();
            } finally {
                tx.close();
            }
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        } finally {
            if (rawGraphDB != null) rawGraphDB.shutdown();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.