@Test
  public void testServerStatus() throws IOException {
    /**
     * Query the ambari server for the list of stacks.
     * A successful GET returns the list of stacks.
     * We should get a json like:
     * {
     *   "href" : "http://localhost:9995/api/v1/stacks",
     *   "items" : [
     *   {
     *     "href" : "http://localhost:9995/api/v1/stacks/HDP",
     *     "Stacks" : {
     *     "stack_name" : "HDP"
     *     }
     *   }
     *  ]
     * }
     */

    /**
     * Test URL for GETting the status of the ambari server
     */
    String stacksPath = "/api/v1/stacks";
    String stacksUrl = String.format(SERVER_URL_FORMAT, serverPort) + stacksPath;
    CloseableHttpClient httpClient = HttpClients.createDefault();
    HttpGet httpGet = new HttpGet(stacksUrl);
    httpGet.addHeader("Authorization", getBasicAdminAuthentication());
    httpGet.addHeader("X-Requested-By", "ambari");

    try {
      HttpResponse httpResponse = httpClient.execute(httpGet);
      int statusCode = httpResponse.getStatusLine().getStatusCode();

      assertEquals(HttpStatus.SC_OK, statusCode); // HTTP status code 200

      HttpEntity entity = httpResponse.getEntity();
      String responseBody = entity != null ? EntityUtils.toString(entity) : null;

      assertTrue(responseBody != null); // Make sure response body is valid

      JsonElement jsonElement = new JsonParser().parse(new JsonReader(new StringReader(responseBody)));

      assertTrue (jsonElement != null); // Response was a JSON string

      JsonObject jsonObject = jsonElement.getAsJsonObject();

      assertTrue (jsonObject.has("items"));  // Should have "items" entry

      JsonArray stacksArray = jsonObject.get("items").getAsJsonArray();

      assertTrue (stacksArray.size() > 0); // Should have at least one stack

    } finally {
      httpClient.close();
    }
  }
Waits for the ambari server to startup and then checks it's
status by querying /api/v1/stacks (does not touch the DB)
ambari-funtest/src/test/java/org/apache/ambari/funtest/server/tests/GetStacksTest.java