@Test
public void testLogLevelRequestBasic() throws Exception {

  LoggingCookieStore.INSTANCE.getCookiesMap().clear();
  EasyMockSupport mockSupport =
    new EasyMockSupport();
  CredentialStoreService credentialStoreServiceMock =
    mockSupport.createMock(CredentialStoreService.class);
  Cluster clusterMock =
    mockSupport.createMock(Cluster.class);
  LoggingRequestHelperImpl.NetworkConnection networkConnectionMock =
    mockSupport.createMock(LoggingRequestHelperImpl.NetworkConnection.class);
  Config adminPropertiesConfigMock =
    mockSupport.createMock(Config.class);
  Map<String, String> testConfigProperties =
    new HashMap<String, String>();
  testConfigProperties.put("logsearch_admin_username", "admin-user");
  testConfigProperties.put("logsearch_admin_password", "admin-pwd");
  testConfigProperties = Collections.unmodifiableMap(testConfigProperties);
  Capture<HttpURLConnection> captureURLConnection = EasyMock.newCapture();
  Capture<HttpURLConnection> captureURLConnectionForAuthentication = EasyMock.newCapture();
  expect(clusterMock.getDesiredConfigByType("logsearch-admin-json")).andReturn(adminPropertiesConfigMock).atLeastOnce();
  expect(adminPropertiesConfigMock.getProperties()).andReturn(testConfigProperties).atLeastOnce();
  expect(networkConnectionMock.readQueryResponseFromServer(capture(captureURLConnection))).andReturn(new StringBuffer(TEST_JSON_INPUT_LOG_LEVEL_QUERY)).atLeastOnce();
  // expect that basic authentication is setup, with the expected encoded credentials
  networkConnectionMock.setupBasicAuthentication(capture(captureURLConnectionForAuthentication), eq(EXPECTED_ENCODED_CREDENTIALS));
  mockSupport.replayAll();
  LoggingRequestHelper helper =
    new LoggingRequestHelperImpl(EXPECTED_HOST_NAME, EXPECTED_PORT_NUMBER, EXPECTED_PROTOCOL, credentialStoreServiceMock, clusterMock, networkConnectionMock);
  // invoke query request
  LogLevelQueryResponse result =
    helper.sendLogLevelQueryRequest("hdfs_datanode", EXPECTED_HOST_NAME);
  // verify that the HttpURLConnection was created with the proper values
  HttpURLConnection httpURLConnection =
    captureURLConnection.getValue();
  assertEquals("URLConnection did not have the correct hostname information",
    EXPECTED_HOST_NAME, httpURLConnection.getURL().getHost());
  assertEquals("URLConnection did not have the correct port information",
    EXPECTED_PORT_NUMBER, httpURLConnection.getURL().getPort() + "");
  assertEquals("URLConnection did not have the expected http protocol scheme",
    "http", httpURLConnection.getURL().getProtocol());
  assertEquals("URLConnection did not have the expected method set",
    "GET", httpURLConnection.getRequestMethod());
  assertSame("HttpUrlConnection instances passed into NetworkConnection mock should have been the same instance",
    httpURLConnection, captureURLConnectionForAuthentication.getValue());
  assertNotNull("Response object should not be null",
    result);
  // expected values taken from JSON input string declared above
  assertEquals("startIndex not parsed properly",
    "0", result.getStartIndex());
  assertEquals("pageSize not parsed properly",
    "0", result.getPageSize());
  assertEquals("totalCount not parsed properly",
    "0", result.getTotalCount());
  assertEquals("resultSize not parsed properly",
    "6", result.getResultSize());
  assertEquals("queryTimeMS not parsed properly",
    "1459970731998", result.getQueryTimeMS());
  assertEquals("Incorrect number of log level count items parsed",
    6, result.getNameValueList().size());
  List<NameValuePair> resultList =
    result.getNameValueList();
  assertNameValuePair("FATAL", "0", resultList.get(0));
  assertNameValuePair("ERROR", "0", resultList.get(1));
  assertNameValuePair("WARN", "41", resultList.get(2));
  assertNameValuePair("INFO", "186", resultList.get(3));
  assertNameValuePair("DEBUG", "0", resultList.get(4));
  assertNameValuePair("TRACE", "0", resultList.get(5));
  mockSupport.verifyAll();
}