private static void feedDriverMavenKey(
     FileSystem fileSystem, DatabaseClient.Builder builder, String propertyValue) {
   String[] fields = StringUtils.split(propertyValue, ':');
   Preconditions.checkArgument(
       fields.length == 3,
       "Format is groupId:artifactId:version. Please check the property sonar.jdbc.driverMavenKey: "
           + propertyValue);
   MavenLocation location = MavenLocation.create(fields[0], fields[1], fields[2]);
   File file = fileSystem.locate(location);
   Preconditions.checkState(file.exists(), "Driver file does not exist: " + location);
   builder.setDriverFile(file);
 }
 private File prepareAddToCache(Version version, File file) {
   File to;
   if (version.isRelease()) {
     to = locateRelease(version);
   } else {
     // do not rename the file, as it can differ from version
     to = new File(fs.workspace(), file.getName());
     SNAPSHOTS.put(version, to);
   }
   if (to.exists()) {
     FileUtils.deleteQuietly(to);
   }
   return to;
 }
  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");
    }
  }
 private File locateRelease(Version version) {
   String filename = format("sonarqube-%s.zip", version.toString());
   return new File(fs.sonarInstallsDir(), filename);
 }