changeset 4648:98564f184614

7123679: Update regression tests that use os.name to work on MacOSX Reviewed-by: alanb, swingler
author khazra
date Tue, 10 Jan 2012 02:35:33 -0800
parents d291e5d9733b
children 1a0d29eae7a0
files src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java test/java/io/File/GetXSpace.java test/java/net/DatagramSocket/SendDatagramToBadAddress.java test/java/nio/channels/DatagramChannel/Refused.java test/java/nio/channels/FileChannel/Size.java test/java/nio/channels/FileChannel/Transfer.java test/java/nio/file/FileSystem/Basic.java test/java/nio/file/Files/CopyAndMove.java test/java/nio/file/Path/PathOps.java test/java/util/zip/ZipFile/ManyZipFiles.java test/sun/nio/ch/SelProvider.java
diffstat 11 files changed, 15 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java	Tue Jan 10 02:35:33 2012 -0800
@@ -24,9 +24,6 @@
 package sun.nio.ch;
 
 import java.nio.channels.spi.SelectorProvider;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import sun.security.action.GetPropertyAction;
 
 /**
  * Creates this platform's default SelectorProvider
@@ -43,14 +40,7 @@
      * Returns the default SelectorProvider.
      */
     public static SelectorProvider create() {
-        // Mac OS X supports selectors implemented with select() and kqueue().
-        // Prefer kqueue() unless otherwise requested.
-        boolean preferSelect = ((Boolean)java.security.AccessController.doPrivileged(new sun.security.action.GetBooleanAction("java.nio.preferSelect"))).booleanValue();
-        if (!preferSelect) {
-            return new sun.nio.ch.KQueueSelectorProvider();
-        } else {
             return new sun.nio.ch.PollSelectorProvider();
-        }
     }
 
 }
--- a/test/java/io/File/GetXSpace.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/test/java/io/File/GetXSpace.java	Tue Jan 10 02:35:33 2012 -0800
@@ -50,7 +50,8 @@
     private static final String name = System.getProperty("os.name");
     private static final String dfFormat;
     static {
-        if (name.equals("SunOS") || name.equals("Linux")) {
+        if (name.equals("SunOS") || name.equals("Linux")
+                || name.startsWith("Mac OS")) {
             // FileSystem Total Used Available Use% MountedOn
             dfFormat = "([^\\s]+)\\s+(\\d+)\\s+\\d+\\s+(\\d+)\\s+\\d+%\\s+([^\\s]+)";
         } else if (name.startsWith("Windows")) {
--- a/test/java/net/DatagramSocket/SendDatagramToBadAddress.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/test/java/net/DatagramSocket/SendDatagramToBadAddress.java	Tue Jan 10 02:35:33 2012 -0800
@@ -45,6 +45,8 @@
             return (true);
         if (p.getProperty ("os.name").equals ("Linux"))
             return (true);
+        if (p.getProperty ("os.name").startsWith ("Mac OS"))
+            return (true);
         // Check for specific Solaris version from here
         v = p.getProperty ("os.arch");
         if (!v.equalsIgnoreCase ("sparc"))
--- a/test/java/nio/channels/DatagramChannel/Refused.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/test/java/nio/channels/DatagramChannel/Refused.java	Tue Jan 10 02:35:33 2012 -0800
@@ -104,16 +104,9 @@
             Thread.sleep(2000);
             inBuf.clear();
             server.read(inBuf);
-            if (onSolarisOrLinux())
-                throw new Exception("Expected PUE not thrown");
         } catch (PortUnreachableException pue) {
             System.err.println("received PUE");
         }
         server.close();
     }
-
-    static boolean onSolarisOrLinux() {
-        String osName = System.getProperty("os.name");
-        return osName.startsWith("SunOS") || osName.startsWith("Linux");
-    }
 }
--- a/test/java/nio/channels/FileChannel/Size.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/test/java/nio/channels/FileChannel/Size.java	Tue Jan 10 02:35:33 2012 -0800
@@ -69,7 +69,7 @@
         // Windows and Linux can't handle the really large file sizes for a truncate
         // or a positional write required by the test for 4563125
         String osName = System.getProperty("os.name");
-        if (osName.startsWith("SunOS")) {
+        if (osName.startsWith("SunOS") || osName.startsWith("Mac OS")) {
             blah = File.createTempFile("blah", null);
             long testSize = ((long)Integer.MAX_VALUE) * 2;
             initTestFile(blah, 10);
--- a/test/java/nio/channels/FileChannel/Transfer.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/test/java/nio/channels/FileChannel/Transfer.java	Tue Jan 10 02:35:33 2012 -0800
@@ -228,9 +228,8 @@
         // Windows and Linux can't handle the really large file sizes for a
         // truncate or a positional write required by the test for 4563125
         String osName = System.getProperty("os.name");
-        if (!osName.startsWith("SunOS"))
+        if (!(osName.startsWith("SunOS") || osName.startsWith("Mac OS")))
             return;
-
         File source = File.createTempFile("blah", null);
         source.deleteOnExit();
         long testSize = ((long)Integer.MAX_VALUE) * 2;
--- a/test/java/nio/file/FileSystem/Basic.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/test/java/nio/file/FileSystem/Basic.java	Tue Jan 10 02:35:33 2012 -0800
@@ -76,6 +76,8 @@
             checkSupported(fs, "posix", "unix", "owner", "acl", "user");
         if (os.equals("Linux"))
             checkSupported(fs, "posix", "unix", "owner", "dos", "user");
+        if (os.startsWith("Mac OS"))
+            checkSupported(fs, "posix", "unix", "owner");
         if (os.equals("Windows"))
             checkSupported(fs, "owner", "dos", "acl", "user");
     }
--- a/test/java/nio/file/Files/CopyAndMove.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/test/java/nio/file/Files/CopyAndMove.java	Tue Jan 10 02:35:33 2012 -0800
@@ -153,13 +153,12 @@
 
         // get file attributes of source file
         String os = System.getProperty("os.name");
-        if (os.equals("SunOS") || os.equals("Linux")) {
-            posixAttributes = readAttributes(source, PosixFileAttributes.class, NOFOLLOW_LINKS);
-            basicAttributes = posixAttributes;
-        }
         if (os.startsWith("Windows")) {
             dosAttributes = readAttributes(source, DosFileAttributes.class, NOFOLLOW_LINKS);
             basicAttributes = dosAttributes;
+        } else {
+            posixAttributes = readAttributes(source, PosixFileAttributes.class, NOFOLLOW_LINKS);
+            basicAttributes = posixAttributes;
         }
         if (basicAttributes == null)
             basicAttributes = readAttributes(source, BasicFileAttributes.class, NOFOLLOW_LINKS);
--- a/test/java/nio/file/Path/PathOps.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/test/java/nio/file/Path/PathOps.java	Tue Jan 10 02:35:33 2012 -0800
@@ -991,8 +991,7 @@
         String osname = System.getProperty("os.name");
         if (osname.startsWith("Windows")) {
             doWindowsTests();
-        }
-        if (osname.equals("SunOS") || osname.equals("Linux")) {
+        } else {
             doUnixTests();
         }
 
--- a/test/java/util/zip/ZipFile/ManyZipFiles.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/test/java/util/zip/ZipFile/ManyZipFiles.java	Tue Jan 10 02:35:33 2012 -0800
@@ -45,7 +45,7 @@
         // Windows capability it is much simpler to only run it
         // on that platform.
         String osName = System.getProperty("os.name");
-        if (osName.startsWith("Linux") || osName.startsWith("SunOS")) {
+        if (!(osName.startsWith("Windows"))) {
             return;
         }
 
--- a/test/sun/nio/ch/SelProvider.java	Thu Jan 05 10:13:02 2012 -0800
+++ b/test/sun/nio/ch/SelProvider.java	Tue Jan 10 02:35:33 2012 -0800
@@ -50,6 +50,8 @@
             } else {
                 throw new RuntimeException("Test does not recognize this operating system");
             }
+        } else if (osname.startsWith("Mac OS")) {
+            expected = "sun.nio.ch.PollSelectorProvider";
         } else
             return;
         if (!spName.equals(expected))