@Test
public void testInitWithUGIToken() throws IOException, URISyntaxException {

  Configuration conf = new Configuration();
  DummyFs fs = spy(new DummyFs());
  doReturn(null).when(fs).getDelegationToken(anyString());
  Token<TokenIdentifier> token = new Token<TokenIdentifier>(new byte[0],
      new byte[0], DummyFs.TOKEN_KIND, new Text("127.0.0.1:1234"));
  fs.ugi.addToken(token);
  fs.ugi.addToken(new Token<TokenIdentifier>(new byte[0], new byte[0],
      new Text("Other token"), new Text("127.0.0.1:8021")));
  assertEquals("wrong tokens in user", 2, fs.ugi.getTokens().size());
  fs.emulateSecurityEnabled = true;
  fs.initialize(new URI("dummyfs://127.0.0.1:1234"), conf);
  fs.tokenAspect.ensureTokenInitialized();
  // Select a token from ugi (not from the remote host), store it but don't
  // renew it
  verify(fs).setDelegationToken(token);
  verify(fs, never()).getDelegationToken(anyString());
  assertNull(Whitebox.getInternalState(fs.tokenAspect, "dtRenewer"));
  assertNull(Whitebox.getInternalState(fs.tokenAspect, "action"));
}