@Before public void init() { db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase(); }
@Before public void setup() { fs = fsRule.get(); File storeDir = testDirectory.databaseDir(); builder = new TestGraphDatabaseFactory().setFileSystem( new UncloseableDelegatingFileSystemAbstraction( fs ) ) .newImpermanentDatabaseBuilder( storeDir ); }
@Before public void before() { db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newEmbeddedDatabase( testDirectory.storeDir() ); }
public static DbRepresentation of( File storeDir, boolean includeIndexes, Config config ) { GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir ); builder.setConfig( config.getRaw() ); GraphDatabaseService db = builder.newGraphDatabase(); try { return of( db, includeIndexes ); } finally { db.shutdown(); } }
private GraphDatabaseService startDatabase( File storeDir ) { return new TestGraphDatabaseFactory().setInternalLogProvider( logProvider ).newEmbeddedDatabase( storeDir ); }
private static GraphDatabaseService startDatabase( File storeDir ) { return new TestGraphDatabaseFactory().newEmbeddedDatabase( storeDir ); }
@Before public void setUp() { gdb = new TestGraphDatabaseFactory().newImpermanentDatabase(); tx = gdb.beginTx(); }
@Before public void setup() { db = new TestGraphDatabaseFactory() .newEmbeddedDatabaseBuilder( testDirectory.databaseDir() ) .newGraphDatabase(); }
@Before public void doBefore() { db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newEmbeddedDatabase( testDirectory.databaseDir() ); }
@Before public void setup() { databaseLayout = testDirectory.databaseLayout(); storeDir = databaseLayout.databaseDirectory(); fileSystem = fileSystemRule.get(); new TestGraphDatabaseFactory().setFileSystem( fileSystem ).newImpermanentDatabase( storeDir ).shutdown(); }
@Before public void setup() { db = (GraphDatabaseFacade) new TestGraphDatabaseFactory().newImpermanentDatabase(); try ( Transaction tx = db.beginTx() ) { Node node = db.createNode(); node.createRelationshipTo( db.createNode(), withName( "a" ) ); node.createRelationshipTo( db.createNode(), withName( "b" ) ); relId = node.createRelationshipTo( db.createNode(), withName( "c" ) ).getId(); tx.success(); } }
@Before public void startDb() { graphDb = (GraphDatabaseAPI) new TestGraphDatabaseFactory(). newImpermanentDatabaseBuilder().setConfig(new HashMap<>()).newGraphDatabase(); try ( Transaction tx = graphDb.beginTx() ) { // Create the node and relationship auto-indexes graphDb.index().getNodeAutoIndexer().setEnabled(true); graphDb.index().getNodeAutoIndexer().startAutoIndexingProperty( "nodeProp"); graphDb.index().getRelationshipAutoIndexer().setEnabled(true); graphDb.index().getRelationshipAutoIndexer().startAutoIndexingProperty( "type"); tx.success(); } try ( Transaction tx = graphDb.beginTx() ) { Node node1 = graphDb.createNode(); Node node2 = graphDb.createNode(); Node node3 = graphDb.createNode(); id1 = node1.getId(); id2 = node2.getId(); id3 = node3.getId(); Relationship rel = node1.createRelationshipTo(node2, RelationshipType.withName("FOO")); rel.setProperty("type", "FOO"); tx.success(); } }
private EphemeralFileSystemAbstraction produceUncleanStore() { GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem( fs.get() ) .newImpermanentDatabase( testDirectory.databaseDir() ); try ( Transaction tx = db.beginTx() ) { db.createNode(); tx.success(); } EphemeralFileSystemAbstraction snapshot = fs.get().snapshot(); db.shutdown(); return snapshot; }
private void createGraphDbAndKillIt() { final GraphDatabaseService db = new TestGraphDatabaseFactory() .setFileSystem( fs ) .newImpermanentDatabaseBuilder( storeDirectory.databaseDir() ) .newGraphDatabase(); try ( Transaction tx = db.beginTx() ) { db.createNode( label( "FOO" ) ); db.createNode( label( "BAR" ) ); tx.success(); } db.shutdown(); }
private static void performTransactions( String txPath, File storeDir ) { GraphDatabaseService database = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir ) .setConfig( GraphDatabaseSettings.logical_logs_location, txPath ) .newGraphDatabase(); for ( int i = 0; i < 10; i++ ) { try ( Transaction transaction = database.beginTx() ) { Node node = database.createNode(); node.setProperty( "a", "b" ); node.setProperty( "c", "d" ); transaction.success(); } } database.shutdown(); }
byte[] arrayValue = RandomStringUtils.randomAlphanumeric( 10000 ).getBytes(); GraphDatabaseService db = new TestGraphDatabaseFactory() .setFileSystem( fs.get() ) .newImpermanentDatabaseBuilder() .setConfig( GraphDatabaseSettings.string_block_size, "1024" ) .setConfig( GraphDatabaseSettings.array_block_size, "2048" ) .newGraphDatabase(); try try ( Transaction tx = db.beginTx() ) Node node = db.createNode(); nodeId = node.getId(); node.setProperty( "string", stringValue ); node.setProperty( "array", arrayValue ); tx.success(); try ( Transaction tx = db.beginTx() ) Node node = db.getNodeById( nodeId ); assertEquals( stringValue, node.getProperty( "string" ) ); assertArrayEquals( arrayValue, (byte[]) node.getProperty( "array" ) ); tx.success();
@Test public void testReadOnlyOperationsAndNoTransaction() GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem( fs.get() ).newImpermanentDatabase( testDirectory.databaseDir() ); Transaction tx = db.beginTx(); Node node1 = db.createNode(); Node node2 = db.createNode(); Relationship rel = node1.createRelationshipTo( node2, withName( "TEST" ) ); node1.setProperty( "key1", "value1" ); rel.setProperty( "key1", "value1" ); tx.success(); tx.close(); node1.createRelationshipTo( node2, withName( "TEST2" ) ); fail( "Write operation and no transaction should throw exception" ); assertEquals( rel, loadedRel ); assertThat(loadedRel, inTx(db, hasProperty( "key1" ).withValue( "value1" ))); transaction.close(); db.shutdown();
@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 uuid = "xyz"; Relationship relationship = node1.createRelationshipTo( node2, RelationshipType.withName( "related" ) ); index.add( relationship, "uuid", uuid ); // query try ( IndexHits<Relationship> hits = index.get( "uuid", uuid, node1, node2 ) ) { assertEquals( 1, hits.size() ); } tx.success(); } service.shutdown(); } }
@Before public void setUp() { db = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase(); }
private StoreAccess createStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes( int nDegreeTwoNodes ) File storeDirectory = testDirectory.databaseDir(); GraphDatabaseService database = new TestGraphDatabaseFactory() .newEmbeddedDatabaseBuilder( storeDirectory ) .setConfig( GraphDatabaseSettings.record_format, getRecordFormatName() ) .setConfig( "dbms.backup.enabled", "false" ) .newGraphDatabase(); try ( Transaction transaction = database.beginTx() ) Node denseNode = database.createNode(); for ( int i = 0; i < nDegreeTwoNodes; i++ ) Node degreeTwoNode = database.createNode(); Node leafNode = database.createNode(); if ( i % 2 == 0 ) denseNode.createRelationshipTo( degreeTwoNode, TestRelationshipType.CONNECTED ); degreeTwoNode.createRelationshipTo( denseNode, TestRelationshipType.CONNECTED ); degreeTwoNode.createRelationshipTo( leafNode, TestRelationshipType.CONNECTED ); transaction.success();