@Test
  public void testGetTailFileWhenHelperIsAvailable() throws Exception {
    final String expectedHostName = "c6401.ambari.apache.org";
    final String expectedComponentName = "DATANODE";
    final String expectedClusterName = "clusterone";
    final String expectedResultURI = "http://localhost/test/result";

    EasyMockSupport mockSupport = new EasyMockSupport();

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

    LoggingRequestHelper helperMock =
      mockSupport.createMock(LoggingRequestHelper.class);

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

    expect(helperFactoryMock.getHelper(null, expectedClusterName)).andReturn(helperMock);
    expect(helperMock.createLogFileTailURI("http://localhost", expectedComponentName, expectedHostName)).andReturn(expectedResultURI);
    expect(configurationMock.getLogSearchMetadataCacheExpireTimeout()).andReturn(1).atLeastOnce();

    mockSupport.replayAll();

    LogSearchDataRetrievalService retrievalService = new LogSearchDataRetrievalService();
    retrievalService.setLoggingRequestHelperFactory(helperFactoryMock);
    retrievalService.setConfiguration(configurationMock);
    // call the initialization routine called by the Google framework
    retrievalService.doStart();

    String resultTailFileURI =
      retrievalService.getLogFileTailURI("http://localhost", expectedComponentName, expectedHostName, expectedClusterName);

    assertEquals("TailFileURI was not returned as expected", expectedResultURI, resultTailFileURI);

    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