DelegationTokenFetcher { @VisibleForTesting static void saveDelegationToken(Configuration conf, FileSystem fs, final String renewer, final Path tokenFile) throws IOException { Token<?> token = fs.getDelegationToken(renewer); if (null != token) { Credentials cred = new Credentials(); cred.addToken(token.getService(), token); cred.writeTokenStorageFile(tokenFile, conf, Credentials.SerializedFormat.WRITABLE); if (LOG.isDebugEnabled()) { LOG.debug("Fetched token " + fs.getUri() + " for " + token.getService() + " into " + tokenFile); } } else { System.err.println("ERROR: Failed to fetch token from " + fs.getUri()); } }  static void main(final String[] args); @VisibleForTesting static void main(Configuration conf, final String[] args); @VisibleForTesting static String printTokensToString(
      final Configuration conf,
      final Path tokenFile,
      final boolean verbose);  }
@Test(expected = IOException.class) public void testTokenFetchFail() throws Exception { WebHdfsFileSystem fs = mock(WebHdfsFileSystem.class); doThrow(new IOException()).when(fs).getDelegationToken(any()); Path p = new Path(f.getRoot().getAbsolutePath(), tokenFile); DelegationTokenFetcher.saveDelegationToken(conf, fs, null, p); }