@SuppressWarnings("unchecked")
@Test
public void testMissingProps() throws Exception {

  HttpURLConnection conn = EasyMock.createMock(HttpURLConnection.class);
  m_configMap.clear();
  PrerequisiteCheck check = new PrerequisiteCheck(null, null);
  m_rpc.perform(check, new PrereqCheckRequest("cluster"));
  assertEquals(PrereqCheckStatus.WARNING, check.getStatus());
  assertEquals("Could not check credentials.  Missing property admin-properties/policymgr_external_url", check.getFailReason());
  m_configMap.put("policymgr_external_url", RANGER_URL);
  check = new PrerequisiteCheck(null, null);
  m_rpc.perform(check, new PrereqCheckRequest("cluster"));
  assertEquals(PrereqCheckStatus.WARNING, check.getStatus());
  assertEquals("Could not check credentials.  Missing property ranger-env/admin_username", check.getFailReason());
  m_configMap.put("admin_username", "admin");
  check = new PrerequisiteCheck(null, null);
  m_rpc.perform(check, new PrereqCheckRequest("cluster"));
  assertEquals(PrereqCheckStatus.WARNING, check.getStatus());
  assertEquals("Could not check credentials.  Missing property ranger-env/admin_password", check.getFailReason());
  m_configMap.put("admin_password", "pass");
  check = new PrerequisiteCheck(null, null);
  m_rpc.perform(check, new PrereqCheckRequest("cluster"));
  assertEquals(PrereqCheckStatus.WARNING, check.getStatus());
  assertEquals("Could not check credentials.  Missing property ranger-env/ranger_admin_username", check.getFailReason());
  m_configMap.put("ranger_admin_username", "r_admin");
  check = new PrerequisiteCheck(null, null);
  m_rpc.perform(check, new PrereqCheckRequest("cluster"));
  assertEquals(PrereqCheckStatus.WARNING, check.getStatus());
  assertEquals("Could not check credentials.  Missing property ranger-env/ranger_admin_password", check.getFailReason());
  expect(conn.getResponseCode()).andReturn(200);
  expect(conn.getInputStream()).andReturn(new ByteArrayInputStream(GOOD_LOGIN_RESPONSE.getBytes()));
  expect(conn.getResponseCode()).andReturn(200);
  expect(conn.getInputStream()).andReturn(new ByteArrayInputStream(GOOD_USER_RESPONSE.getBytes()));
  expect(conn.getResponseCode()).andReturn(200);
  expect(conn.getInputStream()).andReturn(new ByteArrayInputStream(GOOD_LOGIN_RESPONSE.getBytes()));
  expect(m_streamProvider.processURL((String) anyObject(), (String) anyObject(),
      (InputStream) anyObject(), (Map<String, List<String>>) anyObject())).andReturn(conn).anyTimes();
  replay(conn, m_streamProvider);
  m_configMap.put("ranger_admin_password", "r_pass");
  check = new PrerequisiteCheck(null, null);
  m_rpc.perform(check, new PrereqCheckRequest("cluster"));
  assertEquals(PrereqCheckStatus.PASS, check.getStatus());
}