diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-04-09 14:05:00 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-04-09 14:05:00 +0700 |
commit | 060bf4c3c66841237a5acafbbe211e360c9d920b (patch) | |
tree | 021db1c7f698a3547fdf5d03855f16cf46c764d0 /taskdefs | |
parent | b6779de5d76af4cf89de19943324b592bb067c2d (diff) | |
download | aspectj-060bf4c3c66841237a5acafbbe211e360c9d920b.tar.gz aspectj-060bf4c3c66841237a5acafbbe211e360c9d920b.zip |
Improve 2 tests do delete temporary files
There were some problems in file handling: One file in was not deleted
in case an exception was thrown during the test. Another case was a
JarFile which was not closed before deletion, which might work on Linux,
but not on Windows where the open file is still locked after usage.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'taskdefs')
-rw-r--r-- | taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java index 8e9008fba..e6ae8876b 100644 --- a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java +++ b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java @@ -394,18 +394,19 @@ public class AjcTaskTest extends TestCase { checkRun(task, null); - JarFile jarFile = new JarFile(destJar); - String[] expected = {"copyMe.htm", "pack/includeme", - "pack/Pack.class", "Default.class"}; - String[] unexpected = {"doNotCopy", "skipTxtFiles.txt", "pack/something.txt"}; - for (String value : expected) { - JarEntry entry = jarFile.getJarEntry(value); - assertTrue(value + " not found", null != entry); - } - for (String s : unexpected) { - JarEntry entry = jarFile.getJarEntry(s); - assertTrue(s + " found", null == entry); - } + try (JarFile jarFile = new JarFile(destJar)) { + String[] expected = { "copyMe.htm", "pack/includeme", + "pack/Pack.class", "Default.class" }; + String[] unexpected = { "doNotCopy", "skipTxtFiles.txt", "pack/something.txt" }; + for (String value : expected) { + JarEntry entry = jarFile.getJarEntry(value); + assertTrue(value + " not found", null != entry); + } + for (String s : unexpected) { + JarEntry entry = jarFile.getJarEntry(s); + assertTrue(s + " found", null == entry); + } + } } public void testInpathDirCopyFilterError() { |