### Question:
FSImage implements Closeable { public synchronized void saveNamespace(FSNamesystem source) throws IOException { saveNamespace(source, NameNodeFile.IMAGE, null); } FSImage(Configuration conf); protected  FSImage(Configuration conf,
                    Collection<URI> imageDirs,
                    List<URI> editsDirs); boolean hasRollbackFSImage(); FSEditLog getEditLog(); @VisibleForTesting void setEditLogForTesting(FSEditLog newLog); void initEditLog(StartupOption startOpt); long loadEdits(Iterable<EditLogInputStream> editStreams,
      FSNamesystem target); void saveLegacyOIVImage(FSNamesystem source, String targetDir,
      Canceler canceler); synchronized void updateStorageVersion(); synchronized void saveNamespace(FSNamesystem source); synchronized void saveNamespace(FSNamesystem source, NameNodeFile nnf,
      Canceler canceler); synchronized void saveDigestAndRenameCheckpointImage(NameNodeFile nnf,
      long txid, MD5Hash digest); @Override synchronized void close(); NNStorage getStorage(); int getLayoutVersion(); int getNamespaceID(); String getClusterID(); String getBlockPoolID(); synchronized long getLastAppliedTxId(); long getLastAppliedOrWrittenTxId(); void updateLastAppliedTxIdFromWritten(); long getMostRecentCheckpointTxId(); static final Log LOG; }### Answer:
@Test public void testDigest() throws IOException { Configuration conf = new Configuration(); MiniDFSCluster cluster = null; try { cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build(); DistributedFileSystem fs = cluster.getFileSystem(); fs.setSafeMode(SafeModeAction.SAFEMODE_ENTER); fs.saveNamespace(); fs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE); File currentDir = FSImageTestUtil.getNameNodeCurrentDirs(cluster, 0).get( 0); File fsimage = FSImageTestUtil.findNewestImageFile(currentDir .getAbsolutePath()); assertEquals(MD5FileUtils.readStoredMd5ForFile(fsimage), MD5FileUtils.computeMd5ForFile(fsimage)); } finally { if (cluster != null) { cluster.shutdown(); } } }