Search in sources :

Example 46 with HashCode

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();
}
Also used : Hasher(com.google.common.hash.Hasher) HashCode(com.google.common.hash.HashCode)

Example 47 with HashCode

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();
}
Also used : Hasher(com.google.common.hash.Hasher) HashCode(com.google.common.hash.HashCode)

Example 48 with HashCode

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));
}
Also used : HashCode(com.google.common.hash.HashCode) ResourceValue(com.android.ide.common.rendering.api.ResourceValue) AppResourceRepository(com.android.tools.idea.res.AppResourceRepository) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration)

Example 49 with HashCode

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);
}
Also used : HashCode(com.google.common.hash.HashCode)

Example 50 with HashCode

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;
}
Also used : HashCode(com.google.common.hash.HashCode)

Aggregations

HashCode (com.google.common.hash.HashCode)115 Path (java.nio.file.Path)41 Test (org.junit.Test)39 BuildTarget (com.facebook.buck.model.BuildTarget)19 FakeFileHashCache (com.facebook.buck.testutil.FakeFileHashCache)13 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)12 ImmutableMap (com.google.common.collect.ImmutableMap)12 IOException (java.io.IOException)12 PathSourcePath (com.facebook.buck.rules.PathSourcePath)11 FileHashCache (com.facebook.buck.util.cache.FileHashCache)11 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)10 Sha1HashCode (com.facebook.buck.util.sha1.Sha1HashCode)10 Hasher (com.google.common.hash.Hasher)10 Map (java.util.Map)8 UnflavoredBuildTarget (com.facebook.buck.model.UnflavoredBuildTarget)7 SourcePath (com.facebook.buck.rules.SourcePath)7 BuckEventBus (com.facebook.buck.event.BuckEventBus)6 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)6 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)5 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)5