Examples of HttpResponseException


Examples of com.facebook.presto.jdbc.internal.jetty.client.HttpResponseException

        HttpExchange exchange = getHttpExchange();
        if (exchange != null)
        {
            HttpResponse response = exchange.getResponse();
            response.status(status).reason(reason);
            failAndClose(new HttpResponseException("HTTP protocol violation: bad response", response));
        }
    }
View Full Code Here

Examples of com.google.api.client.http.HttpResponseException

        GoogleTokenResponse tokenData = accessTokenContext.getTokenData();
        try {
            return invokeRequest(accessTokenContext);
        } catch (IOException ioe) {
            if (ioe instanceof HttpResponseException) {
                HttpResponseException googleException = (HttpResponseException)ioe;
                if (googleException.getStatusCode() == 400 && tokenData.getRefreshToken() != null) {
                    try {
                        // Refresh token and retry revocation with refreshed token
                        googleProcessor.refreshToken(accessTokenContext);
                        return invokeRequest(accessTokenContext);
                    } catch (OAuthException refreshException) {
View Full Code Here

Examples of org.apache.http.client.HttpResponseException

     */
    public String handleResponse(final HttpResponse response)
            throws HttpResponseException, IOException {
        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() >= 300) {
            throw new HttpResponseException(statusLine.getStatusCode(),
                    statusLine.getReasonPhrase());
        }

        HttpEntity entity = response.getEntity();
        return entity == null ? null : EntityUtils.toString(entity);
View Full Code Here

Examples of org.apache.http.client.HttpResponseException

  @Test (expected = ApplicationException.class)
  @SuppressWarnings("unchecked")
  public void failsWithApplicationExceptionOnInternalErrors() throws Exception {
    TestMusicBrainzClient client = getClient();
    when(client.getHttpClient().execute(any(HttpUriRequest.class),
        any(ResponseHandler.class))).thenThrow(new HttpResponseException(503, "NA"));

    client.get();
  }
View Full Code Here

Examples of org.apache.http.client.HttpResponseException

  @Test
  public void validatePackagingOfResponseCode404() throws ApplicationException, IOException {
    final int errorCode = 404;
    final String errorMessage = "Not found";
    HttpResponseException hpe = new HttpResponseException(errorCode, errorMessage);
    TestWSGetClient testWSClient = getTestWSClient(hpe);
    WSResponse response = testWSClient.testCall();
   
    Assert.assertTrue(response.wasCallAllowed());
    Assert.assertFalse(response.wasCallSuccessful());
View Full Code Here

Examples of org.apache.http.client.HttpResponseException

  @Test
  public void validatePackagingOfResponseCode503() throws ApplicationException, IOException {
    final int errorCode = 503;
    final String errorMessage = "Service temporary unavailable";
    HttpResponseException hpe = new HttpResponseException(errorCode, errorMessage);
    TestWSGetClient testWSClient = getTestWSClient(hpe);
    WSResponse response = testWSClient.testCall();
   
    Assert.assertTrue(response.wasCallAllowed());
    Assert.assertFalse(response.wasCallSuccessful());
View Full Code Here

Examples of org.apache.http.client.HttpResponseException

  public void handlesArtistFailureDuringUpdate() throws ApplicationException {
    final String revName = reverse(artistName);
    submitFile(additionDao, getFile(revName, albumName, trackName));
   
    Mockito.when(service.artistQueryClient.get(revName)).thenThrow(
      new ApplicationException("Fail", new HttpResponseException(503, "Overloaded")));
   
    service.updateDiscography();
   
    List<MBAlbum> albums = service.getMissingAlbums(artistName, asList(TYPE_EP), null, -1, 0);
    Assert.assertEquals(2, albums.size());
View Full Code Here

Examples of org.apache.http.client.HttpResponseException

     */
    public String handleResponse(final HttpResponse response)
            throws HttpResponseException, IOException {
        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() >= 300) {
            throw new HttpResponseException(statusLine.getStatusCode(),
                    statusLine.getReasonPhrase());
        }

        HttpEntity entity = response.getEntity();
        return entity == null ? null : EntityUtils.toString(entity);
View Full Code Here

Examples of org.apache.http.client.HttpResponseException

     */
    public String handleResponse(final HttpResponse response)
            throws HttpResponseException, IOException {
        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() >= 300) {
            throw new HttpResponseException(statusLine.getStatusCode(),
                    statusLine.getReasonPhrase());
        }

        HttpEntity entity = response.getEntity();
        return entity == null ? null : EntityUtils.toString(entity);
View Full Code Here

Examples of org.apache.http.client.HttpResponseException

    HttpGet httpget = new HttpGet(uri);
    HttpResponse response = httpclient.execute(httpget);
    StatusLine statusline = response.getStatusLine();
    if (statusline.getStatusCode() >= HttpStatus.SC_BAD_REQUEST) {
      httpget.abort();
      throw new HttpResponseException(
          statusline.getStatusCode(), statusline.getReasonPhrase());
    }
    HttpEntity entity = response.getEntity();
    if (entity == null) {
      // Should _almost_ never happen with HTTP GET requests.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.