use of com.amazonaws.testutils.util.RandomTempFile in project aws-sdk-android by aws-amplify.
the class GetObjectIntegrationTest method setUp.
/**
* Creates and initializes all the test resources needed for these tests.
*/
@BeforeClass
public static void setUp() throws Exception {
S3IntegrationTestBase.setUp();
if (!ANDROID_TESTING) {
setUpCredentials();
}
final long fileSize = 100000L;
tempData = tempDataBuffer((int) fileSize);
s3.createBucket(BUCKET_NAME);
s3.createBucket(REQUESTER_PAYS_BUCKET_NAME);
ObjectMetadata metadata = null;
if (!ANDROID_TESTING) {
file = new RandomTempFile("get-object-integ-test", fileSize);
s3.putObject(BUCKET_NAME, KEY, file);
s3.putObject(REQUESTER_PAYS_BUCKET_NAME, KEY, file);
} else {
file = getRandomTempFile("foo", fileSize);
final ByteArrayInputStream bais = new ByteArrayInputStream(tempData);
metadata = new ObjectMetadata();
metadata.setContentLength(fileSize);
s3.putObject(new PutObjectRequest(BUCKET_NAME, KEY, bais, metadata));
bais.close();
}
metadata = s3.getObjectMetadata(BUCKET_NAME, KEY);
etag = metadata.getETag();
final Date lastModified = metadata.getLastModified();
earlierDate = new Date(lastModified.getTime() - 1000);
laterDate = new Date(lastModified.getTime() + 1000);
// Sleep for a few seconds to make sure the test doesn't run before
// the future date
Thread.sleep(1000 * 2);
}
use of com.amazonaws.testutils.util.RandomTempFile in project aws-sdk-android by aws-amplify.
the class BucketLifecycleConfigurationIntegrationTest method setUp.
/**
* Creates and initializes all the test resources needed for these tests.
*/
@BeforeClass
public static void setUp() throws Exception {
S3IntegrationTestBase.setUp();
if (!ANDROID_TESTING) {
setUpCredentials();
}
tempData = tempDataBuffer(1000);
s3.createBucket(BUCKET_NAME);
S3IntegrationTestBase.waitForBucketCreation(BUCKET_NAME);
ObjectMetadata metadata = null;
if (!ANDROID_TESTING) {
file = new RandomTempFile("get-object-integ-test", 1000L);
s3.putObject(BUCKET_NAME, KEY, file);
} else {
file = S3IntegrationTestBase.getRandomTempFile("foo", 1000L);
ByteArrayInputStream bais = new ByteArrayInputStream(tempData);
metadata = new ObjectMetadata();
metadata.setContentLength(1000);
s3.putObject(new PutObjectRequest(BUCKET_NAME, KEY, bais, metadata));
bais.close();
}
}
use of com.amazonaws.testutils.util.RandomTempFile in project aws-sdk-android by aws-amplify.
the class ServerSideEncryptionWithCustomerKeyIntegrationTest method setUp.
/**
* Creates and initializes all the test resources needed for these tests.
*/
@BeforeClass
public static void setUp() throws Exception {
S3IntegrationTestBase.setUp();
s3.createBucket(BUCKET_NAME);
file_singleUpload = new RandomTempFile("get-object-integ-test-single-upload", SINGLE_UPLOAD_OBJECT_SIZE);
file_multipartUpload = new RandomTempFile("get-object-integ-test-multipart-upload", PART_NUMBER * PART_SIZE);
secretKey = generateSecretKey();
secretKey_b64 = Base64.encodeAsString(secretKey.getEncoded());
}
use of com.amazonaws.testutils.util.RandomTempFile in project aws-sdk-android by aws-amplify.
the class MultiThreadedDownloadIntegrationTest method testMultipleDownloads.
/**
* Tests that we can successfully download objects from multiple threads
* using the same Amazon S3 client, and that the objects are downloaded
* correctly, matching the content that we uploaded, and with the metadata
* that we expect.
*/
@Test
public void testMultipleDownloads() throws Exception {
file = new RandomTempFile("download-stress-integ-test-file.txt", CONTENT_LENGTH);
s3.createBucket(bucketName);
s3.putObject(bucketName, key, file);
List<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
for (int i = 0; i < TOTAL_REQUESTS; i++) {
tasks.add(new TimedGetObjectCallable());
}
List<Future<Integer>> futures = threadPool.invokeAll(tasks);
for (java.util.Iterator iterator = futures.iterator(); iterator.hasNext(); ) {
Future<Integer> future = (Future<Integer>) iterator.next();
int executionTime = future.get().intValue();
assertTrue(executionTime > 0);
assertTrue(executionTime < 1000 * 10);
}
}
use of com.amazonaws.testutils.util.RandomTempFile in project aws-sdk-android by aws-amplify.
the class GetObjectIntegrationTest method testGetDirectoryObjectAsFile.
/**
* Tests that we can download a directory-keyed object to a file.
*/
@Test
public void testGetDirectoryObjectAsFile() throws Exception {
final File data = new RandomTempFile("get-object-integ-test-directory", 1000L);
final String directoryKey = "a/b/c/d.dat";
s3.putObject(BUCKET_NAME, directoryKey, data);
final File tempFile = File.createTempFile("aws-java-sdk-integ-test", ".dat");
final ObjectMetadata objectMetadata = s3.getObject(new GetObjectRequest(BUCKET_NAME, directoryKey), tempFile);
assertNull(objectMetadata.getSSEAlgorithm());
assertNotNull(objectMetadata.getLastModified());
assertNotNull(objectMetadata.getContentType());
assertTrue(tempFile.exists());
assertFileEqualsStream(tempFile, new FileInputStream(data));
}
Aggregations