/** Check if the generated site is linked correctly for multi module projects. */
  public void testMultiModuleSiteBuild() throws Exception {
    MavenModuleSet project = createProject("maven-multimodule-site.zip");
    project.setGoals("site");

    try {
      buildAndAssertSuccess(project);
    } catch (InterruptedException x) {
      // jglick: when using M2 this just hangs on my machine (pool-*-thread-* in
      // java.net.SocketInputStream.socketRead0); sometimes passes in M3, but not consistently, and
      // very very slowly when it does (network dependency)
      return; // TODO use JenkinsRule and throw AssumptionViolatedException
    }

    // this should succeed
    HudsonTestCase.WebClient wc = new WebClient();
    wc.getPage(project, "site");
    wc.getPage(project, "site/core");
    wc.getPage(project, "site/client");

    // @Bug(7577): check that site generation succeeds also if only a single module is build
    MavenModule coreModule = project.getModule("mmtest:core");
    Assert.assertEquals("site", coreModule.getGoals());
    try {
      buildAndAssertSuccess(coreModule);
    } catch (InterruptedException x) {
      return; // TODO as above
    }
    wc.getPage(project, "site/core");
  }
  /** Check if the the site goal will work when run from a slave. */
  @Bug(5943)
  public void testMultiModuleSiteBuildOnSlave() throws Exception {
    MavenModuleSet project = createProject("maven-multimodule-site.zip");
    project.setGoals("site");
    project.setAssignedLabel(createSlave().getSelfLabel());

    try {
      buildAndAssertSuccess(project);
    } catch (InterruptedException x) {
      return; // TODO as above
    }

    // this should succeed
    HudsonTestCase.WebClient wc = new WebClient();
    wc.getPage(project, "site");
    wc.getPage(project, "site/core");
    wc.getPage(project, "site/client");
  }
  public void testNestedMultiModuleSiteBuild() throws Exception {
    MavenModuleSet project = createProject("maven-nested-multimodule-site.zip");
    project.setGoals("site");

    try {
      buildAndAssertSuccess(project);
    } catch (InterruptedException x) {
      return; // TODO as above
    }

    // this should succeed
    HudsonTestCase.WebClient wc = new WebClient();
    wc.getPage(project, "site");
    wc.getPage(project, "site/core");
    wc.getPage(project, "site/client");
    wc.getPage(project, "site/client/nested1");
    wc.getPage(project, "site/client/nested1/nested2");
  }
  /** Evaluates the literal Jelly script passed as a parameter as HTML and returns the page. */
  protected HtmlPage evaluateAsHtml(String jellyScript) throws Exception {
    HudsonTestCase.WebClient wc = new WebClient();

    WebRequestSettings req = new WebRequestSettings(wc.createCrumbedUrl("eval"), POST);
    req.setRequestBody(
        "<j:jelly xmlns:j='jelly:core' xmlns:st='jelly:stapler' xmlns:l='/lib/layout' xmlns:f='/lib/form'>"
            + jellyScript
            + "</j:jelly>");
    Page page = wc.getPage(req);
    return (HtmlPage) page;
  }
  /** Check if the generated site is linked correctly. */
  @Bug(3497)
  public void testSiteBuild() throws Exception {
    MavenModuleSet project = createSimpleProject();
    project.setGoals("site");

    buildAndAssertSuccess(project);

    // this should succeed
    HudsonTestCase.WebClient wc = new WebClient();
    wc.getPage(project, "site");
    wc.assertFails(project.getUrl() + "site/no-such-file", HttpURLConnection.HTTP_NOT_FOUND);
  }