Package org.apache.shindig.gadgets.uri.ProxyUriManager

Examples of org.apache.shindig.gadgets.uri.ProxyUriManager.ProxyUri


  private void verifyQueryUriWithRefresh(Uri orig, Uri uri, boolean debug, boolean noCache,
      String version, Integer refresh, String host, String path) throws Exception {
    // Make sure the manager can parse out results.
    DefaultProxyUriManager manager = makeManager(host, path, null);
    ProxyUri proxyUri = manager.process(uri);
    assertEquals(orig, proxyUri.getResource());
    assertEquals(debug, proxyUri.isDebug());
    assertEquals(noCache, proxyUri.isNoCache());
    assertEquals(noCache ? Integer.valueOf(0) : refresh, proxyUri.getRefresh());
    assertEquals(CONTAINER, proxyUri.getContainer());
    assertEquals(SPEC_URI.toString(), proxyUri.getGadget());

    // "Raw" query param verification.
    assertEquals(noCache || refresh == null ? null : refresh.toString(),
        uri.getQueryParameter(Param.REFRESH.getKey()));
    if (version != null) {
View Full Code Here


  private void verifyChainedUri(Uri orig, Uri uri, boolean debug, boolean noCache, String version,
      boolean endOfPath, String host, String path)
      throws Exception {
    // Make sure the manager can parse out results.
    DefaultProxyUriManager manager = makeManager(host, path, null);
    ProxyUri proxyUri = manager.process(uri);
    assertEquals(orig, proxyUri.getResource());
    assertEquals(debug, proxyUri.isDebug());
    assertEquals(noCache, proxyUri.isNoCache());
    assertEquals(noCache ? 0 : 123, (int)proxyUri.getRefresh());
    assertEquals(CONTAINER, proxyUri.getContainer());
    assertEquals(SPEC_URI.toString(), proxyUri.getGadget());

    // URI should end with the proxied content.
    String uriStr = uri.toString();
    assertTrue(uriStr.endsWith(orig.toString()));
View Full Code Here

    String host = "host.com";
    String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN;
    DefaultProxyUriManager uriManager = makeManager(host, path, null);
    Uri uri = Uri.parse("http://host.com/gadgets/proxy/refresh%3d55%26container%3dcontainer/"
        + "http://www.cnn.com/news?refresh=45");
    ProxyUri pUri = uriManager.process(uri);
    assertEquals(new Integer(55), pUri.getRefresh());
    assertEquals("http://www.cnn.com/news?refresh=45", pUri.getResource().toString());
    assertEquals(CONTAINER, pUri.getContainer());
  }
View Full Code Here

    String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN;
    DefaultProxyUriManager uriManager = makeManager(host, path, null);
    Uri uri = Uri.parse("http://host.com/gadgets/proxy/container%3dcontainer%26" +
        "gadget%3dhttp%3A%2F%2Fwww.orkut.com%2Fcss%2Fgen%2Fbase054.css.int%26" +
        "debug%3d0%26nocache%3d0/http://www.orkut.com/img/castro/i%5freply.gif");
    ProxyUri pUri = uriManager.process(uri);
    assertEquals(false, pUri.isDebug());
    assertEquals("http://www.orkut.com/img/castro/i%5freply.gif", pUri.getResource().toString());
    assertEquals(CONTAINER, pUri.getContainer());
    assertEquals("http://www.orkut.com/css/gen/base054.css.int", pUri.getGadget());
  }
View Full Code Here

    String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN;
    DefaultProxyUriManager uriManager = makeManager(host, path, null);
    Uri uri = Uri.parse("http://host.com/gadgets/proxy/container=container&" +
        "gadget=http%3A%2F%2Fwww.orkut.com%2Fcss%2Fgen%2Fbase054.css.int&" +
        "debug=0&nocache=0/http://www.orkut.com/img/castro/i_reply.gif");
    ProxyUri pUri = uriManager.process(uri);
    assertEquals(false, pUri.isDebug());
    assertEquals("http://www.orkut.com/img/castro/i_reply.gif", pUri.getResource().toString());
    assertEquals(CONTAINER, pUri.getContainer());
    assertEquals("http://www.orkut.com/css/gen/base054.css.int", pUri.getGadget());
  }
View Full Code Here

    expect(request.getIgnoreCache()).andStubReturn(true);
    expect(request.getImageParams()).andStubReturn(image);
    expect(request.getRewriteMimeType()).andStubReturn("image/png");
    expect(request.getSanitize()).andStubReturn(true);
    replay();
    ProxyUri pUri = gadgetHandler.createProxyUri(request);

    ProxyUri expectedUri = new ProxyUri(333, true, true, CONTAINER,
            FakeProcessor.SPEC_URL.toString(), RESOURCE);
    expectedUri.setRewriteMimeType("image/png").setSanitizeContent(true);
    expectedUri.setResize(210, 120, 77, true).setFallbackUrl(FALLBACK);
    assertEquals(pUri, expectedUri);
    verify();
  }
View Full Code Here

    expect(proxyUriManager.make(capture(uriCapture), EasyMock.anyInt())).andReturn(
            ImmutableList.of(resUri));
    replay();
    GadgetsHandlerApi.ProxyResponse response = gadgetHandler.getProxy(request);
    assertEquals(1, uriCapture.getValue().size());
    ProxyUri pUri = uriCapture.getValue().get(0);
    assertEquals(CONTAINER, pUri.getContainer());
    assertEquals(resUri, response.getProxyUrl());
    assertNull(response.getProxyContent());
    assertEquals(timeSource.currentTimeMillis() + HttpUtil.getDefaultTtl() * 1000, response
            .getExpireTimeMs().longValue());
    verify();
View Full Code Here

    HttpResponse httpResponse = builder.create();
    expect(proxyHandler.fetch(EasyMock.isA(ProxyUri.class))).andReturn(httpResponse);
    replay();
    GadgetsHandlerApi.ProxyResponse response = gadgetHandler.getProxy(request);
    assertEquals(1, uriCapture.getValue().size());
    ProxyUri pUri = uriCapture.getValue().get(0);
    assertEquals(CONTAINER, pUri.getContainer());
    assertNull(response.getProxyUrl());
    assertEquals("response",
            new String(Base64.decodeBase64(response.getProxyContent().getContentBase64())));
    assertEquals(20000L, response.getExpireTimeMs().longValue());
    verify();
View Full Code Here

    HttpResponse httpResponse = new HttpResponseBuilder().setHttpStatusCode(504).create();
    expect(proxyHandler.fetch(EasyMock.isA(ProxyUri.class))).andReturn(httpResponse);
    replay();
    GadgetsHandlerApi.ProxyResponse response = gadgetHandler.getProxy(request);
    assertEquals(1, uriCapture.getValue().size());
    ProxyUri pUri = uriCapture.getValue().get(0);
    assertEquals(CONTAINER, pUri.getContainer());
    assertNull(response.getProxyUrl());
    assertEquals("", response.getProxyContent().getContentBase64());
    assertEquals(504, response.getProxyContent().getCode());
    verify();
  }
View Full Code Here

    Capture<Uri> uriCapture = new Capture<Uri>();
    expect(uriManager.process(capture(uriCapture))).andReturn(proxyUri).once();
    replay(uriManager);

    SanitizingProxyUriManager rewriter = makeRewriter(null);
    ProxyUri returned = rewriter.process(uri);

    verify(uriManager);
    assertSame(uri, uriCapture.getValue());
    assertSame(returned, proxyUri);
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.uri.ProxyUriManager.ProxyUri

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.