@Test
  public void test() throws Exception {
    assertTrue(
        "SonarQube 5.1 is the minimum version to generate the issues report, change your orchestrator.properties",
        orchestrator.getConfiguration().getSonarVersion().isGreaterThanOrEquals("5.1"));
    File litsDifferencesFile = FileLocation.of("target/differences").getFile();
    SonarRunner build =
        SonarRunner.create(FileLocation.of("../sources/src").getFile())
            .setProjectKey("project")
            .setProjectName("project")
            .setProjectVersion("1")
            .setLanguage("js")
            .setSourceDirs("./")
            .setSourceEncoding("utf-8")
            .setProfile("rules")
            .setProperty("sonar.analysis.mode", "preview")
            .setProperty("sonar.issuesReport.html.enable", "true")
            .setProperty(
                "dump.old", FileLocation.of("src/test/expected").getFile().getAbsolutePath())
            .setProperty("dump.new", FileLocation.of("target/actual").getFile().getAbsolutePath())
            .setProperty("lits.differences", litsDifferencesFile.getAbsolutePath())
            .setProperty("sonar.cpd.skip", "true")
            .setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Xmx1024m");
    orchestrator.executeBuild(build);

    assertThat(Files.toString(litsDifferencesFile, StandardCharsets.UTF_8)).isEmpty();
  }
 private static String keyFor(String s) {
   return "project:"
       + (orchestrator.getConfiguration().getSonarVersion().isGreaterThanOrEquals("4.2")
           ? "src/"
           : "")
       + s;
 }
  @Before
  public void copyGuavaJar() {
    MavenLocation guava = MavenLocation.of("com.google.guava", "guava", "10.0.1");
    File subFolder = new File(tmp.getRoot(), "subFolder");
    File subSubFolder = new File(subFolder, "subSubFolder");
    new MavenLocator(ORCHESTRATOR.getConfiguration()).copyToDirectory(guava, subSubFolder);

    aarPath =
        new File(new File(TestUtils.projectDir("using-aar-dep"), "lib"), "cache-1.3.0.aar")
            .getAbsolutePath();
    guavaJarPath = new File(subSubFolder.getAbsolutePath(), guava.getFilename()).getAbsolutePath();
    fakeGuavaJarPath =
        new File(new File(TestUtils.projectDir("dit-check"), "lib"), "fake-guava-1.0.jar")
            .getAbsolutePath();
  }
  private void runConcurrentIssues() throws InterruptedException, ExecutionException {
    // Install sonar-runner in advance to avoid concurrent unzip issues
    FileSystem fileSystem = orchestrator.getConfiguration().fileSystem();
    new SonarRunnerInstaller(fileSystem)
        .install(Version.create(SonarRunner.DEFAULT_RUNNER_VERSION), fileSystem.workspace());
    final int nThreads = 3;
    ExecutorService executorService = Executors.newFixedThreadPool(nThreads);
    List<Callable<BuildResult>> tasks = new ArrayList<>();
    for (int i = 0; i < nThreads; i++) {
      tasks.add(
          new Callable<BuildResult>() {

            public BuildResult call() throws Exception {
              SonarRunner runner = configureRunnerIssues("shared/xoo-sample");
              return orchestrator.executeBuild(runner);
            }
          });
    }

    boolean expectedError = false;
    for (Future<BuildResult> result : executorService.invokeAll(tasks)) {
      try {
        result.get();
      } catch (ExecutionException e) {
        if (e.getCause() instanceof BuildFailureException) {
          BuildFailureException bfe = (BuildFailureException) e.getCause();
          assertThat(bfe.getResult().getLogs())
              .contains("Another SonarQube analysis is already in progress for this project");
          expectedError = true;
        }
      }
    }
    if (!expectedError) {
      fail("At least one of the threads should have failed");
    }
  }
 public static boolean is_after_plugin(String version) {
   return ORCHESTRATOR
       .getConfiguration()
       .getPluginVersion(PLUGIN_KEY)
       .isGreaterThanOrEquals(version);
 }
 public static boolean isCheckstyleAtLeast_2_3() {
   return ORCHESTRATOR
       .getConfiguration()
       .getPluginVersion("checkstyle")
       .isGreaterThanOrEquals("2.3");
 }