Package org.apache.shindig.gadgets.http

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


    specFactory.getGadgetSpec(createContext(SPEC_URL, false));
  }

  @Test(expected = GadgetException.class)
  public void throwingPipelineRethrows() throws Exception {
    HttpRequest request = createIgnoreCacheRequest();
    expect(pipeline.execute(request)).andThrow(
        new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT));
    replay(pipeline);

    specFactory.getGadgetSpec(createContext(SPEC_URL, true));
View Full Code Here


  private final ProxyHandler proxyHandler
      = new ProxyHandler(pipeline, rewriterRegistry, true, gadgetAdminStore, LONG_LIVED_REFRESH);

  private void expectGetAndReturnData(String url, byte[] data) throws Exception {
    HttpRequest req = new HttpRequest(Uri.parse(url));
    HttpResponse resp = new HttpResponseBuilder().setResponse(data).create();
    expect(pipeline.execute(req)).andReturn(resp);
  }
View Full Code Here

    expect(pipeline.execute(req)).andReturn(resp);
  }

  private void expectGetAndReturnHeaders(String url, Map<String, List<String>> headers)
      throws Exception {
    HttpRequest req = new HttpRequest(Uri.parse(url));
    HttpResponse resp = new HttpResponseBuilder().addAllHeaders(headers).create();
    expect(pipeline.execute(req)).andReturn(resp);
  }
View Full Code Here

    String domain = "example.org";

    setupProxyRequestMock(domain, url, true, -1, null, null);
    setupGadgetAdminMock(true);

    HttpRequest req = new HttpRequest(Uri.parse(url))
        .setIgnoreCache(true);
    String contentType = "text/html; charset=UTF-8";
    HttpResponse resp = new HttpResponseBuilder()
        .setResponseString("Hello")
        .addHeader("Content-Type", contentType)
View Full Code Here

    String fallback_url = "http://fallback.com/fallback.png";

    setupProxyRequestMock(domain, url, true, -1, null, fallback_url);
    setupGadgetAdminMock(true);

    HttpRequest req = new HttpRequest(Uri.parse(url)).setIgnoreCache(true);
    HttpResponse resp = HttpResponse.error();
    HttpResponse fallback_resp = new HttpResponse("Fallback");
    expect(pipeline.execute(req)).andReturn(resp);
    expect(pipeline.execute(isA(HttpRequest.class))).andReturn(fallback_resp);
View Full Code Here

    String domain = "example.org";

    setupProxyRequestMock(domain, url, true, -1, null, null);
    setupGadgetAdminMock(true);

    HttpRequest req = new HttpRequest(Uri.parse(url)).setIgnoreCache(true);
    HttpResponse resp = new HttpResponse("Hello");
    expect(pipeline.execute(req)).andReturn(resp);

    replay();
    proxyHandler.fetch(request);
View Full Code Here

    HttpResponse.setTimeSource(new FakeTimeSource());

    setupProxyRequestMock(domain, url, false, 120, null, null);
    setupGadgetAdminMock(true);

    HttpRequest req = new HttpRequestCache(Uri.parse(url)).setCacheTtl(120).setIgnoreCache(false);
    HttpResponseBuilder resp = new HttpResponseBuilder().setCacheTtl(1234);
    resp.setContent("Hello");
    expect(pipeline.execute(req)).andReturn(resp.create());

    replay();
View Full Code Here

    HttpResponse.setTimeSource(new FakeTimeSource());

    setupProxyRequestMock(domain, url, false, -1, null, null);
    setupGadgetAdminMock(true);

    HttpRequest req = new HttpRequestCache(Uri.parse(url)).setCacheTtl(-1).setIgnoreCache(false);
    HttpResponseBuilder resp = new HttpResponseBuilder().setCacheTtl(1234);
    resp.setContent("Hello");
    expect(pipeline.execute(req)).andReturn(resp.create());

    replay();
View Full Code Here

    String domain = "example.org";

    setupProxyRequestMock(domain, url, false, -1, expectedMime, null);
    setupGadgetAdminMock(true);

    HttpRequest req = new HttpRequest(Uri.parse(url))
        .setRewriteMimeType(expectedMime);

    HttpResponse resp = new HttpResponseBuilder()
      .setResponseString("Hello")
      .addHeader("Content-Type", contentMime)
View Full Code Here

        return true;
      }
      if (!(obj instanceof HttpRequest)) {
        return false;
      }
      HttpRequest req = (HttpRequest)obj;
      return super.equals(obj) && req.getCacheTtl() == getCacheTtl() &&
              req.getIgnoreCache() == getIgnoreCache();
    }
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.