Package org.neo4j.kernel

Examples of org.neo4j.kernel.EmbeddedGraphDatabase


public class RelatedNodesQuestionTest
{
    @Test
    public void question5346011()
    {
        GraphDatabaseService service = new EmbeddedGraphDatabase( "target/soquestion-test" );
        Transaction transaction = service.beginTx();
        try
        {
            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() );
            transaction.success();
        }
        finally
        {
            transaction.finish();
        }
        service.shutdown();
    }
View Full Code Here


    @BeforeClass
    public static void setUpDb()
    {
        String path = "target/var/examples";
        Neo4jTestCase.deleteFileOrDirectory( new File( path ) );
        graphDb = new EmbeddedGraphDatabase( path );
    }
View Full Code Here

     * @throws java.io.IOException
     */
    @Test
    public void shouldNotCrashNormalGraphdbCreation() throws IOException
    {
        EmbeddedGraphDatabase graphdb = createTempDatabase( null );
        destroy( graphdb );
    }
View Full Code Here

     * Expect the counts to be initialized.
     */
    @Test
    public void shouldLoadWhenNormalGraphdbIsCreated() throws Exception
    {
        EmbeddedGraphDatabase graphdb = createTempDatabase( null );
        // when the UDC extension successfully loads, it initializes the attempts count to 0
        assertGotSuccessWithRetry( IS_ZERO );
        destroy( graphdb );
    }
View Full Code Here

     * Expect separate counts for each graphdb.
     */
    @Test
    public void shouldLoadForEachCreatedGraphdb() throws IOException
    {
        EmbeddedGraphDatabase graphdb1 = createTempDatabase( null );
        EmbeddedGraphDatabase graphdb2 = createTempDatabase( null );
        Set<String> successCountValues = UdcTimerTask.successCounts.keySet();
        assertThat( successCountValues.size(), equalTo( 2 ) );
        assertThat( "this", is( not( "that" ) ) );
        destroy( graphdb1 );
        destroy( graphdb2 );
View Full Code Here

    public void shouldRecordFailuresWhenThereIsNoServer() throws Exception
    {
        Map<String, String> config = new HashMap<String, String>();
        config.put( UdcExtensionImpl.FIRST_DELAY_CONFIG_KEY, "100" ); // first delay must be long enough to allow class initialization to complete
        config.put( UdcExtensionImpl.UDC_HOST_ADDRESS_KEY, "127.0.0.1:1" );
        EmbeddedGraphDatabase graphdb = new EmbeddedGraphDatabase( "should-record-failures", config );
        assertGotFailureWithRetry( IS_GREATER_THAN_ZERO );
        destroy( graphdb );
    }
View Full Code Here

        Map<String, String> config = new HashMap<String, String>();
        config.put( UdcExtensionImpl.FIRST_DELAY_CONFIG_KEY, "100" );
        config.put( UdcExtensionImpl.UDC_HOST_ADDRESS_KEY, serverAddress );

        EmbeddedGraphDatabase graphdb = createTempDatabase( config );
        assertGotSuccessWithRetry( IS_GREATER_THAN_ZERO );
        assertGotFailureWithRetry( IS_ZERO );
        destroy( graphdb );
    }
View Full Code Here

        Map<String, String> config = new HashMap<String, String>();
        config.put( UdcExtensionImpl.FIRST_DELAY_CONFIG_KEY, "100" );
        config.put( UdcExtensionImpl.UDC_HOST_ADDRESS_KEY, serverAddress );
        config.put( UdcExtensionImpl.UDC_SOURCE_KEY, "test" );

        EmbeddedGraphDatabase graphdb = createTempDatabase( config );
        assertGotSuccessWithRetry( IS_GREATER_THAN_ZERO );
        assertEquals( "test", handler.getQueryMap().get( "source" ) );

        destroy( graphdb );
    }
View Full Code Here

        fail();
    }

    private EmbeddedGraphDatabase createTempDatabase( Map<String, String> config ) throws IOException
    {
        EmbeddedGraphDatabase tempdb = null;
        String randomDbName = "tmpdb-" + rnd.nextInt();
        File possibleDirectory = new File( "target" + File.separator
                + randomDbName );
        if ( possibleDirectory.exists() )
        {
            FileUtils.deleteDirectory( possibleDirectory );
        }
        if ( config == null )
        {
            tempdb = new EmbeddedGraphDatabase( randomDbName );
        } else
        {
            tempdb = new EmbeddedGraphDatabase( randomDbName, config );
        }
        return tempdb;
    }
View Full Code Here

        {
            shutdownDbs();
        }

        GraphDatabaseService masterOfflineDb =
                new EmbeddedGraphDatabase( dbPath( 0 ).getAbsolutePath() );
        GraphDatabaseService[] slaveOfflineDbs = new GraphDatabaseService[haDbs.size()];
        for ( int i = 1; i <= haDbs.size(); i++ )
        {
            slaveOfflineDbs[i-1] = new EmbeddedGraphDatabase( dbPath( i ).getAbsolutePath() );
        }
        try
        {
            verify( masterOfflineDb, slaveOfflineDbs );
        }
        finally
        {
            masterOfflineDb.shutdown();
            for ( GraphDatabaseService db : slaveOfflineDbs )
            {
                db.shutdown();
            }
        }
View Full Code Here

TOP

Related Classes of org.neo4j.kernel.EmbeddedGraphDatabase

Copyright © 2018 www.massapicom. 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.