@Private
  @VisibleForTesting
  public int getPort() {
    return this.getListenerAddress().getPort();
  }
@Test
  @Timeout(240000)
  void testHostedUIs() throws Exception {

    ApplicationHistoryServer historyServer = new ApplicationHistoryServer();
    Configuration config = new YarnConfiguration();
    config.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE,
        MemoryTimelineStore.class, TimelineStore.class);
    config.setClass(YarnConfiguration.TIMELINE_SERVICE_STATE_STORE_CLASS,
        MemoryTimelineStateStore.class, TimelineStateStore.class);
    config.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
        "localhost:0");
    final String UI1 = "UI1";
    String connFileStr = "";

    File diskFile = new File("./pom.xml");
    String diskFileStr = readInputStream(new FileInputStream(diskFile));
    try {
      config.set(YarnConfiguration.TIMELINE_SERVICE_UI_NAMES, UI1);
      config.set(YarnConfiguration.TIMELINE_SERVICE_UI_WEB_PATH_PREFIX + UI1,
          "/" + UI1);
      config.set(YarnConfiguration.TIMELINE_SERVICE_UI_ON_DISK_PATH_PREFIX
          + UI1, "./");
      historyServer.init(config);
      historyServer.start();
      URL url = new URL("http://localhost:" + historyServer.getPort() + "/"
          + UI1 + "/pom.xml");
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.connect();
      assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
      connFileStr = readInputStream(conn.getInputStream());
    } finally {
      historyServer.stop();
    }
    assertEquals(diskFileStr, connFileStr,
        "Web file contents should be the same as on disk contents");
  }