DatabaseMgr { public static DatasetGraph connectDatasetGraph(Location location) { return DB_ConnectCreate(location); } private  DatabaseMgr(); static DatasetGraph connectDatasetGraph(Location location); static DatasetGraph connectDatasetGraph(String location); static void compact(DatasetGraph container); static String backup(DatasetGraph container); static DatasetGraph createDatasetGraph(); @Deprecated // Wrong name static boolean isBackedByTDB(DatasetGraph datasetGraph); static boolean isTDB2(DatasetGraph datasetGraph); static Location location(DatasetGraph datasetGraph);  }
@Test public void testDatabaseMgr1() { TDBInternal.reset(); DatasetGraph dg1 = DatabaseMgr.connectDatasetGraph(Location.mem("FOO")); DatasetGraph dg2 = DatabaseMgr.connectDatasetGraph(Location.mem("FOO")); Txn.executeWrite(dg1, ()->{ dg1.add(quad1); }); Txn.executeRead(dg2, ()->{ assertTrue(dg2.contains(quad1)); }); }
@Test public void testDatabaseMgr2() { TDBInternal.reset(); DatasetGraph dg1 = DatabaseMgr.connectDatasetGraph(Location.mem()); DatasetGraph dg2 = DatabaseMgr.connectDatasetGraph(Location.mem()); Txn.executeWrite(dg1, ()->{ dg1.add(quad1); }); Txn.executeRead(dg2, ()->{ assertFalse(dg2.contains(quad1)); }); }
@Test public void testDatabaseMgrDisk() { TDBInternal.reset(); String DIRx = ConfigTest.getCleanDir(); Location LOC = Location.create(DIRx); FileOps.clearDirectory(DIRx); try { DatasetGraph dg1 = DatabaseMgr.connectDatasetGraph(LOC); DatasetGraph dg2 = DatabaseMgr.connectDatasetGraph(Location.create(LOC.getDirectoryPath())); assertSame(dg1, dg2); Txn.executeWrite(dg1, ()-> { dg1.add(quad1); }); Txn.executeRead(dg2, ()-> { assertTrue(dg2.contains(quad1)); }); } finally { FileOps.clearDirectory(DIRx); } }