@Before
  public void setUp() throws Exception {
    TEST_UTIL = new HBaseTestingUtil();
    // Override the connection registry to avoid spinning up a mini cluster for the connection below
    // to go through.
    TEST_UTIL.getConfiguration().set(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
      HConstants.ZK_CONNECTION_REGISTRY_CLASS);
    TEST_UTIL.startMiniZKCluster();
    // register token type for protocol
    SecurityInfo.addInfo(AuthenticationProtos.AuthenticationService.getDescriptor().getName(),
      new SecurityInfo("hbase.test.kerberos.principal",
        AuthenticationProtos.TokenIdentifier.Kind.HBASE_AUTH_TOKEN));
    // security settings only added after startup so that ZK does not require SASL
    Configuration conf = TEST_UTIL.getConfiguration();
    conf.set("hadoop.security.authentication", "kerberos");
    conf.set("hbase.security.authentication", "kerberos");
    conf.setBoolean(HADOOP_SECURITY_AUTHORIZATION, true);
    conf.set(RpcServerFactory.CUSTOM_RPC_SERVER_IMPL_CONF_KEY, rpcServerImpl);
    server = new TokenServer(conf, TEST_UTIL);
    serverThread = new Thread(server);
    Threads.setDaemonThreadRunning(serverThread,
      "TokenServer:" + server.getServerName().toString());
    // wait for startup
    while (!server.isStarted() && !server.isStopped()) {
      Thread.sleep(10);
    }
    server.rpcServer.refreshAuthManager(conf, new PolicyProvider() {
      @Override
      public Service[] getServices() {
        return new Service[] { new Service("security.client.protocol.acl",
          AuthenticationProtos.AuthenticationService.BlockingInterface.class) };
      }
    });
    ZKClusterId.setClusterId(server.getZooKeeper(), clusterId);
    secretManager = (AuthenticationTokenSecretManager) server.getSecretManager();
    while (secretManager.getCurrentKey() == null) {
      Thread.sleep(1);
    }
  }
Basic server process for RPC authentication testing
hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java