@Test
  public void testGetLogFileNamesExistingFailuresLessThanThreshold() throws Exception {
    final String expectedHostName = "c6401.ambari.apache.org";
    final String expectedComponentName = "DATANODE";
    final String expectedClusterName = "clusterone";

    EasyMockSupport mockSupport = new EasyMockSupport();

    LoggingRequestHelperFactory helperFactoryMock = mockSupport.createMock(LoggingRequestHelperFactory.class);

    Executor executorMock = mockSupport.createMock(Executor.class);

    Injector injectorMock =
      mockSupport.createMock(Injector.class);

    Configuration configurationMock =
      mockSupport.createMock(Configuration.class);

    // expect the executor to be called to execute the LogSearch request
    executorMock.execute(isA(LogSearchDataRetrievalService.LogSearchFileNameRequestRunnable.class));
    // executor should only be called once
    expectLastCall().once();

    expect(injectorMock.getInstance(LoggingRequestHelperFactory.class)).andReturn(helperFactoryMock);

    expect(configurationMock.getLogSearchMetadataCacheExpireTimeout()).andReturn(1).atLeastOnce();

    mockSupport.replayAll();

    LogSearchDataRetrievalService retrievalService = new LogSearchDataRetrievalService();
    retrievalService.setLoggingRequestHelperFactory(helperFactoryMock);
    retrievalService.setInjector(injectorMock);
    retrievalService.setConfiguration(configurationMock);
    // call the initialization routine called by the Google framework
    retrievalService.doStart();
    retrievalService.setExecutor(executorMock);
    // initialize the comopnent-based failure count to have a count > 0, but less than threshold (10)
    retrievalService.getComponentRequestFailureCounts().put(expectedComponentName, new AtomicInteger(5));


    assertEquals("Default request set should be empty", 0, retrievalService.getCurrentRequests().size());

    Set<String> resultSet = retrievalService.getLogFileNames(expectedComponentName, expectedHostName, expectedClusterName);

    assertNull("Inital query on the retrieval service should be null, since cache is empty by default", resultSet);
    assertEquals("Incorrect number of entries in the current request set", 1, retrievalService.getCurrentRequests().size());

    assertTrue("Incorrect HostComponent set on request set",
      retrievalService.getCurrentRequests().contains(expectedComponentName + "+" + expectedHostName));
    assertEquals("Incorrect size for failure counts for components, should be 0",
      1, retrievalService.getComponentRequestFailureCounts().size());
    assertEquals("Incorrect failure count for component",
      5, retrievalService.getComponentRequestFailureCounts().get(expectedComponentName).get());

    mockSupport.verifyAll();
  }
This test verifies the basic behavior of the
  LogSearchDataRetrievalServiceTest, and should
  verify the interaction with its dependencies, as
  well as the interaction with the LogSearch
  server.
ambari-server/src/test/java/org/apache/ambari/server/controller/logging/LogSearchDataRetrievalServiceTest.java