Package org.apache.shindig.gadgets.http

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


    public void appendTo(StringBuffer buffer) {
      buffer.append("eqRequest[]");
    }

    public boolean matches(Object obj) {
      HttpRequest match = (HttpRequest)obj;
      return (match.getMethod().equals(req.getMethod()) &&
          match.getUri().equals(req.getUri()) &&
          match.getAuthType().equals(req.getAuthType()) &&
          match.getPostBodyAsString().equals(req.getPostBodyAsString()) &&
          Objects.equal(match.getOAuthArguments(), req.getOAuthArguments()) &&
          match.getHeaders().equals(req.getHeaders()));
    }
View Full Code Here


  private void expectGetAndReturnBody(String response) throws Exception {
    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

    expectPostAndReturnBody(AuthType.NONE, postData, response);
  }

  private void expectPostAndReturnBody(AuthType authType, String postData, String response)
      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");
View Full Code Here

    expectPutAndReturnBody(AuthType.NONE, putData, response);
  }

  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))
View Full Code Here

  private void expectDeleteAndReturnBody(String response) throws Exception {
    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

  private void expectHead() throws Exception {
    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

  private void expectPatchAndReturnBody(String response) throws Exception {
    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

    assertTrue(rewriter.responseWasRewritten());
  }

  @Test
  public void testGetRequestWithUncommonStatusCode() throws Exception {
    HttpRequest req = new HttpRequest(REQUEST_URL);
    HttpResponse response = new HttpResponseBuilder()
        .setHttpStatusCode(HttpResponse.SC_CREATED)
        .setResponseString(RESPONSE_BODY)
        .create();
    expect(pipeline.execute(req)).andReturn(response);
View Full Code Here

    replay();

    handler.fetch(request, recorder);

    HttpRequest httpRequest = requestCapture.getValue();
    assertEquals("public,max-age=120", recorder.getHeader("Cache-Control"));
    assertEquals(120, httpRequest.getCacheTtl());
  }
View Full Code Here

      handler.fetch(request, recorder);
    } catch (GadgetException e) {
      // Expected - catch now occurs at the MakeRequestServlet level.
    }

    HttpRequest httpRequest = requestCapture.getValue();
    assertEquals(null, recorder.getHeader("Cache-Control"));
    assertEquals(-1, httpRequest.getCacheTtl());
  }
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.