### Question:
DefaultJsVersioner implements Versioner { public String version(final JsUri jsUri) { GadgetContext ctx = new GadgetContext() { @Override public String getContainer() { return jsUri.getContainer(); } @Override public RenderingContext getRenderingContext() { return jsUri.getContext(); } }; List<FeatureResource> resources = registry.getFeatureResources(ctx, jsUri.getLibs(), null).getResources(); if (versionCache.containsKey(resources)) { return versionCache.get(resources); } StringBuilder jsBuf = new StringBuilder(); for (FeatureResource resource : resources) { jsBuf.append(resource.getContent()).append(resource.getDebugContent()); } String checksum = HashUtil.checksum(jsBuf.toString().getBytes()); versionCache.put(resources, checksum); return checksum; } @Inject  DefaultJsVersioner(FeatureRegistry registry); String version(final JsUri jsUri); UriStatus validate(JsUri jsUri, String version);  }### Answer:
@Test public void versionCached() { String feature = "feature1"; expectReq(feature, "content"); replay(registry); Collection<String> libs = Lists.newArrayList(feature); JsUri jsUri = new JsUri(UriStatus.VALID_UNVERSIONED, null, libs, null); String version = versioner.version(jsUri); assertNotNull(version); String versionAgain = versioner.version(jsUri); assertSame(version, versionAgain); verify(registry); }
@Test public void versionDifferentForDifferentFeatures() { String feature1 = "feature1"; String feature2 = "feature2"; expectReq(feature1, "content1"); expectReq(feature2, "content2"); replay(registry); Collection<String> libs1 = Lists.newArrayList(feature1); JsUri jsUri1 = new JsUri(UriStatus.VALID_UNVERSIONED, null, libs1, null); String version1 = versioner.version(jsUri1); Collection<String> libs2 = Lists.newArrayList(feature2); JsUri jsUri2 = new JsUri(UriStatus.VALID_UNVERSIONED, null, libs2, null); String version2 = versioner.version(jsUri2); assertNotNull(version1); assertNotNull(version2); assertFalse(version1.equals(version2)); verify(registry); }