@Test
  public void testTokenCreation() throws Exception {
    Token<AuthenticationTokenIdentifier> token = secretManager.generateToken("testuser");

    AuthenticationTokenIdentifier ident = new AuthenticationTokenIdentifier();
    Writables.getWritable(token.getIdentifier(), ident);
    assertEquals("Token username should match", "testuser", ident.getUsername());
    byte[] passwd = secretManager.retrievePassword(ident);
    assertTrue("Token password and password from secret manager should match",
      Bytes.equals(token.getPassword(), passwd));
  }
Basic server process for RPC authentication testing
hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java