JCLOUDS-671: test putBlob with large multi-part InputStream

This commit is contained in:
Andrew Gaul 2014-12-06 13:39:05 -08:00
parent 66c4963b49
commit 1663e0911e
1 changed files with 23 additions and 0 deletions

View File

@ -27,9 +27,12 @@ import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest; import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest;
import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.options.PutOptions;
import org.jclouds.io.ByteStreams2;
import org.jclouds.utils.TestUtils; import org.jclouds.utils.TestUtils;
import org.testng.SkipException; import org.testng.SkipException;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static com.google.common.hash.Hashing.md5; import static com.google.common.hash.Hashing.md5;
@ -92,6 +95,26 @@ public class AzureBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
} }
} }
public void testMultipartUploadInputStream() throws Exception {
long length = MultipartUploadStrategy.MAX_BLOCK_SIZE + 1;
ByteSource byteSource = TestUtils.randomByteSource().slice(0, length);
String containerName = getContainerName();
try {
BlobStore blobStore = view.getBlobStore();
blobStore.createContainerInLocation(null, containerName);
String blobName = "const.txt";
Blob blob = blobStore.blobBuilder(blobName)
.payload(byteSource.openStream())
.contentLength(length)
.build();
blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart());
blob = blobStore.getBlob(containerName, blobName);
assertThat(ByteStreams2.toByteArrayAndClose(blob.getPayload().openStream())).isEqualTo(byteSource.read());
} finally {
returnContainer(containerName);
}
}
public void testMultipartChunkedFileStreamPowerOfTwoSize() throws IOException, InterruptedException { public void testMultipartChunkedFileStreamPowerOfTwoSize() throws IOException, InterruptedException {
final long limit = MultipartUploadStrategy.MAX_BLOCK_SIZE; final long limit = MultipartUploadStrategy.MAX_BLOCK_SIZE;
ByteSource input = TestUtils.randomByteSource().slice(0, limit); ByteSource input = TestUtils.randomByteSource().slice(0, limit);