@Before
 public void setupDemoChannel() throws Exception {
   final SlingClient slingClient = new SlingClient(getServerBaseUrl(), ADMIN, ADMIN);
   try {
     slingClient.createNode(demoChannelPath, "sling:resourceType", "mediacenter:channel");
   } catch (Exception e) {
     fail("Exception while setting up DEMO channel: " + e);
   }
 }
  /**
   * Before running tests, setup a node that gives access to the Sling JUnit servlet, and check
   * (with timeout) that the servlet is ready
   */
  public SlingServerSideTestsBase() {
    if (!servletNodeCreated) {
      final SlingClient slingClient =
          new SlingClient(getServerBaseUrl(), getServerUsername(), getServerPassword());
      try {
        slingClient.createNode(SERVLET_NODE_PATH, "sling:resourceType", "sling/junit/testing");
        servletNodeCreated = true;
      } catch (Exception e) {
        fail("Exception while setting up Sling JUnit servlet: " + e);
      }
    }

    if (servletCheckFailed) {
      fail(SLING_JUNIT_SERVLET_PATH + " check failed previously, cannot run tests");
    }

    if (!servletOk) {
      final RetryingContentChecker servletChecker =
          new RetryingContentChecker(
              getRequestExecutor(), getRequestBuilder(), getServerUsername(), getServerPassword()) {
            @Override
            public void onTimeout() {
              servletCheckFailed = true;
            }

            @Override
            protected boolean assertMore(RequestExecutor e) throws Exception {
              e.assertContentContains("SlingJUnitServlet");
              return true;
            }
          };

      final String path = SLING_JUNIT_SERVLET_PATH;
      final int status = 200;
      final int timeout = TimeoutsProvider.getInstance().getTimeout(30);
      final int intervalMsec = TimeoutsProvider.getInstance().getTimeout(500);
      log.info(
          "Checking that {} returns status {}, timeout={} seconds",
          new Object[] {path, status, timeout});
      servletChecker.check(path, status, timeout, intervalMsec);
      servletOk = true;
      log.info("{} is ready, returns expected content", path);
    }
  }