mirror of https://github.com/apache/jclouds.git
Simplify testPutFileParallel
Create only one temporary file and use explicit delete instead finalization to remove it.
This commit is contained in:
parent
4ca531aa98
commit
607b178c6b
|
@ -134,8 +134,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
public void testPutFileParallel() throws InterruptedException, IOException, TimeoutException {
|
public void testPutFileParallel() throws InterruptedException, IOException, TimeoutException {
|
||||||
|
|
||||||
File payloadFile = File.createTempFile("testPutFileParallel", "png");
|
File payloadFile = File.createTempFile("testPutFileParallel", "png");
|
||||||
Files.copy(createTestInput(), payloadFile);
|
Files.write(createTestInput(), payloadFile);
|
||||||
payloadFile.deleteOnExit();
|
|
||||||
|
|
||||||
final Payload testPayload = Payloads.newFilePayload(payloadFile);
|
final Payload testPayload = Payloads.newFilePayload(payloadFile);
|
||||||
final byte[] md5 = md5Supplier(testPayload);
|
final byte[] md5 = md5Supplier(testPayload);
|
||||||
|
@ -172,6 +171,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
assert exceptions.size() == 0 : exceptions;
|
assert exceptions.size() == 0 : exceptions;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
payloadFile.delete();
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -611,13 +611,10 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
assertEquals(metadata.getContentMetadata().getContentMD5(), md5().hashString(TEST_STRING, UTF_8).asBytes());
|
assertEquals(metadata.getContentMetadata().getContentMD5(), md5().hashString(TEST_STRING, UTF_8).asBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
private File createTestInput() throws IOException {
|
private byte[] createTestInput() throws IOException {
|
||||||
File file = File.createTempFile("testimg", "png");
|
|
||||||
file.deleteOnExit();
|
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
byte[] buffer = new byte[random.nextInt(2 * 1024 * 1024)];
|
byte[] buffer = new byte[random.nextInt(2 * 1024 * 1024)];
|
||||||
random.nextBytes(buffer);
|
random.nextBytes(buffer);
|
||||||
Files.copy(ByteStreams.newInputStreamSupplier(buffer), file);
|
return buffer;
|
||||||
return file;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue