aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/util/FingerprintTest.java
diff options
context:
space:
mode:
authorGravatar Michajlo Matijkiw <michajlo@google.com>2016-11-30 18:59:59 +0000
committerGravatar Irina Iancu <elenairina@google.com>2016-12-01 10:15:39 +0000
commit43ad03290228adc8187853f83be073119c6f9aaa (patch)
tree12192e2ad39db9c10141e4f91f98fc43f832b814 /src/test/java/com/google/devtools/build/lib/util/FingerprintTest.java
parent1f95a4e35b19bea98dbaca3130729c2465b85f95 (diff)
Use MessageDigest instead of HashFunction for Fingerprint
This allows us to reset and reuse the underlying digest implementation, which guava's HashFunction doesn't allow. We do take the clone-if-possible page out of guava's book. -- MOS_MIGRATED_REVID=140624836
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/util/FingerprintTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/util/FingerprintTest.java23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/util/FingerprintTest.java b/src/test/java/com/google/devtools/build/lib/util/FingerprintTest.java
index 15a826482b..22e9fe79b7 100644
--- a/src/test/java/com/google/devtools/build/lib/util/FingerprintTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/FingerprintTest.java
@@ -20,14 +20,12 @@ import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* Tests for Fingerprint.
@@ -56,9 +54,10 @@ public class FingerprintTest {
// echo -n 'Hello World!'| md5sum
@Test
public void bytesFingerprint() {
- assertThat("ed076287532e86365e841e92bfc50d8c").isEqualTo(
- new Fingerprint().addBytes("Hello World!".getBytes(UTF_8)).hexDigestAndReset());
- assertThat("ed076287532e86365e841e92bfc50d8c").isEqualTo(Fingerprint.md5Digest("Hello World!"));
+ assertThat(new Fingerprint().addBytes("Hello World!".getBytes(UTF_8)).hexDigestAndReset())
+ .isEqualTo("ed076287532e86365e841e92bfc50d8c");
+ assertThat(Fingerprint.md5Digest("Hello World!"))
+ .isEqualTo("ed076287532e86365e841e92bfc50d8c");
}
@Test
@@ -113,11 +112,11 @@ public class FingerprintTest {
@Test
public void addPath() throws Exception {
PathFragment pf = new PathFragment("/etc/pwd");
- assertThat("01cc3eeea3a2f58e447e824f9f62d3d1").isEqualTo(
- new Fingerprint().addPath(pf).hexDigestAndReset());
+ assertThat(new Fingerprint().addPath(pf).hexDigestAndReset())
+ .isEqualTo("01cc3eeea3a2f58e447e824f9f62d3d1");
Path p = new InMemoryFileSystem(BlazeClock.instance()).getPath(pf);
- assertThat("01cc3eeea3a2f58e447e824f9f62d3d1").isEqualTo(
- new Fingerprint().addPath(p).hexDigestAndReset());
+ assertThat(new Fingerprint().addPath(p).hexDigestAndReset())
+ .isEqualTo("01cc3eeea3a2f58e447e824f9f62d3d1");
}
@Test