@Test
public void testAction() throws Exception {

  Map<String, String> commandParams = new HashMap<String, String>();
  commandParams.put("clusterName", "c1");
  ExecutionCommand executionCommand = new ExecutionCommand();
  executionCommand.setCommandParams(commandParams);
  executionCommand.setClusterName("c1");
  HostRoleCommand hrc = EasyMock.createMock(HostRoleCommand.class);
  expect(hrc.getRequestId()).andReturn(1L).anyTimes();
  expect(hrc.getStageId()).andReturn(2L).anyTimes();
  expect(hrc.getExecutionCommandWrapper()).andReturn(new ExecutionCommandWrapper(executionCommand)).anyTimes();
  replay(hrc);
  RangerKerberosConfigCalculation action = new RangerKerberosConfigCalculation();
  m_clusterField.set(action, m_clusters);
  action.setExecutionCommand(executionCommand);
  action.setHostRoleCommand(hrc);
  CommandReport report = action.execute(null);
  assertNotNull(report);
  Cluster c = m_clusters.getCluster("c1");
  Config config = c.getDesiredConfigByType("ranger-admin-site");
  Map<String, String> map = config.getProperties();
  assertTrue(map.containsKey("ranger.plugins.hdfs.serviceuser"));
  assertTrue(map.containsKey("ranger.plugins.hive.serviceuser"));
  assertTrue(map.containsKey("ranger.plugins.yarn.serviceuser"));
  assertTrue(map.containsKey("ranger.plugins.hbase.serviceuser"));
  assertTrue(map.containsKey("ranger.plugins.knox.serviceuser"));
  assertTrue(map.containsKey("ranger.plugins.storm.serviceuser"));
  assertTrue(map.containsKey("ranger.plugins.kafka.serviceuser"));
  assertTrue(map.containsKey("ranger.plugins.kms.serviceuser"));
  assertTrue(map.containsKey("ranger.spnego.kerberos.keytab"));
  assertEquals("hdfs", map.get("ranger.plugins.hdfs.serviceuser"));
  assertEquals("hive", map.get("ranger.plugins.hive.serviceuser"));
  assertEquals("yarn", map.get("ranger.plugins.yarn.serviceuser"));
  assertEquals("hbase", map.get("ranger.plugins.hbase.serviceuser"));
  assertEquals("knox", map.get("ranger.plugins.knox.serviceuser"));
  assertEquals("storm-c1,storm", map.get("ranger.plugins.storm.serviceuser"));
  assertEquals("kafka", map.get("ranger.plugins.kafka.serviceuser"));
  assertEquals("kms", map.get("ranger.plugins.kms.serviceuser"));
  assertEquals("/etc/security/keytabs/spnego.kytab", map.get("ranger.spnego.kerberos.keytab"));
  report = action.execute(null);
  assertNotNull(report);
}