@Test public void multiplePreloads() throws Exception { String xml = "<Module><ModulePrefs title=''>" + " <Preload href='" + PRELOAD_HREF + "'/>" + " <Preload href='" + PRELOAD_HREF2 + "'/>" + "</ModulePrefs><Content/></Module>"; GadgetSpec spec = new GadgetSpec(GADGET_URL, xml); Preloader preloader = new HttpPreloader(requestPipeline); Gadget gadget = new Gadget() .setContext(context) .setSpec(spec) .setCurrentView(spec.getView(GadgetSpec.DEFAULT_VIEW)); Collection<Callable<PreloadedData>> preloaded = preloader.createPreloadTasks( gadget); assertEquals(2, preloaded.size()); List<Object> list = getAll(preloaded); assertEquals(2, list.size()); checkRequest(plainFetcher.requests.get(0)); checkResults(list.get(0)); checkRequest(plainFetcher.requests.get(1)); checkResults(list.get(1), PRELOAD_HREF2); }
@Test public void multiplePreloads() throws Exception { String xml = "<Module><ModulePrefs title=''>" + " <Preload href='" + PRELOAD_HREF + "'/>" + " <Preload href='" + PRELOAD_HREF2 + "'/>" + "</ModulePrefs><Content/></Module>"; GadgetSpec spec = new GadgetSpec(GADGET_URL, xml); Preloader preloader = new HttpPreloader(requestPipeline); Gadget gadget = new Gadget() .setContext(context) .setSpec(spec) .setCurrentView(spec.getView(GadgetSpec.DEFAULT_VIEW)); Collection<Callable<PreloadedData>> preloaded = preloader.createPreloadTasks( gadget); assertEquals(2, preloaded.size()); List<Object> list = getAll(preloaded); assertEquals(2, list.size()); checkRequest(plainFetcher.requests.get(0)); checkResults(list.get(0)); checkRequest(plainFetcher.requests.get(1)); checkResults(list.get(1), PRELOAD_HREF2); }
@Test public void multiplePreloads() throws Exception { String xml = "<Module><ModulePrefs title=''>" + " <Preload href='" + PRELOAD_HREF + "'/>" + " <Preload href='" + PRELOAD_HREF2 + "'/>" + "</ModulePrefs><Content/></Module>"; GadgetSpec spec = new GadgetSpec(GADGET_URL, xml); Preloader preloader = new HttpPreloader(requestPipeline); Gadget gadget = new Gadget() .setContext(context) .setSpec(spec) .setCurrentView(spec.getView(GadgetSpec.DEFAULT_VIEW)); Collection<Callable<PreloadedData>> preloaded = preloader.createPreloadTasks( gadget); assertEquals(2, preloaded.size()); List<Object> list = getAll(preloaded); assertEquals(2, list.size()); checkRequest(plainFetcher.requests.get(0)); checkResults(list.get(0)); checkRequest(plainFetcher.requests.get(1)); checkResults(list.get(1), PRELOAD_HREF2); }
@Test public void onlyPreloadForCorrectView() throws Exception { String xml = "<Module><ModulePrefs title=''>" + " <Preload href='" + PRELOAD_HREF + "' views='foo,bar,baz'/>" + " <Preload href='" + PRELOAD_HREF2 + "' views='bar'/>" + "</ModulePrefs><Content/></Module>"; GadgetSpec spec = new GadgetSpec(GADGET_URL, xml); Preloader preloader = new HttpPreloader(requestPipeline); view = "foo"; Gadget gadget = new Gadget() .setContext(context) .setSpec(spec) .setCurrentView(spec.getView(GadgetSpec.DEFAULT_VIEW)); Collection<Callable<PreloadedData>> preloaded = preloader.createPreloadTasks(gadget); List<Object> list = getAll(preloaded); assertEquals(1, list.size()); checkRequest(plainFetcher.requests.get(0)); checkResults(list.get(0)); }
@Test public void onlyPreloadForCorrectView() throws Exception { String xml = "<Module><ModulePrefs title=''>" + " <Preload href='" + PRELOAD_HREF + "' views='foo,bar,baz'/>" + " <Preload href='" + PRELOAD_HREF2 + "' views='bar'/>" + "</ModulePrefs><Content/></Module>"; GadgetSpec spec = new GadgetSpec(GADGET_URL, xml); Preloader preloader = new HttpPreloader(requestPipeline); view = "foo"; Gadget gadget = new Gadget() .setContext(context) .setSpec(spec) .setCurrentView(spec.getView(GadgetSpec.DEFAULT_VIEW)); Collection<Callable<PreloadedData>> preloaded = preloader.createPreloadTasks(gadget); List<Object> list = getAll(preloaded); assertEquals(1, list.size()); checkRequest(plainFetcher.requests.get(0)); checkResults(list.get(0)); }
@Test public void onlyPreloadForCorrectView() throws Exception { String xml = "<Module><ModulePrefs title=''>" + " <Preload href='" + PRELOAD_HREF + "' views='foo,bar,baz'/>" + " <Preload href='" + PRELOAD_HREF2 + "' views='bar'/>" + "</ModulePrefs><Content/></Module>"; GadgetSpec spec = new GadgetSpec(GADGET_URL, xml); Preloader preloader = new HttpPreloader(requestPipeline); view = "foo"; Gadget gadget = new Gadget() .setContext(context) .setSpec(spec) .setCurrentView(spec.getView(GadgetSpec.DEFAULT_VIEW)); Collection<Callable<PreloadedData>> preloaded = preloader.createPreloadTasks(gadget); List<Object> list = getAll(preloaded); assertEquals(1, list.size()); checkRequest(plainFetcher.requests.get(0)); checkResults(list.get(0)); }