ctubbsii commented on code in PR #2100:
URL: https://github.com/apache/zookeeper/pull/2100#discussion_r1435843649


##########
zookeeper-server/src/test/java/org/apache/zookeeper/common/FileChangeWatcherTest.java:
##########
@@ -31,36 +31,25 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.commons.io.FileUtils;
 import org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.test.ClientBase;
-import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class FileChangeWatcherTest extends ZKTestCase {
 
-    private static File tempDir;
-    private static File tempFile;
+    @TempDir
+    static File tempDir;
+    static File tempFile;

Review Comment:
   There's actually a lot of places where you can make these private. Here's 
some more, but I won't comment on every one in the PR.
   
   ```suggestion
       private static File tempDir;
       private static File tempFile;
   ```



##########
zookeeper-server/src/test/java/org/apache/zookeeper/server/CRCTest.java:
##########
@@ -102,8 +103,7 @@ private boolean getCheckSum(File snapFile) throws 
IOException {
      * @throws Exception
      */
     @Test
-    public void testChecksums() throws Exception {
-        File tmpDir = ClientBase.createTmpDir();
+    public void testChecksums(@TempDir File tmpDir) throws Exception {

Review Comment:
   I did not know you could do this! That's neat.



##########
zookeeper-server/src/test/java/org/apache/zookeeper/client/ZKClientConfigTest.java:
##########
@@ -38,20 +38,14 @@
 import java.util.Properties;
 import org.apache.zookeeper.common.ZKConfig;
 import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.io.TempDir;
 
 public class ZKClientConfigTest {
 
-    private static final File testData = new 
File(System.getProperty("test.data.dir", "src/test/resources/data"));
-
-    @BeforeAll
-    public static void init() {
-        if (!testData.exists()) {
-            testData.mkdirs();
-        }
-    }
+    @TempDir
+    static File testDataDir;

Review Comment:
   ```suggestion
       private static File testDataDir;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to