@Test public void compact_dsg_1() {

    DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(dir);
    DatasetGraphSwitchable dsgs = (DatasetGraphSwitchable)dsg;
    DatasetGraph dsg1 = dsgs.get();
    Location loc1 = ((DatasetGraphTDB)dsg1).getLocation();
    Txn.executeWrite(dsg, ()-> {
        dsg.add(quad2);
        dsg.add(quad1);
    });
    DatabaseMgr.compact(dsg);
    assertFalse(StoreConnection.isSetup(loc1));
    DatasetGraph dsg2 = dsgs.get();
    Location loc2 = ((DatasetGraphTDB)dsg2).getLocation();
    assertNotEquals(dsg1, dsg2);
    assertNotEquals(loc1, loc2);
    Txn.executeRead(dsg, ()-> {
        assertTrue(dsg.contains(quad2));
        assertTrue(dsg.contains(quad1));
    });
    // dsg1 was closed and expelled. We must carefully reopen its storage only.
    DatasetGraph dsgOld = StoreConnection.connectCreate(loc1).getDatasetGraph();
    Txn.executeWrite(dsgOld, ()->dsgOld.delete(quad2));
    Txn.executeRead(dsg,     ()->assertTrue(dsg.contains(quad2)) );
    Txn.executeRead(dsg2,    ()->assertTrue(dsg2.contains(quad2)) );
}