ResourceRuntimeContext { public String getDeDupToken(String resType) { String token = m_tokens.get(resType); if (token == null) { Set<String> urns = m_model.getCollectedResource(resType); if (urns != null && !urns.isEmpty()) { for (Iterator<String> i = urns.iterator(); i.hasNext();) { String urn = i.next(); if (urn.indexOf("inline:/") >= 0) { i.remove(); } } if(!urns.isEmpty()){ List<String> urnsList = new ArrayList<String>(urns); Collections.sort(urnsList); token = m_config.getRegistry().getTokenStorage().storeResourceUrns(urnsList); m_tokens.put(resType, token); } } } return token; } private  ResourceRuntimeContext(); static ResourceRuntimeContext ctx(); static boolean isInitialized(); static void reset(); @Deprecated static void setup(String contextPath); static void setup(); IResourceContext createResourceContext(); Object getAttribute(String name); IResourceRuntimeConfig getConfig(); IDeferRenderable getDeferRenderable(String key); ResourceModel getModel(); ResourceAggregator getResourceAggregator(); IResourceContext getResourceContext(); DiagnosisModel getShowDiagModel(); Statistics getStatistics(); boolean isShowDiag(); boolean isStatisticsEnabled(); void registerDeferRenderable(String key, IDeferRenderable renderable); void setAttribute(String name, Object value); String getDeDupToken(String resType); void setDeDupToken(String deDupToken); void setLocale(IResourceLocale locale); void setShowDiag(boolean showDiag); void supportDeferRendering(String uri);  }
@Test public void testGetDedupToken() { ResourceRuntimeContext ctx = ResourceRuntimeContext.ctx(); MockTokenStorage storage = new MockTokenStorage(); ctx.getConfig().getRegistry().setTokenStorage(storage); ResourceModel model = ResourceRuntimeContext.ctx().getResourceAggregator().getModel(); model.enableCollectResources("js", true); model.processModel(); Set<String> set = new HashSet<String>(); set.add("js.local:/tests/ajaxDedup/sample4.js"); set.add("js.local:/tests/ajaxDedup/sample1.js"); set.add("js.inline:/dffoyfpm0yzvdbg1p025pkmixin"); set.add("js.local:/tests/table.js"); set.add("js.local:/tests/ajaxDedup/sample3.js"); model.getCollectedResource("js").addAll(set); String token = ctx.getDeDupToken("js"); Assert.assertEquals("p5ezkcqygu0qfam5grb2phojo23", token); }