@Test public void compact_graph_2() {

    // graphs across compaction.
    DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(dir);
    Graph g = dsg.getDefaultGraph();
    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);
    Txn.executeRead(dsg, ()-> {
        assertEquals(2, g.size());
        assertTrue(g.contains(triple2));
    });
    // Check is not attached to the old graph.
    DatasetGraph dsgOld = StoreConnection.connectCreate(loc1).getDatasetGraph();
    Txn.executeWrite(dsgOld, ()->dsgOld.getDefaultGraph().delete(triple2));
    Txn.executeRead(dsg,     ()->assertTrue(g.contains(triple2)) );
    Txn.executeWrite(dsg,    ()->g.add(triple3));
    Txn.executeRead(dsgOld,  ()->assertFalse(dsgOld.getDefaultGraph().contains(triple3)) );
}