You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2014/04/12 21:04:47 UTC

git commit: Address several Guava InputSupplier deprecations

Repository: jclouds
Updated Branches:
  refs/heads/master 7af18d484 -> d0bd30cc1


Address several Guava InputSupplier deprecations

Many remain due to Payload implementing InputSupplier<InputStream>.  Guava 18
will remove InputSupplier.


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

Branch: refs/heads/master
Commit: d0bd30cc15f877248ee2ab457855c3fda6f78edd
Parents: 7af18d4
Author: Andrew Gaul <ga...@apache.org>
Authored: Fri Apr 11 22:25:16 2014 -0700
Committer: Andrew Gaul <ga...@apache.org>
Committed: Sat Apr 12 12:02:26 2014 -0700

----------------------------------------------------------------------
 .../strategy/internal/FilesystemStorageStrategyImplTest.java | 5 ++---
 .../test/java/org/jclouds/filesystem/utils/TestUtils.java    | 4 ++--
 .../blobstore/integration/SwiftBlobIntegrationLiveTest.java  | 2 +-
 .../integration/internal/BaseBlobIntegrationTest.java        | 8 ++++----
 core/src/main/java/org/jclouds/logging/internal/Wire.java    | 2 +-
 .../http/BaseHttpCommandExecutorServiceIntegrationTest.java  | 2 +-
 core/src/test/java/org/jclouds/http/BaseJettyTest.java       | 3 +--
 .../test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java    | 2 +-
 .../blobstore/integration/AzureBlobIntegrationLiveTest.java  | 4 ++--
 .../functionloader/filters/LicenseHeaderFilter.java          | 5 ++---
 10 files changed, 17 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/d0bd30cc/apis/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java
index 96a2181..f7eab9b 100644
--- a/apis/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java
+++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java
@@ -48,7 +48,6 @@ import org.testng.annotations.Test;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import com.google.common.io.ByteSource;
-import com.google.common.io.ByteStreams;
 import com.google.common.io.Files;
 
 /**
@@ -356,7 +355,7 @@ public class FilesystemStorageStrategyImplTest {
       File blobFullPath = new File(TARGET_CONTAINER_NAME, blobKey);
       ByteSource expectedInput = Files.asByteSource(sourceFile);
       ByteSource actualInput = Files.asByteSource(blobFullPath);
-      assertTrue(ByteStreams.equal(expectedInput, actualInput),
+      assertTrue(expectedInput.contentEquals(actualInput),
             "Files are not equal");
    }
 
@@ -375,7 +374,7 @@ public class FilesystemStorageStrategyImplTest {
       File blobFullPath = new File(TARGET_CONTAINER_NAME, blobKey);
       ByteSource expectedInput = Files.asByteSource(sourceFile);
       ByteSource actualInput = Files.asByteSource(blobFullPath);
-      assertTrue(ByteStreams.equal(expectedInput, actualInput),
+      assertTrue(expectedInput.contentEquals(actualInput),
             "Files are not equal");
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds/blob/d0bd30cc/apis/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java
----------------------------------------------------------------------
diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java
index 3b9159f..c27f895 100644
--- a/apis/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java
+++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java
@@ -31,7 +31,7 @@ import org.jclouds.filesystem.util.Utils;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterators;
 import com.google.common.collect.Sets;
-import com.google.common.io.ByteStreams;
+import com.google.common.io.ByteSource;
 import com.google.common.io.Files;
 
 /**
@@ -218,7 +218,7 @@ public class TestUtils {
         for (File file : IMAGE_RESOURCES) {
             byte[] buffer = new byte[random.nextInt(2 * 1024 * 1024)];
             random.nextBytes(buffer);
-            Files.copy(ByteStreams.newInputStreamSupplier(buffer), file);
+            ByteSource.wrap(buffer).copyTo(Files.asByteSink(file));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/jclouds/blob/d0bd30cc/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java
index 64b828a..e05d792 100644
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java
+++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java
@@ -183,7 +183,7 @@ public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
       }
 
       File fileToUpload = new File("target/lots-of-const.txt");
-      Files.copy(temp, fileToUpload);
+      temp.copyTo(Files.asByteSink(fileToUpload));
 
       assertTrue(fileToUpload.length() > partSize);
       return fileToUpload;

http://git-wip-us.apache.org/repos/asf/jclouds/blob/d0bd30cc/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java
----------------------------------------------------------------------
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 dfedeeb..c454cd2 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
@@ -135,7 +135,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
    public void testPutFileParallel() throws InterruptedException, IOException, TimeoutException {
 
       File payloadFile = File.createTempFile("testPutFileParallel", "png");
-      Files.copy(createTestInput(32 * 1024), payloadFile);
+      createTestInput(32 * 1024).copyTo(Files.asByteSink(payloadFile));
       
       final Payload testPayload = Payloads.newFilePayload(payloadFile);
       final byte[] md5 = md5Supplier(testPayload);
@@ -225,7 +225,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
             .payload(new InputStreamSupplierPayload(supplier))
             .contentType("text/plain")
             .contentMD5(supplier.hash(md5()).asBytes())
-            .contentLength(ByteStreams.length(supplier))
+            .contentLength(supplier.size())
             .contentDisposition(contentDisposition)
             .build());
    }
@@ -297,14 +297,14 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
 
    @Test(groups = { "integration", "live" })
    public void testPutCorrectContentMD5() throws InterruptedException, IOException {
-      byte[] payload = ByteStreams.toByteArray(createTestInput(1024));
+      byte[] payload = createTestInput(1024).read();
       HashCode contentMD5 = md5().hashBytes(payload);
       putBlobWithMd5(payload, contentMD5);
    }
 
    @Test(groups = { "integration", "live" })
    public void testPutIncorrectContentMD5() throws InterruptedException, IOException {
-      byte[] payload = ByteStreams.toByteArray(createTestInput(1024));
+      byte[] payload = createTestInput(1024).read();
       HashCode contentMD5 = md5().hashBytes(new byte[0]);
       try {
          putBlobWithMd5(payload, contentMD5);

http://git-wip-us.apache.org/repos/asf/jclouds/blob/d0bd30cc/core/src/main/java/org/jclouds/logging/internal/Wire.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/logging/internal/Wire.java b/core/src/main/java/org/jclouds/logging/internal/Wire.java
index fbc0b84..893fa07 100644
--- a/core/src/main/java/org/jclouds/logging/internal/Wire.java
+++ b/core/src/main/java/org/jclouds/logging/internal/Wire.java
@@ -100,7 +100,7 @@ public abstract class Wire {
             is.close();
          }
          // we must call FileBackedOutputStream.reset to remove temporary file
-         return new FilterInputStream(out.asByteSource().getInput()) {
+         return new FilterInputStream(out.asByteSource().openStream()) {
             @Override
             public void close() throws IOException {
                super.close();

http://git-wip-us.apache.org/repos/asf/jclouds/blob/d0bd30cc/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 0de5181..7c6e7fe 100644
--- a/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
+++ b/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
@@ -227,7 +227,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
    public void testGetBigFile() throws Exception {
       MockResponse response = new MockResponse().addHeader("Content-MD5", constitutionsMd5)
             .addHeader("Content-type", "text/plain")
-            .setBody(oneHundredOneConstitutions.getInput(), constitutionsLength);
+            .setBody(oneHundredOneConstitutions.openStream(), constitutionsLength);
 
       MockWebServer server = mockWebServer(response, response);
       InputStream input = server.getUrl("/101constitutions").openStream();

http://git-wip-us.apache.org/repos/asf/jclouds/blob/d0bd30cc/core/src/test/java/org/jclouds/http/BaseJettyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/jclouds/http/BaseJettyTest.java b/core/src/test/java/org/jclouds/http/BaseJettyTest.java
index 056a134..2541412 100644
--- a/core/src/test/java/org/jclouds/http/BaseJettyTest.java
+++ b/core/src/test/java/org/jclouds/http/BaseJettyTest.java
@@ -19,7 +19,6 @@ package org.jclouds.http;
 import static com.google.common.base.Throwables.getStackTraceAsString;
 import static com.google.common.hash.Hashing.md5;
 import static com.google.common.io.BaseEncoding.base64;
-import static com.google.common.io.ByteStreams.copy;
 import static com.google.common.io.ByteStreams.toByteArray;
 import static com.google.common.net.HttpHeaders.CONTENT_DISPOSITION;
 import static com.google.common.net.HttpHeaders.CONTENT_ENCODING;
@@ -114,7 +113,7 @@ public abstract class BaseJettyTest {
                response.setContentType("text/plain");
                response.setHeader("Content-MD5", md5);
                response.setStatus(SC_OK);
-               copy(oneHundredOneConstitutions, response.getOutputStream());
+               oneHundredOneConstitutions.copyTo(response.getOutputStream());
             } else if (request.getMethod().equals("PUT")) {
                if (request.getContentLength() > 0) {
                   response.setStatus(SC_OK);

http://git-wip-us.apache.org/repos/asf/jclouds/blob/d0bd30cc/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java
----------------------------------------------------------------------
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 3af30fd..49d3010 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
@@ -149,7 +149,7 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest {
    public void testMultipartChunkedFileStream() throws IOException, InterruptedException {
       
       File file = new File("target/const.txt");
-      Files.copy(oneHundredOneConstitutions, file);
+      oneHundredOneConstitutions.copyTo(Files.asByteSink(file));
       String containerName = getContainerName();
       
       try {

http://git-wip-us.apache.org/repos/asf/jclouds/blob/d0bd30cc/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobIntegrationLiveTest.java
----------------------------------------------------------------------
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 ba64e8f..2c4060f 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
@@ -81,7 +81,7 @@ public class AzureBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
       oneHundredOneConstitutions = getTestDataSupplier();
       oneHundredOneConstitutionsMD5 = oneHundredOneConstitutions.hash(md5()).asBytes();
       File file = new File("target/const.txt");
-      Files.copy(oneHundredOneConstitutions, file);
+      oneHundredOneConstitutions.copyTo(Files.asByteSink(file));
       String containerName = getContainerName();
 
       try {
@@ -100,7 +100,7 @@ public class AzureBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
       final long limit = MultipartUploadStrategy.MAX_BLOCK_SIZE;
       ByteSource input = repeatingArrayByteSource(new byte[1024]).slice(0, limit);
       File file = new File("target/const.txt");
-      Files.copy(input, file);
+      input.copyTo(Files.asByteSink(file));
       String containerName = getContainerName();
 
       try {

http://git-wip-us.apache.org/repos/asf/jclouds/blob/d0bd30cc/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/filters/LicenseHeaderFilter.java
----------------------------------------------------------------------
diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/filters/LicenseHeaderFilter.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/filters/LicenseHeaderFilter.java
index c84e42e..ed31362 100644
--- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/filters/LicenseHeaderFilter.java
+++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/filters/LicenseHeaderFilter.java
@@ -16,8 +16,6 @@
  */
 package org.jclouds.scriptbuilder.functionloader.filters;
 import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.io.CharStreams.newReaderSupplier;
-import static com.google.common.io.CharStreams.readLines;
 
 import java.io.IOException;
 
@@ -26,6 +24,7 @@ import org.jclouds.scriptbuilder.domain.ShellToken;
 import org.jclouds.scriptbuilder.functionloader.FunctionLoader;
 import org.jclouds.scriptbuilder.functionloader.FunctionNotFoundException;
 
+import com.google.common.io.CharSource;
 import com.google.common.io.LineProcessor;
 
 /**
@@ -55,7 +54,7 @@ public class LicenseHeaderFilter implements FunctionLoader {
     */
    public String filter(String lines, OsFamily family) {
       try {
-         return readLines(newReaderSupplier(checkNotNull(lines, "lines")),
+         return CharSource.wrap(checkNotNull(lines, "lines")).readLines(
                new LicenseHeaderProcessor(checkNotNull(family, "family")));
       } catch (IOException e) {
          // Don't fail; just return the original text with the comments