You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2018/06/27 14:44:34 UTC
[12/17] james-project git commit: JAMES-2436 Stop leaking resources
JAMES-2436 Stop leaking resources
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0ebd232c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0ebd232c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0ebd232c
Branch: refs/heads/master
Commit: 0ebd232c4907815646cdc78951a12808dba373f8
Parents: 3feef1d
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Tue Jun 19 16:52:57 2018 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Wed Jun 27 16:36:12 2018 +0200
----------------------------------------------------------------------
.../james/mailbox/backup/ZipAssertTest.java | 154 +++++++++++--------
1 file changed, 91 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/0ebd232c/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipAssertTest.java
----------------------------------------------------------------------
diff --git a/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipAssertTest.java b/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipAssertTest.java
index b903eb2..7075754 100644
--- a/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipAssertTest.java
+++ b/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipAssertTest.java
@@ -64,9 +64,11 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatCode(() -> assertThatZip(new ZipFile(destination))
- .hasNoEntry())
- .doesNotThrowAnyException();
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatCode(() -> assertThatZip(zipFile)
+ .hasNoEntry())
+ .doesNotThrowAnyException();
+ }
}
@Test
@@ -81,9 +83,11 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatThrownBy(() -> assertThatZip(new ZipFile(destination))
- .hasNoEntry())
- .isInstanceOf(AssertionError.class);
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatThrownBy(() -> assertThatZip(zipFile)
+ .hasNoEntry())
+ .isInstanceOf(AssertionError.class);
+ }
}
@Test
@@ -92,9 +96,11 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatCode(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching())
- .doesNotThrowAnyException();
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatCode(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching())
+ .doesNotThrowAnyException();
+ }
}
@Test
@@ -114,11 +120,13 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatCode(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME),
- hasName(ENTRY_NAME_2)))
- .doesNotThrowAnyException();
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatCode(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME),
+ hasName(ENTRY_NAME_2)))
+ .doesNotThrowAnyException();
+ }
}
@Test
@@ -132,10 +140,12 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatThrownBy(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME_2)))
- .isInstanceOf(AssertionError.class);
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatThrownBy(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME_2)))
+ .isInstanceOf(AssertionError.class);
+ }
}
@Test
@@ -155,11 +165,13 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatCode(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME),
- hasName(ENTRY_NAME_2)))
- .doesNotThrowAnyException();
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatCode(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME),
+ hasName(ENTRY_NAME_2)))
+ .doesNotThrowAnyException();
+ }
}
@Test
@@ -179,12 +191,14 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatThrownBy(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME),
- hasName(ENTRY_NAME_2),
- hasName("extraEntry")))
- .isInstanceOf(AssertionError.class);
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatThrownBy(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME),
+ hasName(ENTRY_NAME_2),
+ hasName("extraEntry")))
+ .isInstanceOf(AssertionError.class);
+ }
}
@Test
@@ -204,10 +218,12 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatThrownBy(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME)))
- .isInstanceOf(AssertionError.class);
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatThrownBy(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME)))
+ .isInstanceOf(AssertionError.class);
+ }
}
@Test
@@ -222,11 +238,13 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatCode(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME)
- .hasStringContent(STRING_ENTRY_CONTENT)))
- .doesNotThrowAnyException();
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatCode(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME)
+ .hasStringContent(STRING_ENTRY_CONTENT)))
+ .doesNotThrowAnyException();
+ }
}
@Test
@@ -241,11 +259,13 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatThrownBy(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME)
- .hasStringContent(STRING_ENTRY_CONTENT_2)))
- .isInstanceOf(AssertionError.class);
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatThrownBy(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME)
+ .hasStringContent(STRING_ENTRY_CONTENT_2)))
+ .isInstanceOf(AssertionError.class);
+ }
}
@Test
@@ -260,11 +280,13 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatCode(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME)
- .containsExtraFields()))
- .doesNotThrowAnyException();
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatCode(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME)
+ .containsExtraFields()))
+ .doesNotThrowAnyException();
+ }
}
@Test
@@ -279,11 +301,13 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatThrownBy(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME)
- .containsExtraFields(EXTRA_FIELD)))
- .isInstanceOf(AssertionError.class);
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatThrownBy(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME)
+ .containsExtraFields(EXTRA_FIELD)))
+ .isInstanceOf(AssertionError.class);
+ }
}
@Test
@@ -299,11 +323,13 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatCode(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME)
- .containsExtraFields()))
- .doesNotThrowAnyException();
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatCode(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME)
+ .containsExtraFields()))
+ .doesNotThrowAnyException();
+ }
}
@Test
@@ -319,10 +345,12 @@ public class ZipAssertTest {
archiveOutputStream.finish();
}
- assertThatCode(() -> assertThatZip(new ZipFile(destination))
- .containsOnlyEntriesMatching(
- hasName(ENTRY_NAME)
- .containsExtraFields(EXTRA_FIELD)))
- .doesNotThrowAnyException();
+ try (ZipFile zipFile = new ZipFile(destination)) {
+ assertThatCode(() -> assertThatZip(zipFile)
+ .containsOnlyEntriesMatching(
+ hasName(ENTRY_NAME)
+ .containsExtraFields(EXTRA_FIELD)))
+ .doesNotThrowAnyException();
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org