ConcatUriManager.ConcatUri concatUri = concatUriManager.process(uri); ConcatUriManager.Type concatType = concatUri.getType(); try { if (concatType == null) {
ConcatUriManager.ConcatUri concatUri = concatUriManager.process(uri); ConcatUriManager.Type concatType = concatUri.getType(); try { if (concatType == null) {
ConcatUriManager.ConcatUri concatUri = concatUriManager.process(uri); ConcatUriManager.Type concatType = concatUri.getType(); try { if (concatType == null) {
private ConcatData makeConcatUri(ConcatUri ctx, boolean isAdjacent, String container) { if (!isAdjacent && ctx.getType() != Type.JS) { ctx.getType()); uris.add(uriBuilder.toUri()); addVersionAndSplitParam(uriBuilder, splitParam, doSplit, batchUris, container, ctx.getType()); uris.add(uriBuilder.toUri());
private ConcatData makeConcatUri(ConcatUri ctx, boolean isAdjacent, String version) { if (!isAdjacent && ctx.getType() != Type.JS) { uriBuilder.setPath(concatPath); uriBuilder.addQueryParameter(Param.TYPE.getKey(), ctx.getType().getType()); List<Uri> resourceUris = ctx.getBatch(); Map<Uri, String> snippets = Maps.newHashMapWithExpectedSize(resourceUris.size());
private ConcatData makeConcatUri(ConcatUri ctx, boolean isAdjacent, String version) { if (!isAdjacent && ctx.getType() != Type.JS) { uriBuilder.setPath(concatPath); uriBuilder.addQueryParameter(Param.TYPE.getKey(), ctx.getType().getType()); List<Uri> resourceUris = ctx.getBatch(); Map<Uri, String> snippets = Maps.newHashMapWithExpectedSize(resourceUris.size());
private void checkUnversionedUri(ConcatUriManager.Type type, boolean hasSplit) { // Returns VALID_VERSIONED, but no version is present. ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(UriStatus.VALID_UNVERSIONED, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
private void checkValidateUri(UriStatus status, ConcatUriManager.Type type, boolean hasSplit) { ConcatUriManager.Versioner versioner = makeVersioner(status); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.VERSION.getKey() + "=something&" + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(status, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
private void checkValidatedBatchAdjacent(ConcatUriManager.Type type) throws Exception { // This is essentially the "integration" test ensuring that a // DefaultConcatUriManager's created Uris can be validated by it in turn. Gadget gadget = mockGadget(true, true); String host = "bar.com"; String path = "/other/path"; String[] versions = new String[] { "version1", "v2", "v3" }; ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED, versions); DefaultConcatUriManager manager = makeManager(host, path, "token", versioner); List<List<Uri>> resourceUris = ImmutableList.<List<Uri>>of(RESOURCES_ONE, RESOURCES_TWO, RESOURCES_ONE); List<ConcatData> concatUris = manager.make(fromList(gadget, resourceUris, type), true); assertEquals(3, concatUris.size()); for (int i = 0; i < 3; ++i) { ConcatUriManager.ConcatUri validated = manager.process(concatUris.get(i).getUri()); assertEquals(UriStatus.VALID_VERSIONED, validated.getStatus()); List<Uri> resList = (i % 2 == 0) ? RESOURCES_ONE : RESOURCES_TWO; assertEquals(resList, validated.getBatch()); assertEquals(type, validated.getType()); } }
private void checkValidatedBatchAdjacent(ConcatUriManager.Type type) throws Exception { // This is essentially the "integration" test ensuring that a // DefaultConcatUriManager's created Uris can be validated by it in turn. Gadget gadget = mockGadget(true, true); String host = "bar.com"; String path = "/other/path"; String[] versions = new String[] { "version1"}; ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED, versions); DefaultConcatUriManager manager = makeManager(host, path, "token", versioner); List<List<Uri>> resourceUris = ImmutableList.of(RESOURCES_ONE, RESOURCES_TWO, RESOURCES_ONE); List<ConcatData> concatUris = manager.make(fromList(gadget, resourceUris, type), true); assertEquals(3, concatUris.size()); for (int i = 0; i < 3; ++i) { ConcatUriManager.ConcatUri validated = manager.process(concatUris.get(i).getUris().get(0)); assertEquals(UriStatus.VALID_VERSIONED, validated.getStatus()); List<Uri> resList = (i % 2 == 0) ? RESOURCES_ONE : RESOURCES_TWO; assertEquals(resList, validated.getBatch()); assertEquals(type, validated.getType()); } }
private void checkValidatedBatchAdjacent(ConcatUriManager.Type type) throws Exception { // This is essentially the "integration" test ensuring that a // DefaultConcatUriManager's created Uris can be validated by it in turn. Gadget gadget = mockGadget(true, true); String host = "bar.com"; String path = "/other/path"; String[] versions = new String[] { "version1"}; ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED, versions); DefaultConcatUriManager manager = makeManager(host, path, "token", versioner); List<List<Uri>> resourceUris = ImmutableList.of(RESOURCES_ONE, RESOURCES_TWO, RESOURCES_ONE); List<ConcatData> concatUris = manager.make(fromList(gadget, resourceUris, type), true); assertEquals(3, concatUris.size()); for (int i = 0; i < 3; ++i) { ConcatUriManager.ConcatUri validated = manager.process(concatUris.get(i).getUris().get(0)); assertEquals(UriStatus.VALID_VERSIONED, validated.getStatus()); List<Uri> resList = (i % 2 == 0) ? RESOURCES_ONE : RESOURCES_TWO; assertEquals(resList, validated.getBatch()); assertEquals(type, validated.getType()); } }
private void checkUnversionedUri(ConcatUriManager.Type type, boolean hasSplit) { // Returns VALID_VERSIONED, but no version is present. ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(UriStatus.VALID_UNVERSIONED, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
private void checkUnversionedUri(ConcatUriManager.Type type, boolean hasSplit) { // Returns VALID_VERSIONED, but no version is present. ConcatUriManager.Versioner versioner = makeVersioner(UriStatus.VALID_VERSIONED); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(UriStatus.VALID_UNVERSIONED, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
private void checkValidateUri(UriStatus status, ConcatUriManager.Type type, boolean hasSplit) { ConcatUriManager.Versioner versioner = makeVersioner(status); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.VERSION.getKey() + "=something&" + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(status, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
private void checkValidateUri(UriStatus status, ConcatUriManager.Type type, boolean hasSplit) { ConcatUriManager.Versioner versioner = makeVersioner(status); DefaultConcatUriManager manager = makeManager("host.com", "/path", null, versioner); ConcatUriManager.ConcatUri validated = manager.process( Uri.parse("http://host.com/path?" + Param.CONTAINER.getKey() + '=' + CONTAINER + "&1=http://legit.com/1.dat&2=http://another.com/2.dat&" + Param.TYPE.getKey() + '=' + type.getType() + '&' + Param.VERSION.getKey() + "=something&" + Param.JSON.getKey() + "=split&" + Param.GADGET.getKey() + "=http://www.gadget.com/g.xml&" + Param.REFRESH.getKey() + "=123")); assertEquals(status, validated.getStatus()); assertEquals(type, validated.getType()); assertEquals(CONTAINER, validated.getContainer()); assertEquals("http://www.gadget.com/g.xml", validated.getGadget()); assertEquals(2, validated.getBatch().size()); assertEquals("http://legit.com/1.dat", validated.getBatch().get(0).toString()); assertEquals("http://another.com/2.dat", validated.getBatch().get(1).toString()); assertEquals(123, validated.getRefresh().intValue()); assertEquals(hasSplit ? "split" : null, validated.getSplitParam()); }
@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()); }
private UriBuilder makeUriBuilder(ConcatUri ctx, String authority, String path) { UriBuilder uriBuilder = ctx.makeQueryParams(null, null); uriBuilder.setAuthority(authority); uriBuilder.setPath(path); uriBuilder.addQueryParameter(Param.TYPE.getKey(), ctx.getType().getType()); return uriBuilder; }
@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()); }
@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()); }