DelegationTokenFetcher.main(new String[] { "-fs", uri.toString(), tokenFile }); Path p = new Path(fileSys.getWorkingDirectory(), tokenFile); assertTrue(!itr.hasNext()); DelegationTokenFetcher.main(new String[] { "-fs", uri.toString(), "--print", tokenFile }); DelegationTokenFetcher.main(new String[] { "-fs", uri.toString(), "--renew", tokenFile }); DelegationTokenFetcher.main(new String[] { "-fs", uri.toString(), "--cancel", tokenFile }); verify(dfs).renewDelegationToken(eq(t));
/** * try to fetch token without http server with IOException */ @Test public void testTokenFetchFail() throws Exception { try { DelegationTokenFetcher.main(new String[] { "-webservice=" + serviceUrl, tokenFile }); fail("Token fetcher shouldn't start in absense of NN"); } catch (IOException ex) { } }
private static void expectDelegationTokenFetcherExit(String[] args) { try { DelegationTokenFetcher.main(args); fail("should call exit"); } catch (ExitException e) { ExitUtil.resetFirstExitException(); } catch (Exception ex) { fail("expectDelegationTokenFetcherExit ex error " + ex); } }
DelegationTokenFetcher.main(new String[] { "-fs", uri.toString(), tokenFile }); Path p = new Path(fileSys.getWorkingDirectory(), tokenFile); assertTrue(!itr.hasNext()); DelegationTokenFetcher.main(new String[] { "--print", tokenFile }); DelegationTokenFetcher.main(new String[] { "--renew", tokenFile }); assertEquals(t, FakeRenewer.lastRenewed); FakeRenewer.reset(); DelegationTokenFetcher.main(new String[] { "--cancel", tokenFile }); assertEquals(t, FakeRenewer.lastCanceled); } finally {
/** * Call fetch token using http server */ @Test public void expectedTokenIsRetrievedFromHttp() throws Exception { bootstrap = startHttpServer(httpPort, testToken, serviceUrl); DelegationTokenFetcher.main(new String[] { "-webservice=" + serviceUrl, tokenFile }); Path p = new Path(fileSys.getWorkingDirectory(), tokenFile); Credentials creds = Credentials.readTokenStorageFile(p, conf); Iterator<Token<?>> itr = creds.getAllTokens().iterator(); assertTrue("token not exist error", itr.hasNext()); Token<?> fetchedToken = itr.next(); Assert.assertArrayEquals("token wrong identifier error", testToken.getIdentifier(), fetchedToken.getIdentifier()); Assert.assertArrayEquals("token wrong password error", testToken.getPassword(), fetchedToken.getPassword()); if (assertionError != null) throw assertionError; }