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

    String host = "host.com";
    String path = "/proxy/path";
    ProxyUriManager.Versioner versioner = makeVersioner(null, version);
    DefaultProxyUriManager manager = makeManager(host, path, versioner);
    List<ProxyUri> proxyUris = Lists.newLinkedList();
    proxyUris.add(new ProxyUri(refresh, debug, noCache, CONTAINER, SPEC_URI.toString(),
        RESOURCE_1));

    List<Uri> uris = manager.make(proxyUris, null);
    assertEquals(1, uris.size());
    verifyQueryUriWithRefresh(RESOURCE_1, uris.get(0), debug, noCache,
View Full Code Here

    Object responseObj = operation.execute(emptyFormItems, authContext, converter).get();
    JSONObject response = new JSONObject(converter.convertToString(responseObj));

    JSONObject gadget1 = response.getJSONObject(resUri);
    assertEquals(proxyUri, gadget1.getString("proxyUrl"));
    ProxyUri pUri = captureProxyUri.getValue().get(0);
    ProxyUri expectedUri = new ProxyUri(null, false, false, CONTAINER, null, Uri.parse(resUri));
    assertTrue(expectedUri.equals(pUri));
    assertFalse(gadget1.has("error"));
    verify();
  }
View Full Code Here

    Object responseObj = operation.execute(emptyFormItems, authContext, converter).get();
    JSONObject response = new JSONObject(converter.convertToString(responseObj));

    JSONObject gadget1 = response.getJSONObject(resUri);
    assertEquals(proxyUri, gadget1.getString("proxyUrl"));
    ProxyUri pUri = captureProxyUri.getValue().get(0);
    ProxyUri expectedUri = new ProxyUri(null, false, false, CONTAINER, null, Uri.parse(resUri));
    assertTrue(expectedUri.equals(pUri));
    assertEquals(
            responseData,
            new String(Base64.decodeBase64(((JSONObject) gadget1.get("proxyContent")).getString(
                    "contentBase64").getBytes())));
    assertFalse(gadget1.has("error"));
View Full Code Here

    Object responseObj = operation.execute(emptyFormItems, authContext, converter).get();
    JSONObject response = new JSONObject(converter.convertToString(responseObj));

    JSONObject gadget1 = response.getJSONObject(resUri);
    assertEquals(proxyUri, gadget1.getString("proxyUrl"));
    ProxyUri pUri = captureProxyUri.getValue().get(0);
    ProxyUri expectedUri = new ProxyUri(333, true, true, CONTAINER, GADGET1_URL, Uri.parse(resUri));
    expectedUri.setRewriteMimeType("text/xml").setSanitizeContent(true);
    expectedUri.setFallbackUrl(resUri).setResize(555, 444, 88, true);
    assertTrue(expectedUri.equals(pUri));
    assertFalse(gadget1.has("error"));
    verify();
  }
View Full Code Here

  @Test
  public void testDoGetWithOAuth() throws Exception {
    Map<String, String> options = new HashMap<String, String>();
    options.put("OAUTH_SERVICE_NAME", "example");
    ProxyUriManager.ProxyUri proxyUri = new ProxyUri(-1, false, true, "default", "http://example.org/gadget.xml", REQUEST_URL);
    proxyUri.setAuthType(AuthType.OAUTH);

    Uri uri = Uri.parse(BASIC_SYNTAX_URL + "&authz=oauth&OAUTH_SERVICE_NAME=example&container=default&gadget=http://example.org/gadget.xml");
    expect(proxyUriManager.process(uri)).andReturn(proxyUri);
    expect(request.getScheme()).andReturn(uri.getScheme());
    expect(request.getServerName()).andReturn(uri.getAuthority());
    expect(request.getServerPort()).andReturn(80);
    expect(request.getRequestURI()).andReturn(uri.getPath());
    expect(request.getQueryString()).andReturn(uri.getQuery());
    expect(request.getHeader("Host")).andReturn(uri.getAuthority());
    expect(request.getParameter("OAUTH_SERVICE_NAME")).andReturn("example");
    expect(request.getParameterNames()).andReturn(Collections.enumeration(options.keySet()));
    expect(lockedDomainService.isSafeForOpenProxy(uri.getAuthority())).andReturn(true);

    ProxyUriManager.ProxyUri pUri = new ProxyUri(-1, false, true, "default", "http://example.org/gadget.xml", REQUEST_URL);
    pUri.setAuthType(AuthType.OAUTH);
    pUri.setOAuthArguments(new OAuthArguments(AuthType.OAUTH, options));

    expect(proxyHandler.fetch(pUri)).andReturn(new HttpResponse(RESPONSE_BODY));
    replay();
    servlet.doGet(request, recorder);
    verify();
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.