diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java index ae8b86c493..fed3f3b049 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java @@ -24,7 +24,6 @@ import static org.jclouds.blobstore.options.GetOptions.Builder.ifModifiedSince; import static org.jclouds.blobstore.options.GetOptions.Builder.ifUnmodifiedSince; import static org.jclouds.blobstore.options.GetOptions.Builder.range; import static org.jclouds.concurrent.FutureIterables.awaitCompletion; -import static org.jclouds.io.ByteSources.asByteSource; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; @@ -105,7 +104,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { } protected static byte[] md5Supplier(InputSupplier supplier) throws IOException { - return asByteSource(supplier.getInput()).hash(md5()).asBytes(); + return ByteStreams.hash(supplier, md5()).asBytes(); } @SuppressWarnings("unchecked") diff --git a/core/src/main/java/org/jclouds/io/Payloads.java b/core/src/main/java/org/jclouds/io/Payloads.java index 790a0af949..620a5144f7 100644 --- a/core/src/main/java/org/jclouds/io/Payloads.java +++ b/core/src/main/java/org/jclouds/io/Payloads.java @@ -18,7 +18,6 @@ package org.jclouds.io; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.hash.Hashing.md5; import static com.google.common.io.ByteStreams.toByteArray; -import static org.jclouds.io.ByteSources.asByteSource; import java.io.File; import java.io.IOException; @@ -31,6 +30,7 @@ import org.jclouds.io.payloads.StringPayload; import org.jclouds.io.payloads.UrlEncodedFormPayload; import com.google.common.collect.Multimap; +import com.google.common.io.ByteStreams; /** * @@ -102,7 +102,7 @@ public class Payloads { oldContentMetadata.setContentMD5(payload.getContentMetadata().getContentMD5()); payload.setContentMetadata(oldContentMetadata); } - payload.getContentMetadata().setContentMD5(asByteSource(payload.getInput()).hash(md5()).asBytes()); + payload.getContentMetadata().setContentMD5(ByteStreams.hash(payload, md5()).asBytes()); return payload; } diff --git a/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java b/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java index 25c12fe009..980ed96bdc 100644 --- a/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java +++ b/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java @@ -21,6 +21,7 @@ import static com.google.common.io.BaseEncoding.base64; import static com.google.common.io.Closeables.closeQuietly; import static java.lang.String.format; import static org.jclouds.http.options.GetOptions.Builder.tail; +import static org.jclouds.io.ByteSources.asByteSource; import static org.jclouds.io.Payloads.newFilePayload; import static org.jclouds.io.Payloads.newStringPayload; import static org.jclouds.util.Throwables2.getFirstThrowableOfType; @@ -45,7 +46,6 @@ import org.testng.annotations.Test; import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; -import com.google.common.io.ByteSource; import com.google.common.io.CharSink; import com.google.common.io.Files; @@ -131,12 +131,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base } private void assertValidMd5(final InputStream input) throws IOException { - assertEquals(base64().encode(new ByteSource() { - @Override - public InputStream openStream() { - return input; - } - }.hash(md5()).asBytes()), md5); + assertEquals(base64().encode(asByteSource(input).hash(md5()).asBytes()), md5); } private InputStream getConsitution() throws MalformedURLException, IOException { diff --git a/core/src/test/java/org/jclouds/http/BaseJettyTest.java b/core/src/test/java/org/jclouds/http/BaseJettyTest.java index 7fabb76fae..76d3dbcd5a 100644 --- a/core/src/test/java/org/jclouds/http/BaseJettyTest.java +++ b/core/src/test/java/org/jclouds/http/BaseJettyTest.java @@ -70,6 +70,7 @@ import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableSet; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; +import com.google.common.io.ByteStreams; import com.google.common.io.InputSupplier; import com.google.inject.Injector; import com.google.inject.Module; @@ -94,7 +95,7 @@ public abstract class BaseJettyTest { this.testPort = testPort; final InputSupplier oneHundredOneConstitutions = getTestDataSupplier(); - md5 = base64().encode(asByteSource(oneHundredOneConstitutions.getInput()).hash(md5()).asBytes()); + md5 = base64().encode(ByteStreams.hash(oneHundredOneConstitutions, md5()).asBytes()); Handler server1Handler = new AbstractHandler() { public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java index 0923f4c0bc..eb53854f3c 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java @@ -23,7 +23,6 @@ import static org.easymock.EasyMock.createMock; import static org.eclipse.jetty.http.HttpHeaders.TRANSFER_ENCODING; import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; import static org.jclouds.Constants.PROPERTY_USER_THREADS; -import static org.jclouds.io.ByteSources.asByteSource; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; @@ -50,6 +49,7 @@ import org.testng.annotations.Test; import com.google.common.collect.Multimap; import com.google.common.collect.SortedSetMultimap; import com.google.common.collect.TreeMultimap; +import com.google.common.io.ByteStreams; import com.google.common.reflect.Invokable; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.SimpleTimeLimiter; @@ -125,7 +125,7 @@ public abstract class BaseRestApiTest { Long length = Long.valueOf(payload.getBytes().length); try { assertContentHeadersEqual(request, contentType, contentDispositon, contentEncoding, contentLanguage, - length, contentMD5 ? asByteSource(request.getPayload().getInput()).hash(md5()).asBytes() : null, expires); + length, contentMD5 ? ByteStreams.hash(request.getPayload(), md5()).asBytes() : null, expires); } catch (IOException e) { propagate(e); } diff --git a/drivers/apachehc/src/main/java/org/jclouds/http/apachehc/ApacheHCHttpCommandExecutorService.java b/drivers/apachehc/src/main/java/org/jclouds/http/apachehc/ApacheHCHttpCommandExecutorService.java index f94b07af91..6943fe7d71 100644 --- a/drivers/apachehc/src/main/java/org/jclouds/http/apachehc/ApacheHCHttpCommandExecutorService.java +++ b/drivers/apachehc/src/main/java/org/jclouds/http/apachehc/ApacheHCHttpCommandExecutorService.java @@ -18,7 +18,6 @@ package org.jclouds.http.apachehc; import static com.google.common.hash.Hashing.md5; import static com.google.common.io.BaseEncoding.base64; import static org.jclouds.http.HttpUtils.filterOutContentHeaders; -import static org.jclouds.io.ByteSources.asByteSource; import java.io.IOException; import java.net.URI; @@ -45,6 +44,7 @@ import org.jclouds.io.Payloads; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; +import com.google.common.io.ByteStreams; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.Inject; @@ -72,7 +72,7 @@ public class ApacheHCHttpCommandExecutorService extends BaseHttpCommandExecutorS protected HttpUriRequest convert(HttpRequest request) throws IOException { HttpUriRequest returnVal = apacheHCUtils.convertToApacheRequest(request); if (request.getPayload() != null && request.getPayload().getContentMetadata().getContentMD5() != null) { - String md5 = base64().encode(asByteSource(request.getPayload().getInput()).hash(md5()).asBytes()); + String md5 = base64().encode(ByteStreams.hash(request.getPayload(), md5()).asBytes()); returnVal.addHeader("Content-MD5", md5); } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java index 847170e313..cb5a8a23d8 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java @@ -21,7 +21,6 @@ import static com.google.common.io.ByteStreams.join; import static com.google.common.io.ByteStreams.newInputStreamSupplier; import static com.google.common.io.ByteStreams.toByteArray; import static org.jclouds.aws.s3.blobstore.options.AWSS3PutOptions.Builder.storageClass; -import static org.jclouds.io.ByteSources.asByteSource; import static org.jclouds.io.Payloads.newByteArrayPayload; import static org.jclouds.s3.options.ListBucketOptions.Builder.withPrefix; import static org.testng.Assert.assertEquals; @@ -62,6 +61,7 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.io.ByteStreams; import com.google.common.io.Files; import com.google.common.io.InputSupplier; @@ -89,7 +89,7 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest { public void setUpResourcesOnThisThread(ITestContext testContext) throws Exception { super.setUpResourcesOnThisThread(testContext); oneHundredOneConstitutions = getTestDataSupplier(); - oneHundredOneConstitutionsMD5 = asByteSource(oneHundredOneConstitutions.getInput()).hash(md5()).asBytes(); + oneHundredOneConstitutionsMD5 = ByteStreams.hash(oneHundredOneConstitutions, md5()).asBytes(); } @SuppressWarnings("unchecked") diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobIntegrationLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobIntegrationLiveTest.java index a7b104d12c..918759c882 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobIntegrationLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobIntegrationLiveTest.java @@ -35,7 +35,6 @@ import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; import static com.google.common.hash.Hashing.md5; -import static org.jclouds.io.ByteSources.asByteSource; /** * @@ -82,7 +81,7 @@ public class AzureBlobIntegrationLiveTest extends BaseBlobIntegrationTest { */ public void testMultipartChunkedFileStream() throws IOException, InterruptedException { oneHundredOneConstitutions = getTestDataSupplier(); - oneHundredOneConstitutionsMD5 = asByteSource(oneHundredOneConstitutions.getInput()).hash(md5()).asBytes(); + oneHundredOneConstitutionsMD5 = ByteStreams.hash(oneHundredOneConstitutions, md5()).asBytes(); File file = new File("target/const.txt"); Files.copy(oneHundredOneConstitutions, file); String containerName = getContainerName();