private void setupForVersionAndProxy(boolean proxyCacheable, UriStatus uriStatus) { List<String> reqLibs = ImmutableList.of("feature"); List<String> loadLibs = EMPTY_STRING_LIST; FeatureResource resource1 = mockResource(proxyCacheable); FeatureResource resource2 = mockResource(proxyCacheable); FeatureBundle bundle = mockBundle("feature", null, null, Lists.newArrayList(resource1, resource2)); setupJsUriAndRegistry(uriStatus, reqLibs, Lists.newArrayList(bundle), loadLibs, EMPTY_BUNDLE_LIST); expect(compiler.getJsContent(jsUri, bundle)) .andReturn(ImmutableList.<JsContent>of( JsContent.fromFeature(JS_CODE1, "source1", bundle, resource1), JsContent.fromFeature(JS_CODE2, "source2", bundle, resource2))); }
private void setupForVersionAndProxy(boolean proxyCacheable, UriStatus uriStatus) { List<String> reqLibs = ImmutableList.of("feature"); List<String> loadLibs = EMPTY_STRING_LIST; FeatureResource resource1 = mockResource(proxyCacheable); FeatureResource resource2 = mockResource(proxyCacheable); FeatureBundle bundle = mockBundle("feature", null, null, Lists.newArrayList(resource1, resource2)); setupJsUriAndRegistry(uriStatus, reqLibs, Lists.newArrayList(bundle), loadLibs, EMPTY_BUNDLE_LIST); expect(compiler.getJsContent(jsUri, bundle)) .andReturn(ImmutableList.<JsContent>of( JsContent.fromFeature(JS_CODE1, "source1", bundle, resource1), JsContent.fromFeature(JS_CODE2, "source2", bundle, resource2))); }
@Test public void testPopulateWithLoadedFeatures() throws Exception { List<String> reqLibs = ImmutableList.of("feature1", "feature2"); List<String> loadLibs = ImmutableList.of("feature2"); FeatureResource resource1 = mockResource(true); FeatureBundle bundle1 = mockBundle("feature1", null, null, Lists.newArrayList(resource1)); FeatureBundle bundle2 = mockBundle("feature2", "export2", "extern2", null); setupJsUriAndRegistry(UriStatus.VALID_UNVERSIONED, reqLibs, ImmutableList.of(bundle1, bundle2), loadLibs, ImmutableList.of(bundle2)); expect(compiler.getJsContent(jsUri, bundle1)) .andReturn(ImmutableList.<JsContent>of( JsContent.fromFeature(JS_CODE1, "source1", null, null))); control.replay(); processor.process(request, response); checkResponse(true, GetJsContentProcessor.DEFAULT_UNVERSIONED_MAXAGE, JS_CODE1, "export2", "extern2"); control.verify(); }
@Test public void testPopulateWithLoadedFeatures() throws Exception { List<String> reqLibs = ImmutableList.of("feature1", "feature2"); List<String> loadLibs = ImmutableList.of("feature2"); FeatureResource resource1 = mockResource(true); FeatureBundle bundle1 = mockBundle("feature1", null, null, Lists.newArrayList(resource1)); FeatureBundle bundle2 = mockBundle("feature2", "export2", "extern2", null); setupJsUriAndRegistry(UriStatus.VALID_UNVERSIONED, reqLibs, ImmutableList.of(bundle1, bundle2), loadLibs, ImmutableList.of(bundle2)); expect(compiler.getJsContent(jsUri, bundle1)) .andReturn(ImmutableList.<JsContent>of( JsContent.fromFeature(JS_CODE1, "source1", null, null))); control.replay(); processor.process(request, response); checkResponse(true, GetJsContentProcessor.DEFAULT_UNVERSIONED_MAXAGE, JS_CODE1, "export2", "extern2"); control.verify(); }
continue; builder.appendAllJs(compiler.getJsContent(jsUri, bundle)); for (FeatureResource featureResource : bundle.getResources()) { isProxyCacheable = isProxyCacheable && featureResource.isProxyCacheable();