Package org.apache.shindig.gadgets.http

Examples of org.apache.shindig.gadgets.http.HttpResponse


    client.setTrustedParam("xoauth_magic", "quux_overridden");
    client.setTrustedParam("xoauth_magic", "quux");

    client.setTrustedParam("opensocial_owner_id", "overridden_opensocial_owner_id");

    HttpResponse response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
    assertEquals("", response.getResponseAsString());
    client.approveToken("user_data=hello-oauth");

    response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
    assertEquals("User data is hello-oauth", response.getResponseAsString());
    assertEquals(12, serviceProvider.getTrustedParamCount());
  }
View Full Code Here


    client.setTrustedParam("opensocial_magic", "bar");
    client.setTrustedParam("xoauth_magic", "quux");

    client.setTrustedParam("opensocial_owner_id", "overridden_opensocial_owner_id");

    HttpResponse response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
    assertEquals("", response.getResponseAsString());
    client.approveToken("user_data=hello-oauth");

    response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
    assertEquals("User data is hello-oauth", response.getResponseAsString());
    assertEquals(12, serviceProvider.getTrustedParamCount());
  }
View Full Code Here

    client.setTrustedParam("opensocial_magic", "bar");
    client.setTrustedParam("xoauth_magic", "quux");
    client.setTrustedParam("opensocial_owner_id", "overridden_opensocial_owner_id");
    client.setTrustedParam("invalid_trusted_parameter", "invalid");

    HttpResponse response = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
    assertEquals(HttpResponse.SC_FORBIDDEN, response.getHttpStatusCode());
  }
View Full Code Here

    out.close();
  }

  private void mockFetcher(Uri toFetch, String content) throws Exception {
    HttpRequest req = new HttpRequest(toFetch);
    HttpResponse resp =
        new HttpResponseBuilder().setHttpStatusCode(HttpResponse.SC_OK)
                                 .setResponseString(content).create();
    expect(fetcher.fetch(eq(req))).andReturn(resp);
    replay(fetcher);
  }
View Full Code Here

    expectGetAndReturnBody(AuthType.NONE, response);
  }

  private void expectGetAndReturnBody(AuthType authType, String response) throws Exception {
    HttpRequest request = new HttpRequest(REQUEST_URL).setAuthType(authType);
    expect(pipeline.execute(request)).andReturn(new HttpResponse(response));
  }
View Full Code Here

      throws Exception {
    HttpRequest req = new HttpRequest(REQUEST_URL).setMethod("POST")
        .setPostBody(postData.getBytes("UTF-8"))
        .setAuthType(authType)
        .addHeader("Content-Type", "application/x-www-form-urlencoded");
    expect(pipeline.execute(req)).andReturn(new HttpResponse(response));
    expect(request.getParameter(MakeRequestHandler.METHOD_PARAM)).andReturn("POST");
    expect(request.getParameter(MakeRequestHandler.POST_DATA_PARAM))
        .andReturn(postData);
  }
View Full Code Here

  private void expectPutAndReturnBody(AuthType authType, String putData, String response)
          throws Exception {
    HttpRequest req = new HttpRequest(REQUEST_URL).setMethod("PUT")
        .setPostBody(putData.getBytes("UTF-8"))
        .setAuthType(authType);
    expect(pipeline.execute(req)).andReturn(new HttpResponse(response));
    expect(request.getParameter(MakeRequestHandler.METHOD_PARAM)).andReturn("PUT");
    expect(request.getParameter(MakeRequestHandler.POST_DATA_PARAM))
        .andReturn(putData);
  }
View Full Code Here

    expectDeleteAndReturnBody(AuthType.NONE, response);
  }

  private void expectDeleteAndReturnBody(AuthType authType, String response) throws Exception {
    HttpRequest req = new HttpRequest(REQUEST_URL).setMethod("DELETE").setAuthType(authType);
    expect(pipeline.execute(req)).andReturn(new HttpResponse(response));
    expect(request.getParameter(MakeRequestHandler.METHOD_PARAM)).andReturn("DELETE");
  }
View Full Code Here

    expectHead(AuthType.NONE);
  }

  private void expectHead(AuthType authType) throws Exception {
    HttpRequest req = new HttpRequest(REQUEST_URL).setMethod("HEAD").setAuthType(authType);
    expect(pipeline.execute(req)).andReturn(new HttpResponse(""));
    expect(request.getParameter(MakeRequestHandler.METHOD_PARAM)).andReturn("HEAD");
  }
View Full Code Here

    expectPatchAndReturnBody(AuthType.NONE, response);
  }

  private void expectPatchAndReturnBody(AuthType authType, String response) throws Exception {
    HttpRequest req = new HttpRequest(REQUEST_URL).setMethod("PATCH").setAuthType(authType);
    expect(pipeline.execute(req)).andReturn(new HttpResponse(response));
    expect(request.getParameter(MakeRequestHandler.METHOD_PARAM)).andReturn("PATCH");
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.http.HttpResponse

Copyright © 2018 www.massapicom. 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.