You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2014/05/24 01:26:11 UTC
git commit: Prefer File.delete over File.deleteOnExit
Repository: jclouds
Updated Branches:
refs/heads/master 26b53e52b -> bae4377dc
Prefer File.delete over File.deleteOnExit
The former has deterministic behavior and avoids resource leaks.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/bae4377d
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/bae4377d
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/bae4377d
Branch: refs/heads/master
Commit: bae4377dca11c6c9f3db52e51a55455adf3d43f7
Parents: 26b53e5
Author: Andrew Gaul <ga...@apache.org>
Authored: Thu May 22 00:51:27 2014 -0700
Committer: Andrew Gaul <ga...@apache.org>
Committed: Fri May 23 16:17:10 2014 -0700
----------------------------------------------------------------------
...tpCommandExecutorServiceIntegrationTest.java | 1 -
.../internal/RestAnnotationProcessorTest.java | 76 +++++++++++---------
.../jclouds/ssh/jsch/JschSshClientLiveTest.java | 15 ++--
.../org/jclouds/sshj/SshjSshClientLiveTest.java | 15 ++--
4 files changed, 59 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/bae4377d/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java b/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
index c10a354..cc2931d 100644
--- a/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
+++ b/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java
@@ -275,7 +275,6 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
try {
f = File.createTempFile("jclouds", "tmp");
- f.deleteOnExit();
long length = (new Random().nextInt(32) + 1) * 1024 * 1024;
byte[] buf = new byte[1024];
Arrays.fill(buf, (byte) 'a');
http://git-wip-us.apache.org/repos/asf/jclouds/blob/bae4377d/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java
index c727802..07c480d 100644
--- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java
+++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java
@@ -1163,23 +1163,26 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest {
Invokable<?, ?> method = method(TestMultipartForm.class, "withParamFilePart", String.class,
File.class);
File file = File.createTempFile("foo", "bar");
- Files.append("foobledata", file, UTF_8);
- file.deleteOnExit();
-
- GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of("name", file)));
- assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest,
- "----JCLOUDS--\r\n" + //
- "Content-Disposition: form-data; name=\"name\"\r\n" + //
- "\r\n" + //
- "name\r\n" + // /
- "----JCLOUDS--\r\n" + //
- "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n" + //
- "\r\n" + //
- "foobledata\r\n" + //
- "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false);
+ try {
+ Files.append("foobledata", file, UTF_8);
+
+ GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
+ ImmutableList.<Object> of("name", file)));
+ assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest,
+ "----JCLOUDS--\r\n" + //
+ "Content-Disposition: form-data; name=\"name\"\r\n" + //
+ "\r\n" + //
+ "name\r\n" + // /
+ "----JCLOUDS--\r\n" + //
+ "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n" + //
+ "\r\n" + //
+ "foobledata\r\n" + //
+ "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false);
+ } finally {
+ file.delete();
+ }
}
public void testMultipartWithParamByteArrayPart() throws SecurityException, NoSuchMethodException, IOException {
@@ -1206,24 +1209,27 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest {
Invokable<?, ?> method = method(TestMultipartForm.class, "withParamFileBinaryPart",
String.class, File.class);
File file = File.createTempFile("foo", "bar");
- Files.write(new byte[] { 17, 26, 39, 40, 50 }, file);
- file.deleteOnExit();
-
- GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of("name", file)));
- assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest,
- "----JCLOUDS--\r\n" + //
- "Content-Disposition: form-data; name=\"name\"\r\n" + //
- "\r\n" + //
- "name\r\n" + // /
- "----JCLOUDS--\r\n" + //
- "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n" + //
- "Content-Type: application/octet-stream\r\n" + //
- "\r\n" + //
- "'(2\r\n" + //
- "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false);
+ try {
+ Files.write(new byte[] { 17, 26, 39, 40, 50 }, file);
+
+ GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
+ ImmutableList.<Object> of("name", file)));
+ assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest,
+ "----JCLOUDS--\r\n" + //
+ "Content-Disposition: form-data; name=\"name\"\r\n" + //
+ "\r\n" + //
+ "name\r\n" + // /
+ "----JCLOUDS--\r\n" + //
+ "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n" + //
+ "Content-Type: application/octet-stream\r\n" + //
+ "\r\n" + //
+ "'(2\r\n" + //
+ "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false);
+ } finally {
+ file.delete();
+ }
}
public interface TestPut {
http://git-wip-us.apache.org/repos/asf/jclouds/blob/bae4377d/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/JschSshClientLiveTest.java
----------------------------------------------------------------------
diff --git a/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/JschSshClientLiveTest.java b/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/JschSshClientLiveTest.java
index 37d3de0..fa00961 100644
--- a/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/JschSshClientLiveTest.java
+++ b/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/JschSshClientLiveTest.java
@@ -160,12 +160,15 @@ public class JschSshClientLiveTest {
@Test
public void testPutAndGet() throws IOException {
temp = File.createTempFile("foo", "bar");
- temp.deleteOnExit();
- SshClient client = setupClient();
- client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit"));
- Payload input = setupClient().get(temp.getAbsolutePath());
- String contents = Strings2.toString(input);
- assertEquals(contents, "rabbit");
+ try {
+ SshClient client = setupClient();
+ client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit"));
+ Payload input = setupClient().get(temp.getAbsolutePath());
+ String contents = Strings2.toString(input);
+ assertEquals(contents, "rabbit");
+ } finally {
+ temp.delete();
+ }
}
@Test
http://git-wip-us.apache.org/repos/asf/jclouds/blob/bae4377d/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java
----------------------------------------------------------------------
diff --git a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java
index 1aba367..d6e2b0f 100644
--- a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java
+++ b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java
@@ -147,12 +147,15 @@ public class SshjSshClientLiveTest {
public void testPutAndGet() throws IOException {
temp = File.createTempFile("foo", "bar");
- temp.deleteOnExit();
- SshClient client = setupClient();
- client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit"));
- Payload input = client.get(temp.getAbsolutePath());
- String contents = Strings2.toString(input);
- assertEquals(contents, "rabbit");
+ try {
+ SshClient client = setupClient();
+ client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit"));
+ Payload input = client.get(temp.getAbsolutePath());
+ String contents = Strings2.toString(input);
+ assertEquals(contents, "rabbit");
+ } finally {
+ temp.delete();
+ }
}
public void testGetEtcPassword() throws IOException {