Beispiel #1
0
  @Override
  public void run() {
    if (this.checkstyleFuture.isDone() && this.runResultFuture.isDone()) {
      try {
        RunResult tests = this.runResultFuture.get();
        Validations checks;
        try {
          checks = this.checkstyleFuture.get();
        } catch (ExecutionException ex) {
          if (ex.getCause() instanceof UnsupportedOperationException) {
            checks = new Validations();
            checks.setValidationErrors(new HashMap<String, List<ValidationError>>());
          } else {
            throw ex;
          }
        }

        if (tests.status == PASSED && !checks.getValidationErrors().isEmpty()) {
          output.write("All tests passed, but there are checkstyle errors.\n".getBytes());
          output.write(parseData(checks).getBytes());
          output.write("\n".getBytes());
          socket.close();
          return;
        }

        output.write(parseData(tests).getBytes());
        output.write(parseData(checks).getBytes());
        output.write("\n".getBytes());
        socket.close();

      } catch (InterruptedException | ExecutionException | IOException ex) {
        System.err.println(ex.getMessage());
        Logger.getLogger(TestsListener.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
  }