public static void testConnection()

in commit-status-publisher-server/src/main/java/jetbrains/buildServer/commitPublisher/tfs/TfsStatusPublisher.java [238:270]


  public static void testConnection(@NotNull final VcsRoot root,
                                    @NotNull final Map<String, String> params,
                                    @NotNull final String commitId,
                                    @Nullable final KeyStore trustStore,
                                    @NotNull HttpCredentials credentials) throws PublisherException {
    if (!TfsConstants.GIT_VCS_ROOT.equals(root.getVcsName())) {
      throw new PublisherException("Status publisher supports only Git VCS roots");
    }

    final TfsRepositoryInfo info = getServerAndProject(root, params);
    try {
      final String url = MessageFormat.format(COMMIT_STATUS_URL_FORMAT,
        info.getServer(), info.getProject(), info.getRepository(), commitId);
      LoggerUtil.logRequest(TfsConstants.ID, HttpMethod.POST, url, StringUtil.EMPTY);
      IOGuard.allowNetworkCall(() -> {
        HttpHelper.post(url, credentials, StringUtil.EMPTY, ContentType.DEFAULT_TEXT,
                        Collections.singletonMap("Accept", "application/json"), BaseCommitStatusPublisher.DEFAULT_CONNECTION_TIMEOUT,
                        trustStore, new DefaultHttpResponseProcessor() {
            @Override
            public void processResponse(HttpHelper.HttpResponse response) throws HttpPublisherException {
              // Ignore Bad Request for POST check
              if (response.getStatusCode() == 400) {
                return;
              }
              checkResponseStatus(response);
            }
          });
      });
    } catch (Exception e) {
      final String message = FAILED_TO_TEST_CONNECTION_TO_REPOSITORY + info;
      throw new PublisherException(message, e);
    }
  }