@Test public void testParseAndNormalizeAccelUri() throws Exception { Uri uri = Uri.parse("http://apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.1.com%2Fa.html" + "&url=http%3A%2F%2Fwww.example.org%2Findex.html"); HttpRequest req = new HttpRequest(uri); assertEquals(Uri.parse("//apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.1.com%2Fa.html" + "&debug=0&nocache=0&refresh=0" + "&url=http%3A%2F%2Fwww.example.org%2Findex.html"), uriManager.parseAndNormalize(req)); }
@Test public void testParseAndNormalizeAccelUri() throws Exception { Uri uri = Uri.parse("http://apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.1.com%2Fa.html" + "&url=http%3A%2F%2Fwww.example.org%2Findex.html"); HttpRequest req = new HttpRequest(uri); assertEquals(Uri.parse("//apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.1.com%2Fa.html" + "&debug=0&nocache=0&refresh=0" + "&url=http%3A%2F%2Fwww.example.org%2Findex.html"), uriManager.parseAndNormalize(req)); }
@Test public void testParseAndNormalizeAccelUri() throws Exception { Uri uri = Uri.parse("http://apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.1.com%2Fa.html" + "&url=http%3A%2F%2Fwww.example.org%2Findex.html"); HttpRequest req = new HttpRequest(uri); assertEquals(Uri.parse("//apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.1.com%2Fa.html" + "&debug=0&nocache=0&refresh=0" + "&url=http%3A%2F%2Fwww.example.org%2Findex.html"), uriManager.parseAndNormalize(req)); }
@Test public void testParseAndNormalizeNonAccelUri() throws Exception { Uri uri = Uri.parse("http://www.example.org/index.html"); HttpRequest req = new HttpRequest(uri); assertEquals(Uri.parse("//apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.example.org%2Findex.html" + "&debug=0&nocache=0&refresh=0" + "&rooe=1&url=http%3A%2F%2Fwww.example.org%2Findex.html"), uriManager.parseAndNormalize(req)); uri = Uri.parse("http://www.example.org/index.html"); req = new HttpRequest(uri); req.setContainer("accel"); assertEquals(Uri.parse("//apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.example.org%2Findex.html" + "&debug=0&nocache=0&refresh=0" + "&rooe=1&url=http%3A%2F%2Fwww.example.org%2Findex.html"), uriManager.parseAndNormalize(req)); }
@Test public void testParseAndNormalizeNonAccelUri() throws Exception { Uri uri = Uri.parse("http://www.example.org/index.html"); HttpRequest req = new HttpRequest(uri); assertEquals(Uri.parse("//apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.example.org%2Findex.html" + "&debug=0&nocache=0&refresh=0" + "&rooe=1&url=http%3A%2F%2Fwww.example.org%2Findex.html"), uriManager.parseAndNormalize(req)); uri = Uri.parse("http://www.example.org/index.html"); req = new HttpRequest(uri); req.setContainer("accel"); assertEquals(Uri.parse("//apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.example.org%2Findex.html" + "&debug=0&nocache=0&refresh=0" + "&rooe=1&url=http%3A%2F%2Fwww.example.org%2Findex.html"), uriManager.parseAndNormalize(req)); }
@Test public void testParseAndNormalizeNonAccelUri() throws Exception { Uri uri = Uri.parse("http://www.example.org/index.html"); HttpRequest req = new HttpRequest(uri); assertEquals(Uri.parse("//apache.org/gadgets/proxy?container=default" + "&gadget=http%3A%2F%2Fwww.example.org%2Findex.html" + "&debug=0&nocache=0&refresh=0" + "&url=http%3A%2F%2Fwww.example.org%2Findex.html"), uriManager.parseAndNormalize(req)); uri = Uri.parse("http://www.example.org/index.html"); req = new HttpRequest(uri); req.setContainer("accel"); assertEquals(Uri.parse("//apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.example.org%2Findex.html" + "&debug=0&nocache=0&refresh=0" + "&url=http%3A%2F%2Fwww.example.org%2Findex.html"), uriManager.parseAndNormalize(req)); }
@Test public void testContainersChange() throws Exception { String beforeUrl = "//apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.example.org%2Findex.html" + "&debug=0&nocache=0&refresh=0&rooe=1&url=http%3A%2F%2Fwww.example.org%2Findex.html"; String afterUrl = "//apache.org/random/url?container=accel" + "&gadget=http%3A%2F%2Fwww.example.org%2Findex.html" + "&debug=0&nocache=0&refresh=0&rooe=1&url=http%3A%2F%2Fwww.example.org%2Findex.html"; Uri uri = Uri.parse("http://www.example.org/index.html"); HttpRequest req = new HttpRequest(uri); req.setContainer("accel"); assertEquals(Uri.parse(beforeUrl), uriManager.parseAndNormalize(req)); assertTrue(uriManager.looksLikeAccelUri(Uri.parse(beforeUrl))); assertFalse(uriManager.looksLikeAccelUri(Uri.parse(afterUrl))); config.newTransaction().addContainer(makeConfig("accel", "/random/url")).commit(); uri = Uri.parse("http://www.example.org/index.html"); req = new HttpRequest(uri); req.setContainer("accel"); assertEquals(Uri.parse(afterUrl), uriManager.parseAndNormalize(req)); assertFalse(uriManager.looksLikeAccelUri(Uri.parse(beforeUrl))); assertTrue(uriManager.looksLikeAccelUri(Uri.parse(afterUrl))); } }
@Test public void testContainersChange() throws Exception { String beforeUrl = "//apache.org/gadgets/accel?container=accel" + "&gadget=http%3A%2F%2Fwww.example.org%2Findex.html" + "&debug=0&nocache=0&refresh=0&rooe=1&url=http%3A%2F%2Fwww.example.org%2Findex.html"; String afterUrl = "//apache.org/random/url?container=accel" + "&gadget=http%3A%2F%2Fwww.example.org%2Findex.html" + "&debug=0&nocache=0&refresh=0&rooe=1&url=http%3A%2F%2Fwww.example.org%2Findex.html"; Uri uri = Uri.parse("http://www.example.org/index.html"); HttpRequest req = new HttpRequest(uri); req.setContainer("accel"); assertEquals(Uri.parse(beforeUrl), uriManager.parseAndNormalize(req)); assertTrue(uriManager.looksLikeAccelUri(Uri.parse(beforeUrl))); assertFalse(uriManager.looksLikeAccelUri(Uri.parse(afterUrl))); config.newTransaction().addContainer(makeConfig("accel", "/random/url")).commit(); uri = Uri.parse("http://www.example.org/index.html"); req = new HttpRequest(uri); req.setContainer("accel"); assertEquals(Uri.parse(afterUrl), uriManager.parseAndNormalize(req)); assertFalse(uriManager.looksLikeAccelUri(Uri.parse(beforeUrl))); assertTrue(uriManager.looksLikeAccelUri(Uri.parse(afterUrl))); } }