JavaScriptModuleBuilder implements IModuleBuilder, IExtensionInitializer, ILayerListener, IShutdownListener, IConfigListener { @Override public List<ICacheKeyGenerator> getCacheKeyGenerators(IAggregator aggregator) { return getCacheKeyGenerators((Set<String>)null, true); }  static CompilationLevel getCompilationLevel(HttpServletRequest request); @Override void initialize(IAggregator aggregator,
			IAggregatorExtension extension, IExtensionRegistrar registrar); @Override String layerBeginEndNotifier(EventType type, HttpServletRequest request, List<IModule> modules, Set<String> dependentFeatures); @Override void shutdown(IAggregator aggregator); @Override void configLoaded(IConfig config, long sequence); @Override ModuleBuild build(
			String mid,
			IResource resource,
			HttpServletRequest request,
			List<ICacheKeyGenerator> keyGens
			); @Override List<ICacheKeyGenerator> getCacheKeyGenerators(IAggregator aggregator); @Override boolean handles(String mid, IResource resource); @Override boolean isScript(HttpServletRequest request); static final String MODULE_EXPANDED_DEPS; }
@Test public void testGenerateCacheKey() throws IOException { TestUtils.createTestFiles(tmpdir); mockAggregator.getOptions().setOption(IOptions.DEVELOPMENT_MODE, true); TestJavaScriptModuleBuilder builder = new TestJavaScriptModuleBuilder(); List<ICacheKeyGenerator> keyGens = builder.getCacheKeyGenerators(mockAggregator); requestAttributes.put(IAggregator.AGGREGATOR_REQATTRNAME, mockAggregator); assertEquals("expn:0;js:S:0:0:1;has{}", KeyGenUtil.generateKey(mockRequest, keyGens)); requestAttributes.put(IHttpTransport.OPTIMIZATIONLEVEL_REQATTRNAME, OptimizationLevel.SIMPLE); assertEquals("expn:0;js:S:0:0:1;has{}", KeyGenUtil.generateKey(mockRequest, keyGens)); requestAttributes.put(IHttpTransport.OPTIMIZATIONLEVEL_REQATTRNAME, OptimizationLevel.NONE); assertEquals("expn:0;js:N:0:0:1", KeyGenUtil.generateKey(mockRequest, keyGens)); requestAttributes.put(IHttpTransport.OPTIMIZATIONLEVEL_REQATTRNAME, OptimizationLevel.WHITESPACE); assertEquals("expn:0;js:W:0:0:1;has{}", KeyGenUtil.generateKey(mockRequest, keyGens)); requestAttributes.put(IHttpTransport.EXPANDREQUIRELISTS_REQATTRNAME, Boolean.TRUE); assertEquals("expn:0;js:W:1:0:1;has{}", KeyGenUtil.generateKey(mockRequest, keyGens)); Features features = new Features(); features.put("foo", true); features.put("bar", false); requestAttributes.put(IHttpTransport.FEATUREMAP_REQATTRNAME, features); assertEquals("expn:0;js:W:1:0:1;has{!bar,foo}", KeyGenUtil.generateKey(mockRequest, keyGens)); Set<String> hasConditionals = new HashSet<String>(); keyGens = builder.getCacheKeyGenerators(hasConditionals, true); assertEquals("expn:0;js:W:1:0:1;has{}", KeyGenUtil.generateKey(mockRequest, keyGens)); hasConditionals.add("foo"); keyGens = builder.getCacheKeyGenerators(hasConditionals, true); assertEquals("expn:0;js:W:1:0:1;has{foo}", KeyGenUtil.generateKey(mockRequest, keyGens)); hasConditionals.add("bar"); keyGens = builder.getCacheKeyGenerators(hasConditionals, false); assertEquals("expn:0;js:W:0:0:1;has{!bar,foo}", KeyGenUtil.generateKey(mockRequest, keyGens)); hasConditionals.add("undefined"); keyGens = builder.getCacheKeyGenerators(hasConditionals, false); assertEquals("expn:0;js:W:0:0:1;has{!bar,foo}", KeyGenUtil.generateKey(mockRequest, keyGens)); }