提交 0e209131 编写于 作者: J jgish

8004651: TEST: java/util/logging/CheckLockLocationTest.java failed to delete file (win)

Summary: Failure to delete test log file should be a warning instead of test failure
Reviewed-by: mduigou, smarks
上级 e6b14fba
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
* @run main/othervm CheckLockLocationTest * @run main/othervm CheckLockLocationTest
*/ */
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.nio.file.AccessDeniedException; import java.nio.file.AccessDeniedException;
import java.nio.file.FileSystemException; import java.nio.file.FileSystemException;
...@@ -90,13 +89,12 @@ public class CheckLockLocationTest { ...@@ -90,13 +89,12 @@ public class CheckLockLocationTest {
throw new RuntimeException("Test failed: should not have been able" throw new RuntimeException("Test failed: should not have been able"
+ " to create FileHandler for " + "%t/" + NON_WRITABLE_DIR + " to create FileHandler for " + "%t/" + NON_WRITABLE_DIR
+ "/log.log in non-writable directory."); + "/log.log in non-writable directory.");
} catch (AccessDeniedException ex) {
// the right exception was thrown, so continue.
} catch (IOException ex) { } catch (IOException ex) {
// check for the right exception throw new RuntimeException(
if (!(ex instanceof AccessDeniedException)) {
throw new RuntimeException(
"Test failed: Expected exception was not an " "Test failed: Expected exception was not an "
+ "AccessDeniedException", ex); + "AccessDeniedException", ex);
}
} }
} }
...@@ -106,14 +104,11 @@ public class CheckLockLocationTest { ...@@ -106,14 +104,11 @@ public class CheckLockLocationTest {
throw new RuntimeException("Test failed: should not have been able" throw new RuntimeException("Test failed: should not have been able"
+ " to create FileHandler for " + "%t/" + NOT_A_DIR + " to create FileHandler for " + "%t/" + NOT_A_DIR
+ "/log.log in non-directory."); + "/log.log in non-directory.");
} catch (FileSystemException ex) {
// the right exception was thrown, so continue.
} catch (IOException ex) { } catch (IOException ex) {
// check for the right exception throw new RuntimeException("Test failed: exception thrown was not a "
if (!(ex instanceof FileSystemException + "FileSystemException", ex);
&& ex.getMessage().contains("Not a directory"))) {
throw new RuntimeException(
"Test failed: Expected exception was not a "
+ "FileSystemException", ex);
}
} }
// Test 4: make sure we can't create a FileHandler in a non-existent dir // Test 4: make sure we can't create a FileHandler in a non-existent dir
...@@ -122,12 +117,11 @@ public class CheckLockLocationTest { ...@@ -122,12 +117,11 @@ public class CheckLockLocationTest {
throw new RuntimeException("Test failed: should not have been able" throw new RuntimeException("Test failed: should not have been able"
+ " to create FileHandler for " + "%t/" + NON_EXISTENT_DIR + " to create FileHandler for " + "%t/" + NON_EXISTENT_DIR
+ "/log.log in a non-existent directory."); + "/log.log in a non-existent directory.");
} catch (NoSuchFileException ex) {
// the right exception was thrown, so continue.
} catch (IOException ex) { } catch (IOException ex) {
// check for the right exception throw new RuntimeException("Test failed: Expected exception "
if (!(ex instanceof NoSuchFileException)) { + "was not a NoSuchFileException", ex);
throw new RuntimeException("Test failed: Expected exception "
+ "was not a NoSuchFileException", ex);
}
} }
} }
...@@ -216,12 +210,14 @@ public class CheckLockLocationTest { ...@@ -216,12 +210,14 @@ public class CheckLockLocationTest {
/* /*
* Recursively delete all files starting at specified file * Recursively delete all files starting at specified file
*/ */
private static void delete(File f) throws IOException { private static void delete(File f) {
if (f != null && f.isDirectory()) { if (f != null && f.isDirectory()) {
for (File c : f.listFiles()) for (File c : f.listFiles())
delete(c); delete(c);
} }
if (!f.delete()) if (!f.delete())
throw new FileNotFoundException("Failed to delete file: " + f); System.err.println(
} "WARNING: unable to delete/cleanup writable test directory: "
+ f );
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册