Author: fanningpj
Date: Mon Jun 16 11:14:55 2025
New Revision: 1926467

URL: http://svn.apache.org/viewvc?rev=1926467&view=rev
Log:
[bug-69714] refactor test

Modified:
    poi/trunk/poi/src/main/java/org/apache/poi/util/TempFile.java
    
poi/trunk/poi/src/test/java/org/apache/poi/util/DefaultTempFileCreationStrategyTest.java

Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/TempFile.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/TempFile.java?rev=1926467&r1=1926466&r2=1926467&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/TempFile.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/TempFile.java Mon Jun 16 
11:14:55 2025
@@ -58,7 +58,8 @@ public final class TempFile {
     /**
      * Configures the strategy used by {@link #createTempFile(String, String)} 
to create the temporary files.
      *
-     * @param strategy The new strategy to be used to create the temporary 
files.
+     * @param strategy The new strategy to be used to create the temporary 
files for this thread.
+     *                 <code>null</code> can be used to reset the strategy for 
this thread to the default one.
      * @since POI 5.4.2
      */
     public static void 
setThreadLocalTempFileCreationStrategy(TempFileCreationStrategy strategy) {

Modified: 
poi/trunk/poi/src/test/java/org/apache/poi/util/DefaultTempFileCreationStrategyTest.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/util/DefaultTempFileCreationStrategyTest.java?rev=1926467&r1=1926466&r2=1926467&view=diff
==============================================================================
--- 
poi/trunk/poi/src/test/java/org/apache/poi/util/DefaultTempFileCreationStrategyTest.java
 (original)
+++ 
poi/trunk/poi/src/test/java/org/apache/poi/util/DefaultTempFileCreationStrategyTest.java
 Mon Jun 16 11:14:55 2025
@@ -121,48 +121,6 @@ class DefaultTempFileCreationStrategyTes
         }
     }
 
-    private static void checkGetFile(DefaultTempFileCreationStrategy strategy) 
throws IOException {
-        checkGetFileAndPath(strategy, null);
-    }
-
-    private static void checkGetFileAndPath(DefaultTempFileCreationStrategy 
strategy,
-                                           Path path) throws IOException {
-        File file = strategy.createTempFile("POITest", ".tmp");
-        try {
-            if (path != null) {
-                assertTrue(file.toPath().startsWith(path),
-                        "File path does not start with expected path: " + 
path);
-            }
-
-            assertTrue(file.getParentFile().exists(),
-                    "Failed for " + file.getParentFile());
-
-            assertTrue(file.exists(),
-                    "Failed for " + file);
-        } finally {
-            assertTrue(file.delete());
-        }
-    }
-
-    private static void checkGetFileAndPath(Path path) throws IOException {
-        File file = TempFile.createTempFile("POITest", ".tmp");
-        try {
-            if (path != null) {
-                assertTrue(file.toPath().startsWith(path),
-                        "File path does not start with expected path: " + 
path);
-            }
-
-            assertTrue(file.getParentFile().exists(),
-                    "Failed for " + file.getParentFile());
-
-            assertTrue(file.exists(),
-                    "Failed for " + file);
-        } finally {
-            assertTrue(file.delete());
-        }
-    }
-
-
     @Test
     void testDefaultDir() throws IOException {
         DefaultTempFileCreationStrategy strategy = new 
DefaultTempFileCreationStrategy();
@@ -224,4 +182,36 @@ class DefaultTempFileCreationStrategyTes
             FileUtils.deleteDirectory(dirTest);
         }
     }
+
+    private static void checkGetFile(DefaultTempFileCreationStrategy strategy) 
throws IOException {
+        checkGetFileAndPath(strategy, null);
+    }
+
+    private static void checkGetFileAndPath(DefaultTempFileCreationStrategy 
strategy,
+                                            Path path) throws IOException {
+        File file = strategy.createTempFile("POITest", ".tmp");
+        testFileAndPath(file, path);
+    }
+
+    private static void checkGetFileAndPath(Path path) throws IOException {
+        File file = TempFile.createTempFile("POITest", ".tmp");
+        testFileAndPath(file, path);
+    }
+
+    private static void testFileAndPath(File file, Path path) throws 
IOException {
+        try {
+            if (path != null) {
+                assertTrue(file.toPath().startsWith(path),
+                        "File path does not start with expected path: " + 
path);
+            }
+
+            assertTrue(file.getParentFile().exists(),
+                    "Failed for " + file.getParentFile());
+
+            assertTrue(file.exists(),
+                    "Failed for " + file);
+        } finally {
+            assertTrue(file.delete());
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to