Package org.apache.shindig.gadgets.http

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


  public void testSignedGetRequest() throws Exception {
    JSONObject request = new JSONObject("{method:http.get, id:req1, params : {"
        + "href:'http://www.example.org/somecontent',"
        + "authz : 'signed' }"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");
    httpRequest.setAuthType(AuthType.SIGNED);
    httpRequest.setOAuthArguments(
        new OAuthArguments(AuthType.SIGNED, ImmutableMap.<String, String>of()));
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();
    replay();
    RpcHandler operation = registry.getRpcHandler(request);
View Full Code Here


    JSONObject request = new JSONObject("{method:http.post, id:req1, params : {"
        + "href:'http://www.example.org/somecontent',"
        + "body:'POSTBODY',"
        + "authz: 'signed' }"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("POST");
    httpRequest.setAuthType(AuthType.SIGNED);
    httpRequest.setOAuthArguments(
        new OAuthArguments(AuthType.SIGNED, ImmutableMap.<String, String>of()));
    httpRequest.setPostBody("POSTBODY".getBytes());
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();
    replay();
    RpcHandler operation = registry.getRpcHandler(request);

    HttpRequestHandler.HttpApiResponse httpApiResponse =
View Full Code Here

    JSONObject request = new JSONObject("{method:http.post, id:req1, params : {"
        + "href:'http://www.example.org/somecontent',"
        + "body:'POSTBODY',"
        + "authz: 'oauth' }"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("POST");
    httpRequest.setAuthType(AuthType.OAUTH);
    httpRequest.setOAuthArguments(
        new OAuthArguments(AuthType.OAUTH, ImmutableMap.<String, String>of()));
    httpRequest.setPostBody("POSTBODY".getBytes());
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();
    replay();
    RpcHandler operation = registry.getRpcHandler(request);

    operation.execute(emptyFormItems, token, converter).get();
View Full Code Here

        + "sign_owner:'false',"
        + "sign_viewer:'true',"
        + "oauth_service_name:'oauthService',"
        + "authz: 'oauth' }"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("POST");
    httpRequest.setAuthType(AuthType.OAUTH);
    OAuthArguments oauthArgs =
        new OAuthArguments(AuthType.OAUTH, ImmutableMap.<String, String>of());
    oauthArgs.setSignOwner(false);
    oauthArgs.setServiceName("oauthService");
    httpRequest.setOAuthArguments(oauthArgs);
    httpRequest.setPostBody("POSTBODY".getBytes());

    Capture<HttpRequest> requestCapture = new Capture<HttpRequest>();
    expect(pipeline.execute(capture(requestCapture))).andReturn(builder.create());
    replay();
    RpcHandler operation = registry.getRpcHandler(request);

    operation.execute(emptyFormItems, token, converter).get();
    verify();

    assertEquals(httpRequest.getOAuthArguments(),
        requestCapture.getValue().getOAuthArguments());
  }
View Full Code Here

    JSONObject request = new JSONObject("{method:http.post, id:req1, params : {"
        + "href:'http://www.example.org/somecontent',"
        + "body:'POSTBODY',"
        + "authz : 'rubbish' }"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("POST");
    httpRequest.setAuthType(AuthType.NONE);
    httpRequest.setPostBody("POSTBODY".getBytes());
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();
    replay();
    RpcHandler operation = registry.getRpcHandler(request);

    operation.execute(emptyFormItems, token, converter).get();
View Full Code Here

  public void testSignedGetRequestNoSecurityToken() throws Exception {
    JSONObject request = new JSONObject("{method:http.get, id:req1, params : {"
        + "href:'http://www.example.org/somecontent',"
        + "authz : 'signed'}"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");
    httpRequest.setAuthType(AuthType.SIGNED);
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();
    replay();
    RpcHandler operation = registry.getRpcHandler(request);

    try {
View Full Code Here

  @Test
  public void testBadHttpResponseIsPropagated() throws Exception {
    JSONObject request = new JSONObject("{method:http.get, id:req1, params : {"
        + "href:'http://www.example.org/somecontent'"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");
    httpRequest.setAuthType(AuthType.NONE);
    builder.setHttpStatusCode(HttpResponse.SC_INTERNAL_SERVER_ERROR);
    builder.setResponseString("I AM AN ERROR MESSAGE");
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();
    replay();
    RpcHandler operation = registry.getRpcHandler(request);
View Full Code Here

  @Test
  public void testMetadataCopied() throws Exception {
    JSONObject request = new JSONObject("{method:http.get, id:req1, params : {"
        + "href:'http://www.example.org/somecontent'"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");
    builder.setMetadata("foo", "CONTENT");
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();

    replay();
    RpcHandler operation = registry.getRpcHandler(request);
View Full Code Here

  @Test
  public void testSetCookiesReturned() throws Exception {
    JSONObject request = new JSONObject("{method:http.get, id:req1, params : {"
        + "href:'http://www.example.org/somecontent',"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");
    builder.addHeader("Set-Cookie", "foo=bar; Secure");
    builder.addHeader("Set-Cookie", "name=value");
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();

    replay();
View Full Code Here

  @Test
  public void testLocationReturned() throws Exception {
    JSONObject request = new JSONObject("{method:http.get, id:req1, params : {"
        + "href:'http://www.example.org/somecontent',"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");
    builder.addHeader("Location", "here");
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();

    replay();
    RpcHandler operation = registry.getRpcHandler(request);
View Full Code Here

TOP

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

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.