diff options
author | gjoranv <gjoranv@gmail.com> | 2018-05-14 10:27:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-14 10:27:13 +0200 |
commit | 5224e612edc9f5af2f93051a41000a36ca6c5c93 (patch) | |
tree | 046794b68da38a478aaa45bdf59ade5444e84be1 | |
parent | 786ebde378567d5de38465b43f1bae98a7302d41 (diff) | |
parent | 74876532e309d5250c1568afeeccb258ea9f9420 (diff) |
Merge pull request #5835 from vespa-engine/hmusum/cleanup-tests
Use @After instead of finalizer
-rw-r--r-- | configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java index 73cda93ccab..157c36d7aef 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java @@ -5,6 +5,7 @@ import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.io.IOUtils; import com.yahoo.net.HostName; import com.yahoo.vespa.filedistribution.FileReferenceData; +import org.junit.After; import org.junit.Test; import java.io.File; @@ -21,8 +22,8 @@ import static org.junit.Assert.assertFalse; public class FileServerTest { - FileServer fs = new FileServer(new File(".")); - List<File> created = new LinkedList<>(); + private FileServer fs = new FileServer(new File(".")); + private List<File> created = new LinkedList<>(); private void createCleanDir(String name) throws IOException{ File dir = new File(name); @@ -70,7 +71,7 @@ public class FileServerTest { } @Test - public void requireThatDifferentNumberOfConfigServersWork() throws IOException { + public void requireThatDifferentNumberOfConfigServersWork() { // Empty connection pool in tests etc. ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder(); FileServer fileServer = new FileServer(new ConfigserverConfig(builder)); @@ -107,17 +108,10 @@ public class FileServerTest { } } - private void cleanup() { - created.forEach((file) -> IOUtils.recursiveDeleteDir(file)); + @After + public void cleanup() { + created.forEach(IOUtils::recursiveDeleteDir); created.clear(); } - // TODO: Why not use @After instead of finalizer? - @Override - @SuppressWarnings("deprecation") // finalize() is deprecated from Java 9 - protected void finalize() throws Throwable { - super.finalize(); - cleanup(); - } - } |