private void checkMissingHostConfig(ConcatUriManager.Type type) throws Exception { Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager(null, "/foo", "token", null); List<List<Uri>> resourceUris = ImmutableList.of(RESOURCES_ONE); manager.make(fromList(gadget, resourceUris, type), true); }
private void checkMissingPathConfig(ConcatUriManager.Type type) throws Exception { Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager("host.com", null, "token", null); List<List<Uri>> resourceUris = ImmutableList.of(RESOURCES_ONE); manager.make(fromList(gadget, resourceUris, type), false); }
@Test(expected = RuntimeException.class) public void typeJsMissingPathConfig() throws Exception { Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager("host.com", null, "token", null); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(ImmutableList.of(RESOURCE_1)); manager.make(fromList(gadget, resourceUris, ConcatUriManager.Type.JS), false); }
@Test(expected = RuntimeException.class) public void typeJsMissingHostConfig() throws Exception { Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager(null, "/foo", "token", null); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(ImmutableList.of(RESOURCE_1)); manager.make(fromList(gadget, resourceUris, ConcatUriManager.Type.JS), false); }
@Test(expected = RuntimeException.class) public void typeJsMissingHostConfig() throws Exception { Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager(null, "/foo", "token", null); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(ImmutableList.of(RESOURCE_1)); manager.make(fromList(gadget, resourceUris, ConcatUriManager.Type.JS), false); }
@Test(expected = RuntimeException.class) public void typeJsMissingPathConfig() throws Exception { Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager("host.com", null, "token", null); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(ImmutableList.of(RESOURCE_1)); manager.make(fromList(gadget, resourceUris, ConcatUriManager.Type.JS), false); }
@Test(expected = RuntimeException.class) public void typeJsMissingHostConfig() throws Exception { Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager(null, "/foo", "token", null); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(ImmutableList.of(RESOURCE_1)); manager.make(fromList(gadget, resourceUris, ConcatUriManager.Type.JS), false); }
private void checkBatchInsufficientVersions(ConcatUriManager.Type type) throws Exception { Gadget gadget = mockGadget(true, true); String host = "bar.com"; String path = "/other/path"; String[] versions = new String[] { "v1" }; // Only one for three resources. ConcatUriManager.Versioner versioner = makeVersioner(null, versions); DefaultConcatUriManager manager = makeManager(host, path, "token", versioner); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(RESOURCES_ONE, RESOURCES_ONE); manager.make(fromList(gadget, resourceUris, type), true); }
@Test(expected = UnsupportedOperationException.class) public void typeCssSplitNotSupported() throws Exception { // Unique to type=CSS, split isn't supported. Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager("host.com", "/foo", "token", null); List<List<Uri>> resourceUris = ImmutableList.of(RESOURCES_ONE); manager.make(fromList(gadget, resourceUris, ConcatUriManager.Type.CSS), false); }
@Test public void typeJsMissingSplitTokenConfig() throws Exception { Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager("host.com", "/foo", null, null); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(ImmutableList.of(RESOURCE_1)); List<ConcatData> concatUris = manager.make(fromList(gadget, resourceUris, ConcatUriManager.Type.JS), false); assertEquals(1, concatUris.size()); assertEquals(1, concatUris.get(0).getUris().size()); assertNull(concatUris.get(0).getUris().get(0).getQueryParameter(Param.JSON.getKey())); }
@Test public void typeJsMissingSplitTokenConfig() throws Exception { Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager("host.com", "/foo", null, null); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(ImmutableList.of(RESOURCE_1)); List<ConcatData> concatUris = manager.make(fromList(gadget, resourceUris, ConcatUriManager.Type.JS), false); assertEquals(1, concatUris.size()); assertEquals(1, concatUris.get(0).getUris().size()); assertNull(concatUris.get(0).getUris().get(0).getQueryParameter(Param.JSON.getKey())); }
@Test public void typeJsMissingSplitTokenConfig() throws Exception { Gadget gadget = mockGadget(false, false); DefaultConcatUriManager manager = makeManager("host.com", "/foo", null, null); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(ImmutableList.of(RESOURCE_1)); List<ConcatData> concatUris = manager.make(fromList(gadget, resourceUris, ConcatUriManager.Type.JS), false); assertEquals(1, concatUris.size()); assertNull(concatUris.get(0).getUri().getQueryParameter(Param.JSON.getKey())); }
@Test public void validateNoContainer() { DefaultConcatUriManager manager = makeManager("host.com", "/path", null, null); ConcatUriManager.ConcatUri validated = manager.process(Uri.parse("http://host.com/path?q=f")); assertEquals(UriStatus.BAD_URI, validated.getStatus()); }
@Test public void validateNoContainer() { DefaultConcatUriManager manager = makeManager("host.com", "/path", null, null); ConcatUriManager.ConcatUri validated = manager.process(Uri.parse("http://host.com/path?q=f")); assertEquals(UriStatus.BAD_URI, validated.getStatus()); }
@Test public void validateNullTypeUri() { DefaultConcatUriManager manager = makeManager("host.com", "/path", null, null); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat")); assertEquals(UriStatus.BAD_URI, validated.getStatus()); }
@Test public void validateInvalidChildUri() { DefaultConcatUriManager manager = makeManager("host.com", "/path", null, null); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=!!!")); assertEquals(UriStatus.BAD_URI, validated.getStatus()); }
@Test public void validateNoContainerStrict() { DefaultConcatUriManager manager = makeManager("host.com", "/path", null, null); manager.setUseStrictParsing(true); ConcatUriManager.ConcatUri validated = manager.process(Uri.parse("http://host.com/path?q=f")); assertEquals(UriStatus.BAD_URI, validated.getStatus()); }
@Test public void validateHostMismatchStrict() { DefaultConcatUriManager manager = makeManager("host.com", "/path", null, null); manager.setUseStrictParsing(true); ConcatUriManager.ConcatUri validated = manager.process(Uri.parse("http://another.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&type=css")); assertEquals(UriStatus.BAD_URI, validated.getStatus()); }
@Test public void validateHostMismatchStrict() { DefaultConcatUriManager manager = makeManager("host.com", "/path", null, null); manager.setUseStrictParsing(true); ConcatUriManager.ConcatUri validated = manager.process(Uri.parse("http://another.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&type=css")); assertEquals(UriStatus.BAD_URI, validated.getStatus()); }
@Test public void validateOldStyleTypeUri() { DefaultConcatUriManager manager = makeManager("host.com", "/path", null, null); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&" + Param.TYPE.getKey() + "=NOTATYPE&rewriteMime=text/css")); assertEquals(UriStatus.VALID_UNVERSIONED, validated.getStatus()); assertEquals(ConcatUriManager.Type.CSS, validated.getType()); }