Repository: jclouds
Updated Branches:
  refs/heads/master 644fbf205 -> 4c265d316


Prefer Guava Hashing over MessageDigest


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/4c265d31
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/4c265d31
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/4c265d31

Branch: refs/heads/master
Commit: 4c265d31687f261fa4ad52726f9866fb7005d696
Parents: 644fbf2
Author: Andrew Gaul <[email protected]>
Authored: Thu May 22 09:40:06 2014 -0700
Committer: Andrew Gaul <[email protected]>
Committed: Thu May 22 09:40:06 2014 -0700

----------------------------------------------------------------------
 ...HttpCommandExecutorServiceIntegrationTest.java | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c265d31/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
 
b/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
index 7c6e7fe..f3c2729 100644
--- 
a/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
+++ 
b/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
@@ -34,8 +34,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.Writer;
 import java.net.URLDecoder;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
 import java.util.Random;
 import java.util.zip.GZIPInputStream;
 
@@ -280,23 +278,21 @@ public abstract class 
BaseHttpCommandExecutorServiceIntegrationTest extends Base
          f.deleteOnExit();
          long length = (new Random().nextInt(32) + 1) * 1024 * 1024;
 
-         MessageDigest digester = md5Digest();
-
          CharSink fileSink = Files.asCharSink(f, Charsets.UTF_8);
          Writer out = null;
          try {
             out = fileSink.openStream();
             for (long i = 0; i < length; i++) {
                out.append('a');
-               digester.update((byte) 'a');
             }
             out.flush();
          } finally {
             close(out, true);
          }
 
-         payload = newByteSourcePayload(asByteSource(f));
-         byte[] digest = digester.digest();
+         ByteSource byteSource = asByteSource(f);
+         payload = newByteSourcePayload(byteSource);
+         byte[] digest = byteSource.hash(md5()).asBytes();
          String strDigest = base64().encode(digest);
 
          payload.getContentMetadata().setContentMD5(digest);
@@ -317,14 +313,6 @@ public abstract class 
BaseHttpCommandExecutorServiceIntegrationTest extends Base
       }
    }
 
-   private MessageDigest md5Digest() throws AssertionError {
-      try {
-         return MessageDigest.getInstance("MD5");
-      } catch (NoSuchAlgorithmException e) {
-         throw new AssertionError(e);
-      }
-   }
-
    @Test
    public void testPost() throws Exception {
       MockWebServer server = mockWebServer(new 
MockResponse().setBody("fooPOST"));

Reply via email to