Package org.apache.shindig.gadgets.http

Examples of org.apache.shindig.gadgets.http.HttpFetcher.fetch()


        break;
    }
    request.setMethod(method);

    HttpFetcher fetcher = new BasicHttpFetcher();
    HttpResponse response = fetcher.fetch(request);

    System.out.println("Request ------------------------------");
    System.out.println(request.toString());
    System.out.println("Response -----------------------------");
    System.out.println(response.toString());
View Full Code Here


    Uri location = Uri.parse("http://example.org/file.js");
    HttpRequest request = new HttpRequest(location);
    HttpResponse response = new HttpResponseBuilder()
        .setResponse(URL_JS.getBytes())
        .create();
    expect(mockFetcher.fetch(eq(request))).andReturn(response);
    replay();
    JsLibrary lib = JsLibrary.create(
        JsLibrary.Type.URL, location.toString(), null, mockFetcher);
    verify();
View Full Code Here

        break;
    }
    request.setMethod(method);

    HttpFetcher fetcher = new BasicHttpFetcher();
    HttpResponse response = fetcher.fetch(request);

    System.out.println("Request ------------------------------");
    System.out.println(request.toString());
    System.out.println("Response -----------------------------");
    System.out.println(response.toString());
View Full Code Here

  public void loadUriInlineFetcherFailure() throws Exception {
    Uri uri = Uri.parse("http://apache.org/resource.js");
    Map<String, String> attribs = Maps.newHashMap();
    attribs.put("inline", "true");
    HttpFetcher fetcher = createMock(HttpFetcher.class);
    expect(fetcher.fetch(eq(new HttpRequest(uri))))
        .andThrow(new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT));
    replay(fetcher);
    loader.setHttpFetcher(fetcher);
    FeatureResource resource = loader.load(uri, attribs);
    assertNull(resource.getContent());
View Full Code Here

    HttpFetcher fetcher = createMock(HttpFetcher.class);
    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);
    return fetcher;
  }
}
View Full Code Here

  public void loadUriInlineFetcherFailure() throws Exception {
    Uri uri = Uri.parse("http://apache.org/resource.js");
    Map<String, String> attribs = Maps.newHashMap();
    attribs.put("inline", "true");
    HttpFetcher fetcher = createMock(HttpFetcher.class);
    expect(fetcher.fetch(eq(new HttpRequest(uri))))
        .andThrow(new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT));
    replay(fetcher);
    loader.setHttpFetcher(fetcher);
    FeatureResource resource = loader.load(uri, attribs);
    assertNull(resource.getContent());
View Full Code Here

    HttpFetcher fetcher = createMock(HttpFetcher.class);
    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);
    return fetcher;
  }
}
View Full Code Here

        break;
    }
    request.setMethod(method);

    HttpFetcher fetcher = new BasicHttpFetcher(httpProxy);
    HttpResponse response = fetcher.fetch(request);

    System.out.println("Request ------------------------------");
    System.out.println(request.toString());
    System.out.println("Response -----------------------------");
    System.out.println(response.toString());
View Full Code Here

    Uri location = Uri.parse("http://example.org/file.js");
    HttpRequest request = new HttpRequest(location);
    HttpResponse response = new HttpResponseBuilder()
        .setResponse(URL_JS.getBytes())
        .create();
    expect(mockFetcher.fetch(eq(request))).andReturn(response);
    replay();
    JsLibrary lib = JsLibrary.create(
        JsLibrary.Type.URL, location.toString(), null, mockFetcher);
    verify();
View Full Code Here

      public HttpResponse removeResponse(HttpCacheKey key) {
        return null;
      }
    };
    HttpFetcher fetcher = new BasicHttpFetcher(nullCache);
    HttpResponse response = fetcher.fetch(request);

    System.out.println("Request ------------------------------");
    System.out.println(request.toString());
    System.out.println("Response -----------------------------");
    System.out.println(response.toString());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.