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

  HttpURLConnection conn = EasyMock.createMock(HttpURLConnection.class);
  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(
      "{ \"data\": \"bad\", \"vXUsers\": \"xyz\" }".getBytes()));
  expect(m_streamProvider.processURL((String) anyObject(), (String) anyObject(),
      (InputStream) anyObject(), (Map<String, List<String>>) anyObject())).andReturn(conn).anyTimes();
  replay(conn, m_streamProvider);
  PrerequisiteCheck check = new PrerequisiteCheck(null, null);
  m_rpc.perform(check, new PrereqCheckRequest("cluster"));
  String error = "The response from Ranger was malformed. ";
  error += "java.lang.String cannot be cast to java.util.List. ";
  error += "Request: " + RANGER_URL + "service/xusers/users?name=r_admin";
  assertEquals(PrereqCheckStatus.WARNING, check.getStatus());
  assertEquals(error, check.getFailReason());
  verify(conn, m_streamProvider);
}