public static List<ProxyUri> fromList(Gadget gadget, List<Uri> uris) { List<ProxyUri> res = Lists.newArrayListWithCapacity(uris.size()); for (Uri uri : uris) { res.add(new ProxyUri(gadget, uri)); } return res; } }
public static List<ProxyUri> fromList(Gadget gadget, List<Uri> uris) { List<ProxyUri> res = Lists.newArrayListWithCapacity(uris.size()); for (Uri uri : uris) { res.add(new ProxyUri(gadget, uri)); } return res; } }
public static List<ProxyUri> fromList(Gadget gadget, List<Uri> uris) { List<ProxyUri> res = Lists.newArrayListWithCapacity(uris.size()); for (Uri uri : uris) { res.add(new ProxyUri(gadget, uri)); } return res; } }
private void setupNoArgsProxyRequestMock(String host, String url) throws Exception { request = new ProxyUriManager.ProxyUri( -1, false, false, ContainerConfig.DEFAULT_CONTAINER, null, url != null ? Uri.parse(url) : null); }
@Test(expected = GadgetException.class) public void testBadFallbackUrl() throws Exception { ProxyUri uri = new ProxyUri(null, false, false, "open", "http://example.com/gadget", Uri.parse("http://example.com/resource")); uri.setFallbackUrl("bad url"); uri.getFallbackUri(); // throws exception! }
@Test public void testFallbackUrl() throws Exception { ProxyUri uri = new ProxyUri(null, false, false, "open", "http://example.com/gadget", Uri.parse("http://example.com/resource")); uri.setFallbackUrl("http://example.com/fallback"); assertEquals("http://example.com/fallback", uri.getFallbackUri().toString()); }
@Test(expected = GadgetException.class) public void testBadFallbackUrl() throws Exception { ProxyUri uri = new ProxyUri(null, false, false, "open", "http://example.com/gadget", Uri.parse("http://example.com/resource")); uri.setFallbackUrl("bad url"); uri.getFallbackUri(); // throws exception! }
@Test public void testReturnOrigContentOnErrorTrueWhenAccelContainer() throws Exception { ProxyUriManager.ProxyUri proxyUri = new ProxyUriManager.ProxyUri( 0, true, false, "accel", "test", Uri.parse("http://www.example.org")); assertEquals("1", proxyUri.returnOriginalContentOnError); proxyUri = new ProxyUriManager.ProxyUri(getGadget("accel"), URI); assertEquals("1", proxyUri.returnOriginalContentOnError); } }
public String rewriteUri(ExternalReference ref, UriEffect effect, LoaderType loader, Map<String, ?> hints) { Uri resourceUri = Uri.fromJavaUri(ref.getUri()); if (contextUri != null) { resourceUri = contextUri.resolve(resourceUri); } ProxyUriManager.ProxyUri proxyUri = new ProxyUriManager.ProxyUri( stubGadget, resourceUri); return proxyUri.getResource().toString(); } };
public Uri parseAndNormalize(HttpRequest httpRequest) throws GadgetException { Gadget gadget = DomWalker.makeGadget(httpRequest); ProxyUriManager.ProxyUri proxied = looksLikeAccelUri(httpRequest.getUri()) ? proxyUriManager.process(httpRequest.getUri()) : new ProxyUriManager.ProxyUri( gadget, httpRequest.getUri()); return proxyUriManager.make(ImmutableList.of(proxied), 0).get(0); }
@Test public void testFallbackUrl() throws Exception { ProxyUri uri = new ProxyUri(null, false, false, "open", "http://example.com/gadget", Uri.parse("http://example.com/resource")); uri.setFallbackUrl("http://example.com/fallback"); assertEquals("http://example.com/fallback", uri.getFallbackUri().toString()); }
private void setupNoArgsProxyRequestMock(String host, String url) throws Exception { request = new ProxyUriManager.ProxyUri( -1, false, false, ContainerConfig.DEFAULT_CONTAINER, GADGET, url != null ? Uri.parse(url) : null); }
public String rewriteUri(ExternalReference ref, UriEffect effect, LoaderType loader, Map<String, ?> hints) { Uri resourceUri = Uri.fromJavaUri(ref.getUri()); if (contextUri != null) { resourceUri = contextUri.resolve(resourceUri); } ProxyUriManager.ProxyUri proxyUri = new ProxyUriManager.ProxyUri( stubGadget, resourceUri); return proxyUri.getResource().toString(); } };
@Test(expected = GadgetException.class) public void testBadFallbackUrl() throws Exception { ProxyUri uri = new ProxyUri(null, false, false, "open", "http://example.com/gadget", Uri.parse("http://example.com/resource")); uri.setFallbackUrl("bad url"); uri.getFallbackUri(); // throws exception! }
@Test public void testFallbackUrl() throws Exception { ProxyUri uri = new ProxyUri(null, false, false, "open", "http://example.com/gadget", Uri.parse("http://example.com/resource")); uri.setFallbackUrl("http://example.com/fallback"); assertEquals("http://example.com/fallback", uri.getFallbackUri().toString()); }
private void setupNoArgsProxyRequestMock(String host, String url) throws Exception { request = new ProxyUriManager.ProxyUri( -1, false, false, ContainerConfig.DEFAULT_CONTAINER, GADGET, url != null ? Uri.parse(url) : null); }
public ProxyUri process(Uri uri) throws GadgetException { String proxied = uri.getQueryParameter(Param.URL.getKey()); ProxyUri proxyUri = new ProxyUri(expectStatus, proxied != null ? Uri.parse(proxied) : null, uri); proxyUri.setHtmlTagContext(uri.getQueryParameter(Param.HTML_TAG_CONTEXT.getKey())); return proxyUri; }
private void setupProxyRequestMock(String host, String url, boolean noCache, int refresh, String rewriteMime, String fallbackUrl) throws Exception { request = new ProxyUriManager.ProxyUri( refresh, false, noCache, ContainerConfig.DEFAULT_CONTAINER, GADGET, Uri.parse(url)); request.setFallbackUrl(fallbackUrl); request.setRewriteMimeType(rewriteMime); }
@Test public void testReturnOrigContentOnErrorTrueWhenAccelContainer() throws Exception { ProxyUriManager.ProxyUri proxyUri = new ProxyUriManager.ProxyUri( 0, true, false, "accel", "test", Uri.parse("http://www.example.org")); assertEquals("1", proxyUri.returnOriginalContentOnError); proxyUri = new ProxyUriManager.ProxyUri(getGadget("accel"), URI); assertEquals("1", proxyUri.returnOriginalContentOnError); } }
public Uri parseAndNormalize(HttpRequest httpRequest) throws GadgetException { Gadget gadget = DomWalker.makeGadget(httpRequest); ProxyUriManager.ProxyUri proxied = looksLikeAccelUri(httpRequest.getUri()) ? proxyUriManager.process(httpRequest.getUri()) : new ProxyUriManager.ProxyUri( gadget, httpRequest.getUri()); return proxyUriManager.make(ImmutableList.of(proxied), 0).get(0); }