当前位置: 首页>>代码示例>>Java>>正文


Java TestGraphDatabaseFactory类代码示例

本文整理汇总了Java中org.neo4j.test.TestGraphDatabaseFactory的典型用法代码示例。如果您正苦于以下问题:Java TestGraphDatabaseFactory类的具体用法?Java TestGraphDatabaseFactory怎么用?Java TestGraphDatabaseFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TestGraphDatabaseFactory类属于org.neo4j.test包,在下文中一共展示了TestGraphDatabaseFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: question5346011

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
@Test
public void question5346011()
{
    GraphDatabaseService service = new TestGraphDatabaseFactory().newImpermanentDatabase();
    try ( Transaction tx = service.beginTx() )
    {
        RelationshipIndex index = service.index().forRelationships( "exact" );
        // ...creation of the nodes and relationship
        Node node1 = service.createNode();
        Node node2 = service.createNode();
        String a_uuid = "xyz";
        Relationship relationship = node1.createRelationshipTo( node2, DynamicRelationshipType.withName( "related" ) );
        index.add( relationship, "uuid", a_uuid );
        // query
        IndexHits<Relationship> hits = index.get( "uuid", a_uuid, node1, node2 );
        assertEquals( 1, hits.size() );
        tx.success();
    }
    service.shutdown();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:21,代码来源:RelatedNodesQuestionTest.java

示例2: deleteIndex

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
@Test
public void deleteIndex()
{
    GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
    try ( Transaction tx = graphDb.beginTx() )
    {
        // START SNIPPET: delete
        IndexManager index = graphDb.index();
        Index<Node> actors = index.forNodes( "actors" );
        actors.delete();
        // END SNIPPET: delete
        tx.success();
    }
    assertFalse( indexExists( graphDb ) );
    graphDb.shutdown();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:17,代码来源:ImdbDocTest.java

示例3: main

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
public static void main( String[] args )
{
    GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( args[0] );
    try ( Transaction tx = db.beginTx() )
    {
        Index<Relationship> index = db.index().forRelationships( "myIndex" );
        Node node = db.createNode();
        Relationship relationship = db.createNode().createRelationshipTo( node,
                DynamicRelationshipType.withName( "KNOWS" ) );

        index.add( relationship, "key", "value" );
        tx.success();
    }

    db.shutdown();
    System.exit( 0 );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:18,代码来源:RecoveryTest.java

示例4: setup

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
@Before
public void setup() throws InterruptedException, ExecutionException {
  graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
  Transaction tx = graphDb.beginTx();
  enableIndexing();
  parent = graphDb.createNode();
  parent.setProperty(CommonProperties.IRI, "http://example.org/a");
  child = graphDb.createNode();
  child.createRelationshipTo(parent, OwlRelationships.RDFS_SUBCLASS_OF);
  grandChild = graphDb.createNode();
  grandChild.createRelationshipTo(child, OwlRelationships.RDFS_SUBCLASS_OF);
  equivalent = graphDb.createNode();
  equivalentSubclass = graphDb.createNode();
  equivalentSubclass.createRelationshipTo(equivalent, OwlRelationships.RDFS_SUBCLASS_OF);
  equivalent.createRelationshipTo(child, OwlRelationships.OWL_EQUIVALENT_CLASS);
  instance = graphDb.createNode();
  instance.createRelationshipTo(grandChild, OwlRelationships.RDF_TYPE);
  tx.success();
  postprocessor = new OwlPostprocessor(graphDb, Collections.<String, String>emptyMap());
  Map<String, String> categoryMap = new HashMap<>();
  categoryMap.put("http://example.org/a", "foo");
  tx.close();
  postprocessor.processCategories(categoryMap);
  tx = graphDb.beginTx();
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:26,代码来源:OwlPostprocessorTest.java

示例5: setupDb

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
@BeforeClass
public static void setupDb() {
  graphDb = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase();
  // graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(new
  // File("/tmp/lucene")).newGraphDatabase(); // convenient for debugging
  Neo4jConfiguration config = new Neo4jConfiguration();
  config.getExactNodeProperties().addAll(
      newHashSet(NodeProperties.LABEL, Concept.SYNONYM, Concept.ABREVIATION, Concept.ACRONYM));
  config.getIndexedNodeProperties().addAll(
      newHashSet(NodeProperties.LABEL, Concept.CATEGORY, Concept.SYNONYM, Concept.ABREVIATION,
          Concept.ACRONYM));
  Neo4jModule.setupAutoIndexing(graphDb, config);
  graph = new GraphTransactionalImpl(graphDb, idMap, new RelationshipMap());
  curieUtil = new CurieUtil(Collections.<String, String>emptyMap());
  cypherUtil = new CypherUtil(graphDb, curieUtil);
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:17,代码来源:GraphTestBase.java

示例6: setUp

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
@Before
public void setUp() throws IOException, InterruptedException
{
    database = new TestGraphDatabaseFactory().newImpermanentDatabase();
    Runtime.getRuntime().addShutdownHook(new Thread()
    {
        @Override
        public void run()
        {
            database.shutdown();
        }
    });
    ServerConfigurator configurator = new ServerConfigurator((GraphDatabaseAPI) database);
    int port = neoServerPort();
    configurator.configuration().addProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, port);
    configurator.configuration().addProperty("dbms.security.auth_enabled", false);
    bootstrapper = new WrappingNeoServerBootstrapper((GraphDatabaseAPI) database, configurator);
    bootstrapper.start();
    while (!bootstrapper.getServer().getDatabase().isRunning())
    {
        // It's ok to spin here.. it's not production code.
        Thread.sleep(250);
    }
    client = new Neo4jClient("http://localhost:" + port + "/db/data");
}
 
开发者ID:mangrish,项目名称:java-neo4j-client,代码行数:26,代码来源:EndToEndTests.java

示例7: setUp

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
public void setUp() throws Exception {
    super.setUp();
    neoDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
    graphDb = new NeoGraphDatabase(neoDb);
    obelixQueue = new InternalObelixQueue();
    obelixCacheQueue = new InternalObelixQueue();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("type", "events.pageviews");
    jsonObject.put("user", "1");
    jsonObject.put("item", "1");
    jsonObject.put("timestamp", "1421027564617");

    obelixQueue.push(new ObelixQueueElement(jsonObject));

}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:17,代码来源:NeoFeederTest.java

示例8: setUp

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
public void setUp() throws Exception {
    super.setUp();

    neoDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
    graphDb = new NeoGraphDatabase(neoDb);
    obelixQueue = new InternalObelixQueue();
    obelixStore = new InternalObelixStore();
    obelixCacheQueue = new InternalObelixQueue();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("type", "events.pageviews");
    jsonObject.put("user", "1");
    jsonObject.put("item", "1");
    jsonObject.put("timestamp", "1421027564617");

    obelixQueue.push(new ObelixQueueElement(jsonObject));
}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:18,代码来源:CacheBuilderTest.java

示例9: createGraphDB

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
@Override
	protected GraphDatabaseService createGraphDB() {
		GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder();
		if (this.properties != null) {
			if (this.properties
					.getProperty(DBProperties.PAGECACHE_MEMORY) != null)
				builder.setConfig(
						GraphDatabaseSettings.pagecache_memory,
						DBProperties.PAGECACHE_MEMORY);
			if (this.properties.getProperty(DBProperties.STRING_BLOCK_SIZE) != null)
				builder.setConfig(GraphDatabaseSettings.string_block_size,
						DBProperties.ARRAY_BLOCK_SIZE);
			if (this.properties.getProperty(DBProperties.STRING_BLOCK_SIZE) != null)
				builder.setConfig(GraphDatabaseSettings.array_block_size,
						DBProperties.ARRAY_BLOCK_SIZE);
		}
		
//		builder.setConfig(GraphDatabaseSettings.cypher_planner, "RULE");
		
		return builder.newGraphDatabase();
	}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:22,代码来源:InMemoryDBAccess.java

示例10: bootstrap

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
@Test
public void bootstrap() throws URISyntaxException {
    GraphDatabaseService graphDatabaseService = new TestGraphDatabaseFactory().newImpermanentDatabase();
    XOUnit xoUnit = XOUnitBuilder.create("graphDb:///", Neo4jXOProvider.class, A.class).property(GraphDatabaseService.class.getName(), graphDatabaseService).create();
    XOManagerFactory xoManagerFactory = XO.createXOManagerFactory(xoUnit);
    XOManager xoManager = xoManagerFactory.createXOManager();
    xoManager.currentTransaction().begin();
    A a = xoManager.create(A.class);
    a.setName("Test");
    xoManager.currentTransaction().commit();
    xoManager.close();
    xoManagerFactory.close();
    try (Transaction transaction = graphDatabaseService.beginTx()) {
        ResourceIterator<Node> iterator = graphDatabaseService.findNodes(label("A"), "name", "Test");
        assertThat(iterator.hasNext(), equalTo(true));
        Node node = iterator.next();
        assertThat(node.hasLabel(label("A")), equalTo(true));
        assertThat(node.getProperty("name"), equalTo((Object) "Test"));
        transaction.success();
    }
}
 
开发者ID:buschmais,项目名称:extended-objects,代码行数:22,代码来源:GraphDbBootstrapTest.java

示例11: prepareTestDatabase

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
@Before
public void prepareTestDatabase() throws Exception {
	mGraphDb = new TestGraphDatabaseFactory()
	.newImpermanentDatabaseBuilder().newGraphDatabase();

	Neo4JConnection neo4jConnection = mock(Neo4JConnection.class);
	when(neo4jConnection.getConnection()).thenReturn(mGraphDb);
	Neo4JRepository repo = new Neo4JRepository(neo4jConnection,
			MessageDigest.getInstance("MD5"));
	mDbConnection = mock(Neo4JConnection.class);
	mTimestampManager = new Neo4JTimestampManager(mDbConnection);
	when(mDbConnection.getTimestampManager()).thenReturn(mTimestampManager);
	when(mDbConnection.getConnection()).thenReturn(mGraphDb);
	mReader = new Neo4JReader(repo, mDbConnection, "testDB");
	mExecutor = new Neo4JExecutor(mDbConnection);
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:17,代码来源:SimpleGraphServiceTest.java

示例12: loadTensorFlow

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
@Test
    @Ignore("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.")
    public void loadTensorFlow() throws Exception {
//        String url = getClass().getResource("/tensorflow_example.pbtxt").toString();
        String url = getClass().getResource("/saved_model.pb").toString();
        System.out.println("url = " + url);
        GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
        try (Transaction tx = db.beginTx()) {
            LoadTensorFlow load = new LoadTensorFlow();
            load.loadTensorFlow(url);
            tx.success();
        }
    }
 
开发者ID:neo4j-contrib,项目名称:neo4j-ml-procedures,代码行数:14,代码来源:LoadTest.java

示例13: EmbeddedTestkitDriver

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
public EmbeddedTestkitDriver(final File storeDir) {
        GraphDatabaseSettings.BoltConnector bolt = GraphDatabaseSettings.boltConnector( "0" );

        String host = "localhost";
        int port = 7687; // this is the default Neo4j port - we start one higher than this
        GraphDatabaseService graphDb = null;
        String address = null;
        while (port < 65000) {
            port++;
            address = String.format("%s:%d", host, port);
            try {
                graphDb = new TestGraphDatabaseFactory()
                    .newImpermanentDatabaseBuilder()
//                    .newEmbeddedDatabaseBuilder(storeDir)
                    .setConfig(bolt.type, "BOLT")
                    .setConfig(bolt.enabled, "true")
                    .setConfig(bolt.address, address)
                    .newGraphDatabase();
            } catch (RuntimeException e) {
                // this is usually a org.neo4j.kernel.lifecycle.LifecycleException
                // caused by org.neo4j.helpers.PortBindException
                e.printStackTrace();
                System.out.println("Cannot connect on port " + port + ", retrying on a higher port.");
                continue;
            }
            break;
        }

        gds = graphDb;
        driver = GraphDatabase.driver("bolt://" + address);
    }
 
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:32,代码来源:EmbeddedTestkitDriver.java

示例14: batchInsert

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
@Test
public void batchInsert() throws Exception
{
    Neo4jTestCase.deleteFileOrDirectory( new File(
            "target/neo4jdb-batchinsert" ) );
    // START SNIPPET: batchInsert
    BatchInserter inserter = BatchInserters.inserter( "target/neo4jdb-batchinsert" );
    BatchInserterIndexProvider indexProvider =
            new LuceneBatchInserterIndexProvider( inserter );
    BatchInserterIndex actors =
            indexProvider.nodeIndex( "actors", MapUtil.stringMap( "type", "exact" ) );
    actors.setCacheCapacity( "name", 100000 );

    Map<String, Object> properties = MapUtil.map( "name", "Keanu Reeves" );
    long node = inserter.createNode( properties );
    actors.add( node, properties );

    //make the changes visible for reading, use this sparsely, requires IO!
    actors.flush();

    // Make sure to shut down the index provider as well
    indexProvider.shutdown();
    inserter.shutdown();
    // END SNIPPET: batchInsert

    GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( "target/neo4jdb-batchinsert" );
    try ( Transaction tx = db.beginTx() )
    {
        Index<Node> index = db.index().forNodes( "actors" );
        Node reeves = index.get( "name", "Keanu Reeves" ).next();
        assertEquals( node, reeves.getId() );
    }
    db.shutdown();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:35,代码来源:ImdbDocTest.java

示例15: switchToGraphDatabaseService

import org.neo4j.test.TestGraphDatabaseFactory; //导入依赖的package包/类
private void switchToGraphDatabaseService( ConfigurationParameter... config )
{
    shutdownInserter();
    GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir );
    for ( ConfigurationParameter configurationParameter : config )
    {
        builder = builder.setConfig( configurationParameter.key, configurationParameter.value );
    }
    db = builder.newGraphDatabase();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:11,代码来源:TestLuceneBatchInsert.java


注:本文中的org.neo4j.test.TestGraphDatabaseFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。