diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java index 38d92d631f..ccbfbf6930 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java @@ -58,13 +58,13 @@ import org.jclouds.io.InputSuppliers; import org.jclouds.io.Payload; import org.jclouds.io.payloads.PhantomPayload; import org.jclouds.io.payloads.StringPayload; +import org.jclouds.util.Strings2; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import com.google.common.base.Charsets; import com.google.common.io.ByteStreams; -import com.google.common.io.CharStreams; import com.google.common.io.Closeables; import com.google.common.io.Files; import com.google.common.io.InputSupplier; @@ -742,7 +742,7 @@ public class FilesystemAsyncBlobStoreTest { Blob blobRangeStartAt = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeStartAt); payload = blobRangeStartAt.getPayload(); try { - assertEquals(input.substring(1), CharStreams.toString(CharStreams.newReaderSupplier(payload, Charsets.UTF_8))); + assertEquals(input.substring(1), Strings2.toString(payload)); } finally { Closeables.closeQuietly(payload); } @@ -752,7 +752,7 @@ public class FilesystemAsyncBlobStoreTest { Blob blobRangeTail = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeTail); payload = blobRangeTail.getPayload(); try { - assertEquals(input.substring(5), CharStreams.toString(CharStreams.newReaderSupplier(payload, Charsets.UTF_8))); + assertEquals(input.substring(5), Strings2.toString(payload)); } finally { Closeables.closeQuietly(payload); } @@ -762,7 +762,7 @@ public class FilesystemAsyncBlobStoreTest { Blob blobFragment = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsFragment); payload = blobFragment.getPayload(); try { - assertEquals(input.substring(4, 7), CharStreams.toString(CharStreams.newReaderSupplier(payload, Charsets.UTF_8))); + assertEquals(input.substring(4, 7), Strings2.toString(payload)); } finally { Closeables.closeQuietly(payload); } 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 a2b4a08392..6966e041ec 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 @@ -93,7 +93,7 @@ public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest { public void testMultipartChunkedFileStream() throws IOException, InterruptedException { FileOutputStream fous = new FileOutputStream(new File("target/const.txt")); - ByteStreams.copy(oneHundredOneConstitutions.getInput(), fous); + ByteStreams.copy(oneHundredOneConstitutions, fous); fous.flush(); fous.close(); String containerName = getContainerName(); diff --git a/core/src/test/java/org/jclouds/http/BaseJettyTest.java b/core/src/test/java/org/jclouds/http/BaseJettyTest.java index 68055e507a..f2b7e8105d 100644 --- a/core/src/test/java/org/jclouds/http/BaseJettyTest.java +++ b/core/src/test/java/org/jclouds/http/BaseJettyTest.java @@ -115,7 +115,7 @@ public abstract class BaseJettyTest { response.setContentType("text/plain"); response.setHeader("Content-MD5", md5); response.setStatus(HttpServletResponse.SC_OK); - copy(oneHundredOneConstitutions.getInput(), response.getOutputStream()); + copy(oneHundredOneConstitutions, response.getOutputStream()); } else if (request.getMethod().equals("PUT")) { if (request.getContentLength() > 0) { response.setStatus(HttpServletResponse.SC_OK); diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeApiLiveTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeApiLiveTest.java index 570345c0f3..b05b1ee9f0 100644 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeApiLiveTest.java +++ b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeApiLiveTest.java @@ -43,6 +43,7 @@ import org.jclouds.snia.cdmi.v1.domain.DataObject; import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiLiveTest; import org.jclouds.snia.cdmi.v1.options.CreateContainerOptions; import org.jclouds.snia.cdmi.v1.queryparams.DataObjectQueryParams; +import org.jclouds.util.Strings2; import org.testng.annotations.Test; import com.google.common.base.Charsets; @@ -100,7 +101,7 @@ public class DataNonCDMIContentTypeApiLiveTest extends BaseCDMIApiLiveTest { dataNonCDMIContentTypeApi.create(dataObjectNameIn, value); payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); assertNotNull(payloadOut); - assertEquals(CharStreams.toString(new InputStreamReader(payloadOut.getInput(), "UTF-8")), value); + assertEquals(Strings2.toString(payloadOut), value); payloadIn = new StringPayload(value); payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata() @@ -109,7 +110,7 @@ public class DataNonCDMIContentTypeApiLiveTest extends BaseCDMIApiLiveTest { payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); assertNotNull(payloadOut); - assertEquals(CharStreams.toString(new InputStreamReader(payloadOut.getInput(), "UTF-8")), value); + assertEquals(Strings2.toString(payloadOut), value); dataObject = dataNonCDMIContentTypeApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI")); assertNotNull(dataObject); @@ -149,7 +150,7 @@ public class DataNonCDMIContentTypeApiLiveTest extends BaseCDMIApiLiveTest { assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); assertNotNull(payloadOut); - assertEquals(CharStreams.toString(new InputStreamReader(payloadOut.getInput(), "UTF-8")), value); + assertEquals(Strings2.toString(payloadOut), value); dataNonCDMIContentTypeApi.delete(dataObjectNameIn); assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); @@ -181,12 +182,11 @@ public class DataNonCDMIContentTypeApiLiveTest extends BaseCDMIApiLiveTest { payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); assertNotNull(payloadOut); - // assertEquals(CharStreams.toString(new InputStreamReader(payloadOut.getInput(), - // "UTF-8")),value); - // byte[] _bytes = ByteStreams.toByteArray(payloadOut.getInput()); + // assertEquals(Strings2.toString(payloadOut), value); + // byte[] _bytes = ByteStreams.toByteArray(payloadOut); tmpFileOut = new File(Files.createTempDir(), "temp.txt"); fos = new FileOutputStream(tmpFileOut); - ByteStreams.copy(payloadOut.getInput(), fos); + ByteStreams.copy(payloadOut, fos); fos.flush(); fos.close(); assertEquals(Files.equal(tmpFileOut, tmpFileIn), true); @@ -237,7 +237,7 @@ public class DataNonCDMIContentTypeApiLiveTest extends BaseCDMIApiLiveTest { assertNotNull(payloadOut); tmpFileOut = new File(Files.createTempDir(), "temp.jpg"); fos = new FileOutputStream(tmpFileOut); - ByteStreams.copy(payloadOut.getInput(), fos); + ByteStreams.copy(payloadOut, fos); fos.flush(); fos.close(); assertEquals(Files.equal(tmpFileOut, inFile), true); @@ -289,7 +289,7 @@ public class DataNonCDMIContentTypeApiLiveTest extends BaseCDMIApiLiveTest { assertNotNull(payloadOut); tmpFileOut = new File(Files.createTempDir(), "temp.jpg"); fos = new FileOutputStream(tmpFileOut); - ByteStreams.copy(payloadOut.getInput(), fos); + ByteStreams.copy(payloadOut, fos); fos.flush(); fos.close(); assertEquals(Files.equal(tmpFileOut, inFile), true); @@ -308,14 +308,12 @@ public class DataNonCDMIContentTypeApiLiveTest extends BaseCDMIApiLiveTest { payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn, "bytes=0-10"); assertNotNull(payloadOut); - assertEquals(CharStreams.toString(new InputStreamReader(payloadOut.getInput(), "UTF-8")), - value.substring(0, 11)); + assertEquals(Strings2.toString(payloadOut), value.substring(0, 11)); assertEquals(payloadOut.getContentMetadata().getContentLength(), new Long(11)); payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn, "bytes=11-20"); assertNotNull(payloadOut); - assertEquals(CharStreams.toString(new InputStreamReader(payloadOut.getInput(), "UTF-8")), - value.substring(11, 21)); + assertEquals(Strings2.toString(payloadOut), value.substring(11, 21)); assertEquals(payloadOut.getContentMetadata().getContentLength(), new Long(10)); dataNonCDMIContentTypeApi.delete(dataObjectNameIn); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/ReturnPayloadBytes.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/ReturnPayloadBytes.java index 7e5dcd524b..2696393d3b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/ReturnPayloadBytes.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/ReturnPayloadBytes.java @@ -37,7 +37,7 @@ public class ReturnPayloadBytes implements Function { @Override public byte[] apply(HttpResponse from) { try { - return ByteStreams.toByteArray(from.getPayload().getInput()); + return ByteStreams.toByteArray(from.getPayload()); } catch (IOException e) { throw Throwables.propagate(e); } 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 568a7f8f71..2cae80a94e 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 @@ -111,7 +111,7 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest { String key = "constitution.txt"; String uploadId = getApi().initiateMultipartUpload(containerName, ObjectMetadataBuilder.create().key(key).contentMD5(oneHundredOneConstitutionsMD5).build()); - byte[] buffer = toByteArray(oneHundredOneConstitutions.getInput()); + byte[] buffer = toByteArray(oneHundredOneConstitutions); assertEquals(oneHundredOneConstitutionsLength, (long) buffer.length); Payload part1 = newByteArrayPayload(buffer); @@ -153,7 +153,7 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest { public void testMultipartChunkedFileStream() throws IOException, InterruptedException { FileOutputStream fous = new FileOutputStream(new File("target/const.txt")); - ByteStreams.copy(oneHundredOneConstitutions.getInput(), fous); + ByteStreams.copy(oneHundredOneConstitutions, fous); fous.flush(); fous.close(); String containerName = getContainerName();