@Test
public void testDeserializeHAToken() throws IOException {

  Configuration conf = DFSTestUtil.newHAConfiguration(LOGICAL_NAME);
  DataNode dn = mock(DataNode.class);
  doReturn(conf).when(dn).getConf();
  ServletContext context = mock(ServletContext.class);
  doReturn(dn).when(context).getAttribute("datanode");
  final Token<DelegationTokenIdentifier> token = new
          Token<DelegationTokenIdentifier>();
  DatanodeWebHdfsMethods method = new DatanodeWebHdfsMethods();
  Whitebox.setInternalState(method, "context", context);
  final Token<DelegationTokenIdentifier> tok2 = method.deserializeToken
          (token.encodeToUrlString(), LOGICAL_NAME);
  Assert.assertTrue(HAUtil.isTokenForLogicalUri(tok2));
}