Package org.apache.shindig.gadgets.http

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


  @Test
  public void testGetWithValidGadget() 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");
    mockGadget(new ArrayList<Feature>(), "default","http://www.example.com/gadget.xml");
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();
    expect(mockProcessor.process(EasyMock.isA(GadgetContext.class))).andReturn(mockGadget);

    replay();
View Full Code Here


  @Test
  public void testGetWithValidGadgeWithProcessorExceptiont() 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");
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();
    expect(mockProcessor.process(EasyMock.isA(GadgetContext.class))).andThrow(
            new ProcessingException("error", HttpServletResponse.SC_BAD_REQUEST)).anyTimes();

    replay();
View Full Code Here

  @Test
  public void testSimpleGet() 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");
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();

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

  public void testFailGetWithBodyGet() throws Exception {
    JSONObject request = new JSONObject("{method:http.get, id:req1, params : {"
        + "href:'http://www.example.org/somecontent',"
        + "body:'POSTBODY'"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");
    RpcHandler operation = registry.getRpcHandler(request);
    try {
      operation.execute(emptyFormItems, token, converter).get();
      fail("Body should not be allowed in GET request");
    } catch (ExecutionException ee) {
View Full Code Here

  public void testSimplePost() throws Exception {
    JSONObject request = new JSONObject("{method:http.post, id:req1, params : {"
        + "href:'http://www.example.org/somecontent',"
        + "body:'POSTBODY'"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("POST");
    httpRequest.setPostBody("POSTBODY".getBytes());
    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',"
        + "headers:{goodheader:[good], host : [iamstripped], 'Content-Length':['1000']}"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("POST");
    httpRequest.setPostBody("POSTBODY".getBytes());
    httpRequest.setHeader("goodheader", "good");
    httpRequest.setHeader("Content-Length", "1000");
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();

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

                 "<description>" + entrySummary + "</description>" +
                 "</item>" +
                 "</channel></rss>";
    builder.setResponseString(rss);

    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");

    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();

    replay();
View Full Code Here

                 "</item>" +
                 "</channel></rss>";

    builder.setResponseString(rss);

    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");

    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();

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

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

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

  @Test
  public void testJsonArrayGet() throws Exception {
    JSONObject request = new JSONObject("{method:http.get, id:req1, params : {"
        + "href:'http://www.example.org/somecontent', format:'json'"
        + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");
    builder.setResponseString("[{key:1},{key:2}]");
    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.