Repository: jclouds Updated Branches: refs/heads/master ba9c4b972 -> 550018a68
Use randomByteSource to generate test data This avoids buffering the entire bolus of data in-memory. Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/550018a6 Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/550018a6 Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/550018a6 Branch: refs/heads/master Commit: 550018a68d65963a28a6ee0dc59cf31458e731e6 Parents: ba9c4b9 Author: Andrew Gaul <[email protected]> Authored: Wed Aug 27 15:59:36 2014 -0700 Committer: Andrew Gaul <[email protected]> Committed: Wed Aug 27 15:59:36 2014 -0700 ---------------------------------------------------------------------- .../src/test/java/org/jclouds/filesystem/utils/TestUtils.java | 7 ++++--- .../integration/internal/BaseBlobIntegrationTest.java | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds/blob/550018a6/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 78ef6b2..cd0276c 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 @@ -16,6 +16,7 @@ */ package org.jclouds.filesystem.utils; +import static org.jclouds.utils.TestUtils.randomByteSource; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; @@ -214,9 +215,9 @@ public class TestUtils { } Random random = new Random(); for (File file : IMAGE_RESOURCES) { - byte[] buffer = new byte[random.nextInt(2 * 1024 * 1024)]; - random.nextBytes(buffer); - ByteSource.wrap(buffer).copyTo(Files.asByteSink(file)); + int length = random.nextInt(2 * 1024 * 1024); + ByteSource byteSource = randomByteSource().slice(0, length); + byteSource.copyTo(Files.asByteSink(file)); } } http://git-wip-us.apache.org/repos/asf/jclouds/blob/550018a6/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 e1e7fc7..eb55098 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 @@ -630,11 +630,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { } /** @return ByteSource containing a random length 0..length of random bytes. */ - @SuppressWarnings("unchecked") private static ByteSource createTestInput(int length) { - Random random = new Random(); - byte[] buffer = new byte[random.nextInt(length)]; - random.nextBytes(buffer); - return ByteSource.wrap(buffer); + return TestUtils.randomByteSource().slice(0, new Random().nextInt(length)); } }
