提交 74060bdc 编写于 作者: J jgish

8003596: TEST_BUG: java/util/logging/CheckLockLocationTest.java failing [win]

Reviewed-by: alanb
上级 4f1534c2
...@@ -363,9 +363,6 @@ java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java generic-all ...@@ -363,9 +363,6 @@ java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java generic-all
# Filed 6772009 # Filed 6772009
java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
# 8003596
java/util/logging/CheckLockLocationTest.java windows-all
# 7041639, Solaris DSA keypair generation bug # 7041639, Solaris DSA keypair generation bug
java/util/TimeZone/TimeZoneDatePermissionCheck.sh solaris-all java/util/TimeZone/TimeZoneDatePermissionCheck.sh solaris-all
......
...@@ -42,17 +42,22 @@ public class CheckLockLocationTest { ...@@ -42,17 +42,22 @@ public class CheckLockLocationTest {
private static final String NOT_A_DIR = "not-a-dir"; private static final String NOT_A_DIR = "not-a-dir";
private static final String WRITABLE_DIR = "writable-dir"; private static final String WRITABLE_DIR = "writable-dir";
private static final String NON_EXISTENT_DIR = "non-existent-dir"; private static final String NON_EXISTENT_DIR = "non-existent-dir";
private static boolean runNonWritableDirTest;
public static void main(String... args) throws IOException { public static void main(String... args) throws IOException {
// we'll base all file creation attempts on the system temp directory, // we'll base all file creation attempts on the system temp directory,
// %t and also try specifying non-existent directories and plain files // %t and also try specifying non-existent directories and plain files
// that should be directories, and non-writable directories, // that should be directories, and non-writable directories,
// to exercise all code paths of checking the lock location // to exercise all code paths of checking the lock location
// Note that on platforms like Windows that don't support
// setWritable() on a directory, we'll skip the non-writable
// directory test if setWritable(false) returns false.
//
File writableDir = setup(); File writableDir = setup();
// we now have three files/directories to work with: // we now have three files/directories to work with:
// writableDir // writableDir
// notAdir // notAdir
// nonWritableDir // nonWritableDir (may not be possible on some platforms)
// nonExistentDir (which doesn't exist) // nonExistentDir (which doesn't exist)
runTests(writableDir); runTests(writableDir);
} }
...@@ -79,15 +84,19 @@ public class CheckLockLocationTest { ...@@ -79,15 +84,19 @@ public class CheckLockLocationTest {
} }
// Test 2: creating FileHandler in non-writable directory should fail // Test 2: creating FileHandler in non-writable directory should fail
try { if (runNonWritableDirTest) {
new FileHandler("%t/" + NON_WRITABLE_DIR + "/log.log"); try {
throw new RuntimeException("Test failed: should not have been able" new FileHandler("%t/" + NON_WRITABLE_DIR + "/log.log");
+ " to create FileHandler for " + "%t/" + NON_WRITABLE_DIR throw new RuntimeException("Test failed: should not have been able"
+ "/log.log in non-writable directory."); + " to create FileHandler for " + "%t/" + NON_WRITABLE_DIR
} catch (IOException ex) { + "/log.log in non-writable directory.");
// check for the right exception } catch (IOException ex) {
if (!(ex instanceof AccessDeniedException)) { // check for the right exception
throw new RuntimeException("Test failed: Expected exception was not an AccessDeniedException", ex); if (!(ex instanceof AccessDeniedException)) {
throw new RuntimeException(
"Test failed: Expected exception was not an "
+ "AccessDeniedException", ex);
}
} }
} }
...@@ -99,8 +108,11 @@ public class CheckLockLocationTest { ...@@ -99,8 +108,11 @@ public class CheckLockLocationTest {
+ "/log.log in non-directory."); + "/log.log in non-directory.");
} catch (IOException ex) { } catch (IOException ex) {
// check for the right exception // check for the right exception
if (!(ex instanceof FileSystemException && ex.getMessage().contains("Not a directory"))) { if (!(ex instanceof FileSystemException
throw new RuntimeException("Test failed: Expected exception was not a FileSystemException", ex); && ex.getMessage().contains("Not a directory"))) {
throw new RuntimeException(
"Test failed: Expected exception was not a "
+ "FileSystemException", ex);
} }
} }
...@@ -113,7 +125,8 @@ public class CheckLockLocationTest { ...@@ -113,7 +125,8 @@ public class CheckLockLocationTest {
} catch (IOException ex) { } catch (IOException ex) {
// check for the right exception // check for the right exception
if (!(ex instanceof NoSuchFileException)) { if (!(ex instanceof NoSuchFileException)) {
throw new RuntimeException("Test failed: Expected exception was not a NoSuchFileException", ex); throw new RuntimeException("Test failed: Expected exception "
+ "was not a NoSuchFileException", ex);
} }
} }
} }
...@@ -162,10 +175,14 @@ public class CheckLockLocationTest { ...@@ -162,10 +175,14 @@ public class CheckLockLocationTest {
nonWritableDir.deleteOnExit(); nonWritableDir.deleteOnExit();
// make it non-writable // make it non-writable
if (!nonWritableDir.setWritable(false)) { if (nonWritableDir.setWritable(false)) {
throw new RuntimeException("Test setup failed: unable to make" runNonWritableDirTest = true;
} else {
runNonWritableDirTest = false;
System.out.println( "Test Setup WARNING: unable to make"
+ " working directory " + nonWritableDir.getAbsolutePath() + " working directory " + nonWritableDir.getAbsolutePath()
+ " non-writable."); + " non-writable on platform " + System.getProperty("os.name"));
} }
// make sure non-existent directory really doesn't exist // make sure non-existent directory really doesn't exist
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册