mirror of https://github.com/apache/jclouds.git
JCLOUDS-622: Remove most vestiges of InputSupplier
Guava 16 deprecated InputSupplier and a future release will remove it.
This commit is contained in:
parent
1a3ad75efd
commit
fb60d76704
|
@ -67,7 +67,7 @@ public class ParseAtmosErrorFromXmlContent implements HttpErrorHandler {
|
|||
AtmosError error = null;
|
||||
if (response.getPayload() != null) {
|
||||
try {
|
||||
String content = Strings2.toString(response.getPayload());
|
||||
String content = Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
if (content != null && content.indexOf('<') >= 0) {
|
||||
error = utils.parseAtmosErrorFromContent(command, response, Strings2.toInputStream(content));
|
||||
} else {
|
||||
|
|
|
@ -261,14 +261,14 @@ public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
private static void verifyHeadObject(AtmosClient connection, String path, String metadataValue)
|
||||
throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||
AtmosObject getBlob = connection.headFile(path);
|
||||
assertEquals(Strings2.toString(getBlob.getPayload()), "");
|
||||
assertEquals(Strings2.toStringAndClose(getBlob.getPayload().openStream()), "");
|
||||
verifyMetadata(metadataValue, getBlob);
|
||||
}
|
||||
|
||||
private static void verifyObject(AtmosClient connection, String path, String compare, String metadataValue)
|
||||
throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||
AtmosObject getBlob = connection.readFile(path);
|
||||
assertEquals(Strings2.toString(getBlob.getPayload()), compare);
|
||||
assertEquals(Strings2.toStringAndClose(getBlob.getPayload().openStream()), compare);
|
||||
verifyMetadata(metadataValue, getBlob);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ParseCloudServersErrorFromHttpResponse implements HttpErrorHandler
|
|||
String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) {
|
||||
if (response.getPayload() != null) {
|
||||
try {
|
||||
return Strings2.toString(response.getPayload());
|
||||
return Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
} catch (IOException e) {
|
||||
logger.warn(e, "exception reading error from response", response);
|
||||
}
|
||||
|
|
|
@ -379,7 +379,7 @@ public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTes
|
|||
try {
|
||||
client.connect();
|
||||
Payload etcPasswd = client.get("/etc/jclouds.txt");
|
||||
String etcPasswdContents = Strings2.toString(etcPasswd);
|
||||
String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.openStream());
|
||||
assertEquals("rackspace", etcPasswdContents.trim());
|
||||
} finally {
|
||||
if (client != null)
|
||||
|
|
|
@ -88,7 +88,7 @@ public class CloudSigmaErrorHandler implements HttpErrorHandler {
|
|||
if (response.getPayload() == null)
|
||||
return null;
|
||||
try {
|
||||
return Strings2.toString(response.getPayload());
|
||||
return Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
|
|
@ -90,7 +90,7 @@ public class CloudStackErrorHandler implements HttpErrorHandler {
|
|||
if (response.getPayload() == null)
|
||||
return null;
|
||||
try {
|
||||
return Strings2.toString(response.getPayload());
|
||||
return Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class ElasticStackErrorHandler implements HttpErrorHandler {
|
|||
if (response.getPayload() == null)
|
||||
return null;
|
||||
try {
|
||||
return Strings2.toString(response.getPayload());
|
||||
return Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
|
|
@ -328,7 +328,7 @@ public class ElasticStackApiLiveTest extends BaseComputeServiceContextLiveTest {
|
|||
public void testWeCanReadAndWriteToDrive() throws IOException {
|
||||
drive2 = client.createDrive(new CreateDriveRequest.Builder().name(prefix + "2").size(1 * 1024 * 1024l).build());
|
||||
client.writeDrive(drive2.getUuid(), Payloads.newStringPayload("foo"));
|
||||
assertEquals(Strings2.toString(client.readDrive(drive2.getUuid(), 0, 3)), "foo");
|
||||
assertEquals(Strings2.toStringAndClose(client.readDrive(drive2.getUuid(), 0, 3).openStream()), "foo");
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testWeCanReadAndWriteToDrive")
|
||||
|
@ -343,7 +343,7 @@ public class ElasticStackApiLiveTest extends BaseComputeServiceContextLiveTest {
|
|||
assert driveNotClaimed.apply(drive2) : client.getDriveInfo(drive2.getUuid());
|
||||
System.err.println("after image; drive 2" + client.getDriveInfo(drive2.getUuid()));
|
||||
System.err.println("after image; drive 3" + client.getDriveInfo(drive3.getUuid()));
|
||||
assertEquals(Strings2.toString(client.readDrive(drive3.getUuid(), 0, 3)), "foo");
|
||||
assertEquals(Strings2.toStringAndClose(client.readDrive(drive3.getUuid(), 0, 3).openStream()), "foo");
|
||||
} finally {
|
||||
client.destroyDrive(drive2.getUuid());
|
||||
client.destroyDrive(drive3.getUuid());
|
||||
|
|
|
@ -703,7 +703,7 @@ public class FilesystemAsyncBlobStoreTest {
|
|||
Blob blobRangeStartAt = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeStartAt);
|
||||
payload = blobRangeStartAt.getPayload();
|
||||
try {
|
||||
assertEquals(input.substring(1), Strings2.toString(payload));
|
||||
assertEquals(input.substring(1), Strings2.toStringAndClose(payload.openStream()));
|
||||
} finally {
|
||||
Closeables2.closeQuietly(payload);
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ public class FilesystemAsyncBlobStoreTest {
|
|||
Blob blobRangeTail = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeTail);
|
||||
payload = blobRangeTail.getPayload();
|
||||
try {
|
||||
assertEquals(input.substring(5), Strings2.toString(payload));
|
||||
assertEquals(input.substring(5), Strings2.toStringAndClose(payload.openStream()));
|
||||
} finally {
|
||||
Closeables2.closeQuietly(payload);
|
||||
}
|
||||
|
@ -723,7 +723,7 @@ public class FilesystemAsyncBlobStoreTest {
|
|||
Blob blobFragment = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsFragment);
|
||||
payload = blobFragment.getPayload();
|
||||
try {
|
||||
assertEquals(input.substring(4, 7), Strings2.toString(payload));
|
||||
assertEquals(input.substring(4, 7), Strings2.toStringAndClose(payload.openStream()));
|
||||
} finally {
|
||||
Closeables2.closeQuietly(payload);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ParseCloudLoadBalancersErrorFromHttpResponse implements HttpErrorHa
|
|||
String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) {
|
||||
if (response.getPayload() != null) {
|
||||
try {
|
||||
return Strings2.toString(response.getPayload());
|
||||
return Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
} catch (IOException e) {
|
||||
logger.warn(e, "exception reading error from response", response);
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
assertConsistencyAwareContainerSize(sourceContainer, 1);
|
||||
S3Object newObject = getApi().getObject(sourceContainer, key);
|
||||
assert newObject != null;
|
||||
assertEquals(Strings2.toString(newObject.getPayload()), TEST_STRING);
|
||||
assertEquals(Strings2.toStringAndClose(newObject.getPayload().openStream()), TEST_STRING);
|
||||
return newObject;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler {
|
|||
}
|
||||
} else {
|
||||
try {
|
||||
message = Strings2.toString(response.getPayload());
|
||||
message = Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
exception = new HttpResponseException(command, response, message);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ public abstract class CommonSwiftClientLiveTest<C extends CommonSwiftClient> ext
|
|||
assert getApi().getObject(containerName, "non-existent-object") == null;
|
||||
// Test GET of object (including updated metadata)
|
||||
SwiftObject getBlob = getApi().getObject(containerName, object.getInfo().getName());
|
||||
assertEquals(Strings2.toString(getBlob.getPayload()), data);
|
||||
assertEquals(Strings2.toStringAndClose(getBlob.getPayload().openStream()), data);
|
||||
// TODO assertEquals(getBlob.getName(),
|
||||
// object.getMetadata().getName());
|
||||
assertEquals(getBlob.getInfo().getBytes(), Long.valueOf(data.length()));
|
||||
|
@ -289,7 +289,7 @@ public abstract class CommonSwiftClientLiveTest<C extends CommonSwiftClient> ext
|
|||
GetOptions.Builder.ifETagMatches(newEtag));
|
||||
assertEquals(getBlob.getInfo().getHash(), base16().lowerCase().decode(newEtag));
|
||||
getBlob = getApi().getObject(containerName, object.getInfo().getName(), GetOptions.Builder.startAt(8));
|
||||
assertEquals(Strings2.toString(getBlob.getPayload()), data.substring(8));
|
||||
assertEquals(Strings2.toStringAndClose(getBlob.getPayload().openStream()), data.substring(8));
|
||||
|
||||
} finally {
|
||||
returnContainer(containerName);
|
||||
|
@ -321,7 +321,7 @@ public abstract class CommonSwiftClientLiveTest<C extends CommonSwiftClient> ext
|
|||
assertTrue(getApi().objectExists(destinationContainer, destinationObject));
|
||||
|
||||
SwiftObject destinationSwiftObject = getApi().getObject(destinationContainer, destinationObject);
|
||||
assertEquals(Strings2.toString(destinationSwiftObject.getPayload()), data);
|
||||
assertEquals(Strings2.toStringAndClose(destinationSwiftObject.getPayload().openStream()), data);
|
||||
|
||||
// test exception thrown on bad destination container
|
||||
try {
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ParseVCloudErrorFromHttpResponse implements HttpErrorHandler {
|
|||
message = error.getMessage();
|
||||
exception = new VCloudResponseException(command, response, error);
|
||||
} else {
|
||||
message = Strings2.toString(response.getPayload());
|
||||
message = Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
exception = message != null ? new HttpResponseException(command, response, message) : exception;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -61,7 +61,7 @@ public class BindBlobToMultipartFormTest {
|
|||
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost:8001").build();
|
||||
binder.bindToRequest(request, TEST_BLOB);
|
||||
|
||||
assertEquals(Strings2.toString(request.getPayload()), EXPECTS);
|
||||
assertEquals(Strings2.toStringAndClose(request.getPayload().openStream()), EXPECTS);
|
||||
assertEquals(request.getPayload().getContentMetadata().getContentLength(), Long.valueOf(113));
|
||||
|
||||
assertEquals(request.getPayload().getContentMetadata().getContentType(), "multipart/form-data; boundary="
|
||||
|
|
|
@ -51,7 +51,7 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
assertConsistencyAwareContainerSize(container, 1);
|
||||
HttpRequest request = view.getSigner().signGetBlob(container, name);
|
||||
assertEquals(request.getFilters().size(), 0);
|
||||
assertEquals(Strings2.toString(view.utils().http().invoke(request).getPayload()), text);
|
||||
assertEquals(Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream()), text);
|
||||
} finally {
|
||||
returnContainer(container);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
assertConsistencyAwareContainerSize(container, 1);
|
||||
HttpRequest request = view.getSigner().signGetBlob(container, name, range(0, 1));
|
||||
assertEquals(request.getFilters().size(), 0);
|
||||
assertEquals(Strings2.toString(view.utils().http().invoke(request).getPayload()), "fo");
|
||||
assertEquals(Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream()), "fo");
|
||||
} finally {
|
||||
returnContainer(container);
|
||||
}
|
||||
|
@ -89,11 +89,11 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
HttpRequest request = view.getSigner().signGetBlob(container, name, timeout);
|
||||
|
||||
assertEquals(request.getFilters().size(), 0);
|
||||
assertEquals(Strings2.toString(view.utils().http().invoke(request).getPayload()), text);
|
||||
assertEquals(Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream()), text);
|
||||
|
||||
TimeUnit.SECONDS.sleep(2 * timeout);
|
||||
try {
|
||||
Strings2.toString(view.utils().http().invoke(request).getPayload());
|
||||
Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream());
|
||||
fail("Temporary URL did not expire as expected");
|
||||
} catch (AuthorizationException expected) {
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
try {
|
||||
HttpRequest request = view.getSigner().signPutBlob(container, blob);
|
||||
assertEquals(request.getFilters().size(), 0);
|
||||
Strings2.toString(view.utils().http().invoke(request).getPayload());
|
||||
Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream());
|
||||
assertConsistencyAwareContainerSize(container, 1);
|
||||
} finally {
|
||||
returnContainer(container);
|
||||
|
@ -137,7 +137,7 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
// Java 7+ will throw a ProtocolException instead of setting the response code:
|
||||
// http://www.docjar.com/html/api/sun/net/www/protocol/http/HttpURLConnection.java.html#1021
|
||||
request = request.toBuilder().removeHeader(EXPECT).build();
|
||||
Strings2.toString(view.utils().http().invoke(request).getPayload());
|
||||
Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream());
|
||||
assertConsistencyAwareContainerSize(container, 1);
|
||||
|
||||
view.getBlobStore().removeBlob(container, name);
|
||||
|
@ -145,7 +145,7 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
|
||||
TimeUnit.SECONDS.sleep(2 * timeout);
|
||||
try {
|
||||
Strings2.toString(view.utils().http().invoke(request).getPayload());
|
||||
Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream());
|
||||
fail("Temporary URL did not expire as expected");
|
||||
} catch (AuthorizationException expected) {
|
||||
}
|
||||
|
|
|
@ -72,14 +72,14 @@ public class ParseAzureStorageErrorFromXmlContent implements HttpErrorHandler {
|
|||
}
|
||||
} catch (RuntimeException e) {
|
||||
try {
|
||||
message = Strings2.toString(response.getPayload());
|
||||
message = Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
exception = new HttpResponseException(command, response, message);
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
message = Strings2.toString(response.getPayload());
|
||||
message = Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
exception = new HttpResponseException(command, response, message);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
|
|
@ -391,7 +391,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
|
|||
return actual == null;
|
||||
}
|
||||
try {
|
||||
String real = Strings2.toString((Payload) actual);
|
||||
String real = Strings2.toStringAndClose(((Payload) actual).openStream());
|
||||
assertEquals(real, expected);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -84,7 +84,7 @@ public class HttpResponseException extends RuntimeException {
|
|||
&& request.getPayload().getContentMetadata().getContentLength() < 1024) {
|
||||
try {
|
||||
return String.format(" [%s] ", request.getPayload() instanceof StringPayload ? request.getPayload()
|
||||
.getRawContent() : Strings2.toString(request.getPayload()));
|
||||
.getRawContent() : Strings2.toStringAndClose(request.getPayload().openStream()));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ParseURIFromListOrLocationHeaderIf20x implements Function<HttpRespo
|
|||
try {
|
||||
if (from.getPayload().getInput() == null)
|
||||
throw new HttpResponseException("no content", null, from);
|
||||
String toParse = Strings2.toString(from.getPayload());
|
||||
String toParse = Strings2.toStringAndClose(from.getPayload().getInput());
|
||||
return URI.create(toParse.trim());
|
||||
} catch (IOException e) {
|
||||
throw new HttpResponseException("couldn't parse uri from content", null, from, e);
|
||||
|
|
|
@ -34,7 +34,7 @@ public class CloseContentAndSetExceptionErrorHandler implements HttpErrorHandler
|
|||
public void handleError(HttpCommand command, HttpResponse from) {
|
||||
String content;
|
||||
try {
|
||||
content = from.getPayload() != null ? Strings2.toString(from.getPayload()) : null;
|
||||
content = from.getPayload() != null ? Strings2.toStringAndClose(from.getPayload().openStream()) : null;
|
||||
command.setException(new HttpResponseException(command, from, content));
|
||||
} catch (IOException e) {
|
||||
command.setException(new HttpResponseException(command, from));
|
||||
|
|
|
@ -28,7 +28,6 @@ import com.google.common.hash.HashingInputStream;
|
|||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.io.InputSupplier;
|
||||
|
||||
@Beta
|
||||
public class ByteStreams2 {
|
||||
|
@ -54,12 +53,12 @@ public class ByteStreams2 {
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public static ByteSource asByteSource(final InputSupplier<? extends InputStream> supplier) {
|
||||
checkNotNull(supplier, "supplier");
|
||||
public static ByteSource asByteSource(final Payload payload) {
|
||||
checkNotNull(payload, "payload");
|
||||
return new ByteSource() {
|
||||
@Override
|
||||
public InputStream openStream() throws IOException {
|
||||
return supplier.getInput();
|
||||
return payload.openStream();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ import com.google.common.hash.HashCode;
|
|||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.InputSupplier;
|
||||
|
||||
@Singleton
|
||||
public class BasePayloadSlicer implements PayloadSlicer {
|
||||
|
@ -181,12 +180,6 @@ public class BasePayloadSlicer implements PayloadSlicer {
|
|||
return new ByteSourcePayload(content.slice(offset, length));
|
||||
}
|
||||
|
||||
/** @deprecated use doSlice(ByteSource) instead */
|
||||
@Deprecated
|
||||
protected Payload doSlice(InputSupplier<? extends InputStream> content, long offset, long length) {
|
||||
return doSlice(ByteStreams2.asByteSource(content), offset, length);
|
||||
}
|
||||
|
||||
protected Payload doSlice(byte[] content, long offset, long length) {
|
||||
Payload returnVal;
|
||||
checkArgument(offset <= Integer.MAX_VALUE, "offset is too big for an array");
|
||||
|
|
|
@ -41,7 +41,6 @@ import com.google.common.cache.CacheLoader;
|
|||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.google.common.primitives.Chars;
|
||||
|
||||
public class Strings2 {
|
||||
|
@ -122,13 +121,6 @@ public class Strings2 {
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated use CharSource.read() instead */
|
||||
@Deprecated
|
||||
public static String toString(InputSupplier<? extends InputStream> supplier)
|
||||
throws IOException {
|
||||
return toStringAndClose(supplier.getInput());
|
||||
}
|
||||
|
||||
public static String toStringAndClose(InputStream input) throws IOException {
|
||||
checkNotNull(input, "input");
|
||||
try {
|
||||
|
|
|
@ -145,7 +145,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
try {
|
||||
HttpResponse getStringResponse = client.invoke(HttpRequest.builder().method("GET")
|
||||
.endpoint(server.getUrl("/objects").toString()).build());
|
||||
assertEquals(Strings2.toString(getStringResponse.getPayload()).trim(), XML);
|
||||
assertEquals(Strings2.toStringAndClose(getStringResponse.getPayload().openStream()).trim(), XML);
|
||||
} finally {
|
||||
close(client, true);
|
||||
server.shutdown();
|
||||
|
|
|
@ -48,7 +48,7 @@ public class MultipartFormTest {
|
|||
|
||||
MultipartForm multipartForm = new MultipartForm(boundary, newPart("hello"));
|
||||
|
||||
assertEquals(Strings2.toString(multipartForm), expects);
|
||||
assertEquals(Strings2.toStringAndClose(multipartForm.openStream()), expects);
|
||||
assertEquals(multipartForm.getContentMetadata().getContentLength(), Long.valueOf(199));
|
||||
}
|
||||
|
||||
|
@ -108,11 +108,11 @@ public class MultipartFormTest {
|
|||
|
||||
MultipartForm multipartForm = new MultipartForm(boundary, newPart("hello"), newPart("goodbye"));
|
||||
|
||||
assertEquals(Strings2.toString(multipartForm), expects);
|
||||
assertEquals(Strings2.toStringAndClose(multipartForm.openStream()), expects);
|
||||
|
||||
// test repeatable
|
||||
assert multipartForm.isRepeatable();
|
||||
assertEquals(Strings2.toString(multipartForm), expects);
|
||||
assertEquals(Strings2.toStringAndClose(multipartForm.openStream()), expects);
|
||||
assertEquals(multipartForm.getContentMetadata().getContentLength(), Long.valueOf(352));
|
||||
}
|
||||
|
||||
|
|
|
@ -385,8 +385,8 @@ public abstract class BaseRestApiExpectTest<S> {
|
|||
|
||||
switch (compareHttpRequestAsType(a)) {
|
||||
case XML: {
|
||||
Diff diff = XMLUnit.compareXML(Strings2.toString(a.getPayload()), Strings2
|
||||
.toString(b.getPayload()));
|
||||
Diff diff = XMLUnit.compareXML(Strings2.toStringAndClose(a.getPayload().openStream()),
|
||||
Strings2.toStringAndClose(b.getPayload().openStream()));
|
||||
|
||||
// Ignoring whitespace in elements that have other children, xsi:schemaLocation and
|
||||
// differences in namespace prefixes
|
||||
|
@ -418,8 +418,8 @@ public abstract class BaseRestApiExpectTest<S> {
|
|||
}
|
||||
case JSON: {
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonElement payloadA = parser.parse(Strings2.toString(a.getPayload()));
|
||||
JsonElement payloadB = parser.parse(Strings2.toString(b.getPayload()));
|
||||
JsonElement payloadA = parser.parse(Strings2.toStringAndClose(a.getPayload().openStream()));
|
||||
JsonElement payloadB = parser.parse(Strings2.toStringAndClose(b.getPayload().openStream()));
|
||||
return Objects.equal(payloadA, payloadB);
|
||||
}
|
||||
default: {
|
||||
|
@ -487,7 +487,7 @@ public abstract class BaseRestApiExpectTest<S> {
|
|||
builder.append(header.getKey()).append(": ").append(header.getValue()).append('\n');
|
||||
}
|
||||
try {
|
||||
builder.append('\n').append(Strings2.toString(request.getPayload()));
|
||||
builder.append('\n').append(Strings2.toStringAndClose(request.getPayload().openStream()));
|
||||
} catch (IOException e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public abstract class BaseRestApiTest {
|
|||
} else {
|
||||
String payload = null;
|
||||
try {
|
||||
payload = Strings2.toString(request.getPayload());
|
||||
payload = Strings2.toStringAndClose(request.getPayload().openStream());
|
||||
} catch (IOException e) {
|
||||
propagate(e);
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class ConvertToJcloudsResponseTest {
|
|||
replay(gaeResponse);
|
||||
HttpResponse response = req.apply(gaeResponse);
|
||||
assertEquals(response.getStatusCode(), 200);
|
||||
assertEquals(Strings2.toString(response.getPayload()), "hello");
|
||||
assertEquals(Strings2.toStringAndClose(response.getPayload().openStream()), "hello");
|
||||
assertEquals(response.getHeaders().size(), 0);
|
||||
assertEquals(response.getPayload().getContentMetadata().getContentType(), "text/xml");
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ public class JschSshClientLiveTest {
|
|||
SshClient client = setupClient();
|
||||
client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit"));
|
||||
Payload input = setupClient().get(temp.getAbsolutePath());
|
||||
String contents = Strings2.toString(input);
|
||||
String contents = Strings2.toStringAndClose(input.openStream());
|
||||
assertEquals(contents, "rabbit");
|
||||
} finally {
|
||||
temp.delete();
|
||||
|
@ -172,7 +172,7 @@ public class JschSshClientLiveTest {
|
|||
@Test
|
||||
public void testGetEtcPassword() throws IOException {
|
||||
Payload input = setupClient().get("/etc/passwd");
|
||||
String contents = Strings2.toString(input);
|
||||
String contents = Strings2.toStringAndClose(input.openStream());
|
||||
assert contents.indexOf("root") >= 0 : "no root in " + contents;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ public class SshjSshClientLiveTest {
|
|||
SshClient client = setupClient();
|
||||
client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit"));
|
||||
Payload input = client.get(temp.getAbsolutePath());
|
||||
String contents = Strings2.toString(input);
|
||||
String contents = Strings2.toStringAndClose(input.openStream());
|
||||
assertEquals(contents, "rabbit");
|
||||
} finally {
|
||||
temp.delete();
|
||||
|
@ -158,7 +158,7 @@ public class SshjSshClientLiveTest {
|
|||
|
||||
public void testGetEtcPassword() throws IOException {
|
||||
Payload input = setupClient().get("/etc/passwd");
|
||||
String contents = Strings2.toString(input);
|
||||
String contents = Strings2.toStringAndClose(input.openStream());
|
||||
assert contents.indexOf("root") >= 0 : "no root in " + contents;
|
||||
}
|
||||
|
||||
|
|
|
@ -265,7 +265,7 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest {
|
|||
|
||||
// Test GET of object (including updated metadata)
|
||||
AzureBlob getBlob = getApi().getBlob(privateContainer, object.getProperties().getName());
|
||||
assertEquals(Strings2.toString(getBlob.getPayload()), data);
|
||||
assertEquals(Strings2.toStringAndClose(getBlob.getPayload().openStream()), data);
|
||||
// TODO assertEquals(getBlob.getName(), object.getProperties().getName());
|
||||
assertEquals(getBlob.getPayload().getContentMetadata().getContentLength(), Long.valueOf(data.length()));
|
||||
assertEquals(getBlob.getProperties().getContentMetadata().getContentType(), "text/plain");
|
||||
|
|
|
@ -78,7 +78,7 @@ public class GleSYSErrorHandler implements HttpErrorHandler {
|
|||
if (response.getPayload() == null)
|
||||
return null;
|
||||
try {
|
||||
return Strings2.toString(response.getPayload());
|
||||
return Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
|
|
@ -74,7 +74,7 @@ public class SoftLayerErrorHandler implements HttpErrorHandler {
|
|||
if (response.getPayload() == null)
|
||||
return null;
|
||||
try {
|
||||
return Strings2.toString(response.getPayload());
|
||||
return Strings2.toStringAndClose(response.getPayload().openStream());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
|
Loading…
Reference in New Issue