Package org.apache.shindig.gadgets.http

Examples of org.apache.shindig.gadgets.http.HttpResponseBuilder.create()


    UriUtils.copyResponseHeadersAndStatusCode(resp, builder, false, false,
        UriUtils.DisallowedHeaders.OUTPUT_TRANSFER_DIRECTIVES,
        UriUtils.DisallowedHeaders.CACHING_DIRECTIVES);

    HttpResponse response = builder.create();

    // Date is added by HttpResponse.
    assertEquals(3, response.getHeaders().size());
    Iterator<String> headers = response.getHeaders("hello").iterator();
    assertEquals("world1", headers.next());
View Full Code Here


    UriUtils.copyResponseHeadersAndStatusCode(resp, builder, false, true,
        UriUtils.DisallowedHeaders.OUTPUT_TRANSFER_DIRECTIVES,
        UriUtils.DisallowedHeaders.CACHING_DIRECTIVES);

    HttpResponse response = builder.create();
    assertEquals(2, response.getHeaders().size());
    assertEquals("world2", response.getHeader("hello"));
    assertEquals(5000, response.getHttpStatusCode());
  }
View Full Code Here

    UriUtils.copyResponseHeadersAndStatusCode(resp, builder, true, true,
        UriUtils.DisallowedHeaders.OUTPUT_TRANSFER_DIRECTIVES,
        UriUtils.DisallowedHeaders.CACHING_DIRECTIVES);

    HttpResponse response = builder.create();
    assertEquals(2, response.getHeaders().size());
    assertEquals("world2", response.getHeader("hello"));
    assertEquals(502, response.getHttpStatusCode());
  }
View Full Code Here

    UriUtils.copyResponseHeadersAndStatusCode(resp, builder, false, true,
        UriUtils.DisallowedHeaders.OUTPUT_TRANSFER_DIRECTIVES,
        UriUtils.DisallowedHeaders.CACHING_DIRECTIVES);

    HttpResponse response = builder.create();
    assertEquals(2, response.getHeaders().size());
    assertEquals("world2", response.getHeader("hello"));
    assertEquals(500, response.getHttpStatusCode());
  }
View Full Code Here

      final HttpResponseBuilder builder = new HttpResponseBuilder();
      builder.setStrictNoCache();
      builder.setHttpStatusCode(HttpResponse.SC_OK);
      builder.setHeader("Content-Type", "application/json");
      builder.setContent("{\"access_token\":\"xxx\",\"token_type\":\"Bearer\",\"expires_in\":\"1\",\"refresh_token\":\"yyy\",\"example_parameter\":\"example_value\"}");
      return builder.create();
    }
  }

  static class DummyMessageProvider implements Provider<OAuth2Message> {
    public OAuth2Message get() {
View Full Code Here

    params.setAznUrl("aznurl");
    OAuthRequestException e = new OAuthRequestException(OAuthError.BAD_OAUTH_CONFIGURATION, "whoa there cowboy");

    HttpResponseBuilder responseBuilder = new HttpResponseBuilder();
    params.addToResponse(responseBuilder, e);
    HttpResponse response = responseBuilder.create();
    assertEquals("BAD_OAUTH_CONFIGURATION", response.getMetadata().get("oauthError"));
    String errorText = response.getMetadata().get("oauthErrorText");
    checkStringContains("error text returned", errorText, "whoa there cowboy");
    assertEquals("aznurl", response.getMetadata().get("oauthApprovalUrl"));
    assertNotNull(response.getMetadata().get("oauthState"));
View Full Code Here

    params.addRequestTrace(null, null);
    params.addRequestTrace(null, null);

    HttpResponseBuilder responseBuilder = new HttpResponseBuilder();
    params.addToResponse(responseBuilder, e);
    HttpResponse response = responseBuilder.create();

    String errorText = response.getMetadata().get("oauthErrorText");
    assertEquals("whoa there cowboy", errorText);

    params.setSendTraceToClient(true);
View Full Code Here

    String errorText = response.getMetadata().get("oauthErrorText");
    assertEquals("whoa there cowboy", errorText);

    params.setSendTraceToClient(true);
    params.addToResponse(responseBuilder, e);
    response = responseBuilder.create();
    errorText = response.getMetadata().get("oauthErrorText");
    checkStringContains("includes error text", errorText, "whoa there cowboy");
    checkStringContains("Request 1 logged", errorText, "Sent request 1:\n\n");
    checkStringContains("Request 2 logged", errorText, "Sent request 2:\n\n");
  }
View Full Code Here

  @Test
  public void testAddEmptyParams() {
    HttpResponseBuilder responseBuilder = new HttpResponseBuilder();
    params.addToResponse(responseBuilder, null);
    HttpResponse response = responseBuilder.create();
    assertTrue(response.getMetadata().isEmpty());
  }

  @Test
  public void testSawErrorResponse() {
View Full Code Here

  private String verifyStrip(String body) {
    HttpResponseBuilder resp = new HttpResponseBuilder()
        .setHttpStatusCode(200)
        .setHeader("Date", "Date: Fri, 09 Jan 2009 00:35:08 GMT")
        .setResponseString(body);
    String out = OAuthResponseParams.filterSecrets(resp.create().toString());
    if (out.contains("oauth_token_secret")) {
      checkStringContains("should remove secret", out, "oauth_token_secret=REMOVED");
    }
    if (out.contains("oauth_session_handle")) {
      checkStringContains("should remove handle", out, "oauth_session_handle=REMOVED");
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.