### Question:
DelegationTokenFetcher { @VisibleForTesting static void saveDelegationToken(Configuration conf, FileSystem fs, final String renewer, final Path tokenFile) throws IOException { Token<?> token = fs.getDelegationToken(renewer); Credentials cred = new Credentials(); cred.addToken(token.getKind(), token); cred.writeTokenStorageFile(tokenFile, conf); if (LOG.isDebugEnabled()) { LOG.debug("Fetched token " + fs.getUri() + " for " + token.getService() + " into " + tokenFile); } }  static void main(final String[] args);  }### Answer:
@Test(expected = IOException.class) public void testTokenFetchFail() throws Exception { WebHdfsFileSystem fs = mock(WebHdfsFileSystem.class); doThrow(new IOException()).when(fs).getDelegationToken(anyString()); Path p = new Path(f.getRoot().getAbsolutePath(), tokenFile); DelegationTokenFetcher.saveDelegationToken(conf, fs, null, p); }