@Test public void testAsJsonConcat() throws Exception { String results = "_js={\r\n" + addVar(URL1.toString(), SCRT1_ESCAPED) + addLastVar(URL2.toString(), SCRT2_ESCAPED) + "};\r\n"; runConcat(sequentialExecutor, results, "_js", URL1, URL2); }
@Test public void testAsJsonConcat() throws Exception { String results = "_js={\r\n" + addVar(URL1.toString(), SCRT1_ESCAPED) + addLastVar(URL2.toString(), SCRT2_ESCAPED) + "};\r\n"; runConcat(sequentialExecutor, results, "_js", URL1, URL2); }
@Test public void testAsJsonConcat404() throws Exception { final Uri URL4 = Uri.parse("http://example.org/4.js"); HttpRequest req = new HttpRequest(URL4); HttpResponse resp = new HttpResponseBuilder().setHttpStatusCode(404).create(); expect(pipeline.execute(req)).andReturn(resp).anyTimes(); String results = "_js={\r\n" + addLastVar(URL1.toString(), SCRT1_ESCAPED) + "/* ---- Error 404 (http://example.org/4.js) ---- */\r\n" + "};\r\n"; runConcat(sequentialExecutor, results, "_js", URL1, URL4); }
@Test public void testAsJsonConcat404() throws Exception { final Uri URL4 = Uri.parse("http://example.org/4.js"); HttpRequest req = new HttpRequest(URL4); HttpResponse resp = new HttpResponseBuilder().setHttpStatusCode(404).create(); expect(pipeline.execute(req)).andReturn(resp).anyTimes(); String results = "_js={\r\n" + addLastVar(URL1.toString(), SCRT1_ESCAPED) + "/* ---- Error 404 (http://example.org/4.js) ---- */\r\n" + "};\r\n"; runConcat(sequentialExecutor, results, "_js", URL1, URL4); }
@Test public void testThreeAsJsonConcat() throws Exception { String results = "_js={\r\n" + addVar(URL1.toString(), SCRT1_ESCAPED) + addVar(URL2.toString(), SCRT2_ESCAPED) + addLastVar(URL3.toString(), SCRT3_ESCAPED) + "};\r\n"; runConcat(sequentialExecutor, results, "_js", URL1, URL2, URL3); }
@Test public void testThreeAsJsonConcat() throws Exception { String results = "_js={\r\n" + addVar(URL1.toString(), SCRT1_ESCAPED) + addVar(URL2.toString(), SCRT2_ESCAPED) + addLastVar(URL3.toString(), SCRT3_ESCAPED) + "};\r\n"; runConcat(sequentialExecutor, results, "_js", URL1, URL2, URL3); }
@Test public void testAsJsonConcatException() throws Exception { final Uri URL4 = Uri.parse("http://example.org/4.js"); HttpRequest req = new HttpRequest(URL4); expect(pipeline.execute(req)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT)).anyTimes(); expectRequestWithUris(Lists.newArrayList(URL1, URL4), "_js"); servlet.doGet(request, recorder); verify(); String results = "_js={\r\n" + addLastVar(URL1.toString(), SCRT1_ESCAPED) + addConcatErrComment(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, URL4.toString()) + "};\r\n"; assertEquals(results, recorder.getResponseAsString()); assertEquals(400, recorder.getHttpStatusCode()); }
@Test public void testAsJsonConcatException() throws Exception { final Uri URL4 = Uri.parse("http://example.org/4.js"); HttpRequest req = new HttpRequest(URL4); expect(pipeline.execute(req)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT)).anyTimes(); expectRequestWithUris(Lists.newArrayList(URL1, URL4), "_js"); servlet.doGet(request, recorder); verify(); String results = "_js={\r\n" + addLastVar(URL1.toString(), SCRT1_ESCAPED) + addConcatErrComment(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, URL4.toString()) + "};\r\n"; assertEquals(results, recorder.getResponseAsString()); assertEquals(400, recorder.getHttpStatusCode()); }
@Test public void testAsJsonConcatBadException() throws Exception { final Uri URL4 = Uri.parse("http://example.org/4.js"); HttpRequest req = new HttpRequest(URL4); expect(pipeline.execute(req)).andThrow( new GadgetException(GadgetException.Code.HTML_PARSE_ERROR)).anyTimes(); String results = "_js={\r\n" + addLastVar(URL1.toString(), SCRT1_ESCAPED) + addConcatErrComment(GadgetException.Code.HTML_PARSE_ERROR, URL4.toString()) + "};\r\n"; expectRequestWithUris(Lists.newArrayList(URL1, URL4), "_js"); // Run the servlet servlet.doGet(request, recorder); verify(); assertEquals(results, recorder.getResponseAsString()); assertEquals(400, recorder.getHttpStatusCode()); }
@Test public void testAsJsonConcatBadException() throws Exception { final Uri URL4 = Uri.parse("http://example.org/4.js"); HttpRequest req = new HttpRequest(URL4); expect(pipeline.execute(req)).andThrow( new GadgetException(GadgetException.Code.HTML_PARSE_ERROR)).anyTimes(); String results = "_js={\r\n" + addLastVar(URL1.toString(), SCRT1_ESCAPED) + addConcatErrComment(GadgetException.Code.HTML_PARSE_ERROR, URL4.toString()) + "};\r\n"; expectRequestWithUris(Lists.newArrayList(URL1, URL4), "_js"); // Run the servlet servlet.doGet(request, recorder); verify(); assertEquals(results, recorder.getResponseAsString()); assertEquals(400, recorder.getHttpStatusCode()); }