@Test public void loadUriInlineFetcherFailure() throws Exception { Uri uri = Uri.parse("http://apache.org/resource.js"); Map<String, String> attribs = Maps.newHashMap(); attribs.put("inline", "true"); HttpFetcher fetcher = createMock(HttpFetcher.class); expect(fetcher.fetch(eq(new HttpRequest(uri)))) .andThrow(new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT)); replay(fetcher); loader.setHttpFetcher(fetcher); FeatureResource resource = loader.load(uri, attribs); assertNull(resource.getContent()); assertNull(resource.getDebugContent()); assertFalse(resource.isProxyCacheable()); assertFalse(resource.isExternal()); }
@Test public void loadUriInline() throws Exception { Uri uri = Uri.parse("http://apache.org/resource.js"); Map<String, String> attribs = Maps.newHashMap(); attribs.put("inline", "true"); HttpFetcher fetcher = mockFetcher(uri, URL_JS); loader.setHttpFetcher(fetcher); FeatureResource resource = loader.load(uri, attribs); assertEquals(URL_JS, resource.getContent()); assertEquals(URL_JS, resource.getDebugContent()); assertTrue(resource.isProxyCacheable()); assertFalse(resource.isExternal()); }
@Test public void loadUriExtern() throws Exception { String theUrl = "http://apache.org/resource.js"; Uri uri = Uri.parse(theUrl); Map<String, String> attribs = Maps.newHashMap(); HttpFetcher fetcher = mockFetcher(uri, URL_JS); loader.setHttpFetcher(fetcher); // should have no effect on its own FeatureResource resource = loader.load(uri, attribs); assertEquals(theUrl, resource.getContent()); assertEquals(theUrl, resource.getDebugContent()); assertTrue(resource.isProxyCacheable()); assertTrue(resource.isExternal()); }