Commit 3fe2005e authored by Phillip Webb's avatar Phillip Webb

Use @AfterEach to close the source jar file

Update `JarFileWrapperTests` so that the jar files are closed after each
test.

See gh-22991
parent 47e5db9e
......@@ -30,6 +30,7 @@ import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
......@@ -51,11 +52,16 @@ class JarFileWrapperTests {
private JarFileWrapper wrapper;
@BeforeEach
void setup(@TempDir File temp) throws IOException {
void setup(@TempDir File temp) throws Exception {
this.parent = new SpyJarFile(createTempJar(temp));
this.wrapper = new JarFileWrapper(this.parent);
}
@AfterEach
void cleanup() throws Exception {
this.parent.close();
}
private File createTempJar(File temp) throws IOException {
File file = new File(temp, "temp.jar");
new JarOutputStream(new FileOutputStream(file)).close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment