@Test public void altParamsProxyChainedStyle() throws Exception { checkChainedStyle(true, true, "version"); }
@Test public void basicProxyChainedStyleEndOfPath() throws Exception { checkChainedStyleEndOfPath(false, false, null); }
@Test public void basicProxyQueryStyle() throws Exception { checkQueryStyle(false, false, null); }
private List<Uri> makeAndGetWithRefresh(String host, String path, boolean debug, boolean noCache, List<Uri> resources, Integer refresh, String... version) { ProxyUriManager.Versioner versioner = makeVersioner(null, version); DefaultProxyUriManager manager = makeManager(host, path, versioner); Gadget gadget = mockGadget(debug, noCache); return manager.make( ProxyUriManager.ProxyUri.fromList(gadget, resources), refresh); }
private void checkChainedStyleEndOfPath(boolean debug, boolean noCache, String version) throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; List<Uri> resources = ImmutableList.of(RESOURCE_1); List<Uri> uris = makeAndGet(host, path, debug, noCache, resources, version); assertEquals(1, uris.size()); verifyChainedUri(RESOURCE_1, uris.get(0), debug, noCache, version, true, host, path); }
private void checkQueryStyle(boolean debug, boolean noCache, String version) throws Exception { String host = "host.com"; String path = "/proxy/path"; List<Uri> resources = ImmutableList.of(RESOURCE_1); List<Uri> uris = makeAndGet(host, path, debug, noCache, resources, version); assertEquals(1, uris.size()); verifyQueryUri(RESOURCE_1, uris.get(0), debug, noCache, version, host, path); }
public void verifyRefresh(boolean debug, boolean noCache, String version, Integer refresh) throws Exception { 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, version, refresh, host, path); }
@Test(expected = GadgetException.class) public void missingUrlChained() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath( "/proxy/container=" + CONTAINER + "/path/").toUri(); manager.process(testUri); }
@Test public void verifyAddedParamsChained() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path"; ProxyUriManager.Versioner versioner = makeVersioner(null, "version"); DefaultProxyUriManager manager = makeManager(host, path, versioner); List<ProxyUri> proxyUris = Lists.newLinkedList(); ProxyUri pUri = new ProxyUri(null, false, true, CONTAINER, SPEC_URI.toString(), RESOURCE_1); pUri.setResize(100, 10, 90, true); proxyUris.add(pUri); List<Uri> uris = manager.make(proxyUris, null); assertEquals(1, uris.size()); verifyChainedUri(RESOURCE_1, uris.get(0), false, true, null, false, host, path); // Verify added param: assertEquals("/proxy/container=container&gadget=http%3A%2F%2Fexample.com%2Fgadget.xml" + "&debug=0&nocache=1&v=version&resize_h=10&resize_w=100&resize_q=90&no_expand=1" + "/path/http://example.com/one.dat", uris.get(0).getPath()); }
@Test public void validateChainedStyleVersioned() throws Exception { checkValidate("/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path", UriStatus.VALID_VERSIONED, "version"); }
private List<Uri> makeAndGet(String host, String path, boolean debug, boolean noCache, List<Uri> resources, String... version) { return makeAndGetWithRefresh(host, path, debug, noCache, resources, 123, version); }
private List<Uri> makeAndGetWithRefresh(String host, String path, boolean debug, boolean noCache, List<Uri> resources, Integer refresh, String... version) { ProxyUriManager.Versioner versioner = makeVersioner(null, version); DefaultProxyUriManager manager = makeManager(host, path, versioner); Gadget gadget = mockGadget(debug, noCache); return manager.make( ProxyUriManager.ProxyUri.fromList(gadget, resources), refresh); }
public void verifyRefresh(boolean debug, boolean noCache, String version, Integer refresh) throws Exception { 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, version, refresh, host, path); }
private void checkChainedStyleEndOfPath(boolean debug, boolean noCache, String version) throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; List<Uri> resources = ImmutableList.<Uri>of(RESOURCE_1); List<Uri> uris = makeAndGet(host, path, debug, noCache, resources, version); assertEquals(1, uris.size()); verifyChainedUri(RESOURCE_1, uris.get(0), debug, noCache, version, true, host, path); }
@Test(expected = GadgetException.class) public void missingContainerParamChained() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath( "/proxy/refresh=123/path/http://foo.com").toUri(); manager.process(testUri); }
private void checkQueryStyle(boolean debug, boolean noCache, String version) throws Exception { String host = "host.com"; String path = "/proxy/path"; List<Uri> resources = ImmutableList.of(RESOURCE_1); List<Uri> uris = makeAndGet(host, path, debug, noCache, resources, version); assertEquals(1, uris.size()); verifyQueryUri(RESOURCE_1, uris.get(0), debug, noCache, version, host, path); }
@Test public void verifyAddedParamsChained() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path"; ProxyUriManager.Versioner versioner = makeVersioner(null, "version"); DefaultProxyUriManager manager = makeManager(host, path, versioner); List<ProxyUri> proxyUris = Lists.newLinkedList(); ProxyUri pUri = new ProxyUri(null, false, true, CONTAINER, SPEC_URI.toString(), RESOURCE_1); pUri.setExtensionParams(ImmutableMap.<String, String>of("test", "1")); pUri.setResize(100, 10, 90, true); proxyUris.add(pUri); List<Uri> uris = manager.make(proxyUris, null); assertEquals(1, uris.size()); verifyChainedUri(RESOURCE_1, uris.get(0), false, true, null, false, host, path); // Verify added param: assertEquals("/proxy/container=container&gadget=http%3A%2F%2Fexample.com%2Fgadget.xml" + "&debug=0&nocache=1&v=version&test=1&resize_h=10&resize_w=100&resize_q=90&no_expand=1" + "/path/http://example.com/one.dat", uris.get(0).getPath()); }
@Test public void validateChainedStyleVersioned() throws Exception { checkValidate("/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path", UriStatus.VALID_VERSIONED, "version"); }
private List<Uri> makeAndGet(String host, String path, boolean debug, boolean noCache, List<Uri> resources, String... version) { return makeAndGetWithRefresh(host, path, debug, noCache, resources, 123, version); }
private List<Uri> makeAndGetWithRefresh(String host, String path, boolean debug, boolean noCache, List<Uri> resources, Integer refresh, String... version) { ProxyUriManager.Versioner versioner = makeVersioner(null, version); DefaultProxyUriManager manager = makeManager(host, path, versioner); Gadget gadget = mockGadget(debug, noCache); return manager.make( ProxyUriManager.ProxyUri.fromList(gadget, resources), refresh); }