public boolean isProxyCacheable() { // If browser-specific (ie. browserMatch has some qualifiers in it), not proxy cacheable // (since the vast majority of browsers don't support Vary: User-Agent, we just say "false") // Otherwise, delegate this call. return browserMatch.isEmpty() ? delegate.isProxyCacheable() : false; }
public boolean isProxyCacheable() { // If browser-specific (ie. browserMatch has some qualifiers in it), not proxy cacheable // (since the vast majority of browsers don't support Vary: User-Agent, we just say "false") // Otherwise, delegate this call. return browserMatch.isEmpty() ? delegate.isProxyCacheable() : false; }
public boolean isProxyCacheable() { // If browser-specific (ie. browserMatch has some qualifiers in it), not proxy cacheable // (since the vast majority of browsers don't support Vary: User-Agent, we just say "false") // Otherwise, delegate this call. return browserMatch.isEmpty() ? delegate.isProxyCacheable() : false; }
private FeatureResource mockResource(boolean proxyCacheable) { FeatureResource result = control.createMock(FeatureResource.class); expect(result.isProxyCacheable()).andReturn(proxyCacheable).anyTimes(); return result; }
private FeatureResource mockResource(boolean proxyCacheable) { FeatureResource result = control.createMock(FeatureResource.class); expect(result.isProxyCacheable()).andReturn(proxyCacheable).anyTimes(); return result; }
@Test public void loadFileBothModesAvailable() throws Exception { Pair<Uri, File> optUri = makeFile(".opt.js", FILE_JS); File dbgFile = new File(optUri.one.getPath().replace(".opt.js", ".js")); dbgFile.createNewFile(); Pair<Uri, File> dbgUri = makeFile(dbgFile, UNCOMPRESSED_FILE_JS); FeatureResource resource = loader.load(dbgUri.one, null); assertEquals(FILE_JS, resource.getContent()); assertEquals(UNCOMPRESSED_FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }
@Test public void loadFileBothModesAvailable() throws Exception { Pair<Uri, File> optUri = makeFile(".opt.js", FILE_JS); File dbgFile = new File(optUri.one.getPath().replace(".opt.js", ".js")); dbgFile.createNewFile(); Pair<Uri, File> dbgUri = makeFile(dbgFile, UNCOMPRESSED_FILE_JS); FeatureResource resource = loader.load(dbgUri.one, null); assertEquals(FILE_JS, resource.getContent()); assertEquals(UNCOMPRESSED_FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }
@Test public void loadFileBothModesAvailable() throws Exception { Pair<Uri, File> optUri = makeFile(".opt.js", FILE_JS); File dbgFile = new File(optUri.one.getPath().replace(".opt.js", ".js")); dbgFile.createNewFile(); Pair<Uri, File> dbgUri = makeFile(dbgFile, UNCOMPRESSED_FILE_JS); FeatureResource resource = loader.load(dbgUri.one, null); assertEquals(FILE_JS, resource.getContent()); assertEquals(UNCOMPRESSED_FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }
@Test public void loadUriInlineNoFetcherSet() throws Exception { Uri uri = Uri.parse("http://apache.org/resource.js"); Map<String, String> attribs = Maps.newHashMap(); attribs.put("inline", "true"); 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"); mockFetcher(uri, URL_JS); 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(); mockFetcher(uri, URL_JS); FeatureResource resource = loader.load(uri, attribs); assertEquals(theUrl, resource.getContent()); assertEquals(theUrl, resource.getDebugContent()); assertTrue(resource.isProxyCacheable()); assertTrue(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(); mockFetcher(uri, URL_JS); FeatureResource resource = loader.load(uri, attribs); assertEquals(theUrl, resource.getContent()); assertEquals(theUrl, resource.getDebugContent()); assertTrue(resource.isProxyCacheable()); assertTrue(resource.isExternal()); }
@Test public void loadFileDebugOnlyAvailable() throws Exception { Pair<Uri, File> dbgUri = makeFile(".js", UNCOMPRESSED_FILE_JS); FeatureResource resource = loader.load(dbgUri.one, null); assertEquals(UNCOMPRESSED_FILE_JS, resource.getContent()); assertEquals(UNCOMPRESSED_FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }
@Test public void loadFileOptOnlyAvailable() throws Exception { Pair<Uri, File> optUri = makeFile(".opt.js", FILE_JS); FeatureResource resource = loader.load(optUri.one, null); assertEquals(FILE_JS, resource.getContent()); assertEquals(FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }
@Test public void loadFileNoOptPathCalculable() throws Exception { // File doesn't end in .js, so it's loaded for both opt and debug. Pair<Uri, File> dbgUri = makeFile(".notjssuffix", UNCOMPRESSED_FILE_JS); FeatureResource resource = loader.load(dbgUri.one, null); assertEquals(UNCOMPRESSED_FILE_JS, resource.getContent()); assertEquals(UNCOMPRESSED_FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }
@Test public void loadFileDebugOnlyAvailable() throws Exception { Pair<Uri, File> dbgUri = makeFile(".js", UNCOMPRESSED_FILE_JS); FeatureResource resource = loader.load(dbgUri.one, null); assertEquals(UNCOMPRESSED_FILE_JS, resource.getContent()); assertEquals(UNCOMPRESSED_FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }
@Test public void loadFileOptOnlyAvailable() throws Exception { Pair<Uri, File> optUri = makeFile(".opt.js", FILE_JS); FeatureResource resource = loader.load(optUri.one, null); assertEquals(FILE_JS, resource.getContent()); assertEquals(FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }
@Test public void loadFileDebugOnlyAvailable() throws Exception { Pair<Uri, File> dbgUri = makeFile(".js", UNCOMPRESSED_FILE_JS); FeatureResource resource = loader.load(dbgUri.one, null); assertEquals(UNCOMPRESSED_FILE_JS, resource.getContent()); assertEquals(UNCOMPRESSED_FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }
@Test public void loadFileNoOptPathCalculable() throws Exception { // File doesn't end in .js, so it's loaded for both opt and debug. Pair<Uri, File> dbgUri = makeFile(".notjssuffix", UNCOMPRESSED_FILE_JS); FeatureResource resource = loader.load(dbgUri.one, null); assertEquals(UNCOMPRESSED_FILE_JS, resource.getContent()); assertEquals(UNCOMPRESSED_FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }
@Test public void loadFileOptOnlyAvailable() throws Exception { Pair<Uri, File> optUri = makeFile(".opt.js", FILE_JS); FeatureResource resource = loader.load(optUri.one, null); assertEquals(FILE_JS, resource.getContent()); assertEquals(FILE_JS, resource.getDebugContent()); assertFalse(resource.isExternal()); assertTrue(resource.isProxyCacheable()); }