use of com.google.common.hash.HashCode in project riposte by Nike-Inc.
the class VerifyMultipartRequestsWorkComponentTest method getHashForMultipartPayload.
private static String getHashForMultipartPayload(String name, String filename, byte[] payloadBytes) {
Hasher hasher = hashFunction.newHasher().putString(name, Charsets.UTF_8);
if (filename != null)
hasher = hasher.putString(filename, Charsets.UTF_8);
hasher = hasher.putBytes(payloadBytes);
HashCode hc = hasher.hash();
return hc.toString();
}
use of com.google.common.hash.HashCode in project riposte by Nike-Inc.
the class VerifyPayloadHandlingComponentTest method getHashForPayload.
/**
* @return The MD5 hash of the given payload. This can be used to verify correctness when sending payloads across the wire.
*/
private static String getHashForPayload(byte[] payloadBytes) {
Hasher hasher = hashFunction.newHasher();
hasher = hasher.putBytes(payloadBytes);
HashCode hc = hasher.hash();
return hc.toString();
}
use of com.google.common.hash.HashCode in project android by JetBrains.
the class GradleInstantRunAndroidTest method testResourceChangeIsDetected.
public void testResourceChangeIsDetected() throws Exception {
myFixture.copyFileToProject(BASEDIR + "AndroidManifest.xml", SdkConstants.FN_ANDROID_MANIFEST_XML);
myFixture.copyFileToProject(BASEDIR + "res/values/strings.xml", "res/values/strings.xml");
myFixture.copyFileToProject(BASEDIR + "res/drawable-hdpi/ic_launcher.png", "res/drawable-hdpi/ic_launcher.png");
HashCode hash = GradleInstantRunContext.getManifestResourcesHash(myFacet);
// change a resource not referenced from manifest
AppResourceRepository repository = AppResourceRepository.create(myFacet);
ResourceValue resValue = repository.getConfiguredValue(ResourceType.STRING, "title_section1", new FolderConfiguration());
resValue.setValue("foo");
assertEquals("Hash should not change if a resource not referenced from the manifest is changed", hash, GradleInstantRunContext.getManifestResourcesHash(myFacet));
// change the app_name referenced from manifest
resValue = repository.getConfiguredValue(ResourceType.STRING, "app_name", new FolderConfiguration());
resValue.setValue("testapp");
assertNotEquals("Hash should change if a resource referenced from the manifest is changed", hash, GradleInstantRunContext.getManifestResourcesHash(myFacet));
// change the contents of the launcher icon referenced from manifest
hash = GradleInstantRunContext.getManifestResourcesHash(myFacet);
myFixture.copyFileToProject(BASEDIR + "res/drawable-mdpi/ic_launcher.png", "res/drawable-hdpi/ic_launcher.png");
assertNotEquals("Hash should change if a resource referenced from the manifest is changed", hash, GradleInstantRunContext.getManifestResourcesHash(myFacet));
}
use of com.google.common.hash.HashCode in project android by JetBrains.
the class InstantRunBuilderTest method setUpDeviceForHotSwap.
private void setUpDeviceForHotSwap() {
HashCode resourcesHash = HashCode.fromInt(1);
myInstalledPatchCache.setInstalledManifestResourcesHash(myDevice, APPLICATION_ID, resourcesHash);
when(myInstantRunContext.getManifestResourcesHash()).thenReturn(resourcesHash);
}
use of com.google.common.hash.HashCode in project gitiles by GerritCodeReview.
the class Renderer method getTemplateHash.
public HashCode getTemplateHash(String soyFile) {
HashCode h = hashes.get(soyFile);
if (h == null) {
h = computeTemplateHash(soyFile);
hashes.put(soyFile, h);
}
return h;
}
Aggregations