scolebourne 2003/10/07 13:59:46
Modified: lang/src/java/org/apache/commons/lang SystemUtils.java
lang/src/test/org/apache/commons/lang SystemUtilsTest.java
lang project.xml
Log:
Add IS_OS_UNIX to SystemUtils
from Rafal Krupinski
Revision Changes Path
1.24 +15 -1
jakarta-commons/lang/src/java/org/apache/commons/lang/SystemUtils.java
Index: SystemUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/SystemUtils.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- SystemUtils.java 22 Aug 2003 16:34:06 -0000 1.23
+++ SystemUtils.java 7 Oct 2003 20:59:46 -0000 1.24
@@ -67,6 +67,7 @@
* @author Gary Gregory
* @author Michael Becke
* @author Tetsuya Kaneuchi
+ * @author Rafal Krupinski
* @since 1.0
* @version $Id$
*/
@@ -625,6 +626,19 @@
* @since 2.0
*/
public static final boolean IS_OS_SUN_OS = getOSMatches("SunOS");
+
+ /**
+ * <p>Is <code>true</code> if this is POSIX compilant system,
+ * ie. any of AIX, HP-UX, Irix, Linux, MacOSX, Solaris or SUN OS.</p>
+ *
+ * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
+ * <code>null</code>.</p>
+ *
+ * @since 2.1
+ */
+ public static final boolean IS_OS_UNIX =
+ IS_OS_AIX || IS_OS_HP_UX || IS_OS_IRIX || IS_OS_LINUX ||
+ IS_OS_MAC_OSX || IS_OS_SOLARIS || IS_OS_SUN_OS;
/**
* <p>Is <code>true</code> if this is Windows.</p>
1.7 +19 -7
jakarta-commons/lang/src/test/org/apache/commons/lang/SystemUtilsTest.java
Index: SystemUtilsTest.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/SystemUtilsTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SystemUtilsTest.java 18 Aug 2003 02:22:25 -0000 1.6
+++ SystemUtilsTest.java 7 Oct 2003 20:59:46 -0000 1.7
@@ -363,21 +363,33 @@
String osName = System.getProperty("os.name");
if (osName == null) {
assertEquals(false, SystemUtils.IS_OS_WINDOWS);
+ assertEquals(false, SystemUtils.IS_OS_UNIX);
assertEquals(false, SystemUtils.IS_OS_SOLARIS);
assertEquals(false, SystemUtils.IS_OS_LINUX);
assertEquals(false, SystemUtils.IS_OS_MAC_OSX);
} else if (osName.startsWith("Windows")) {
- assertTrue(SystemUtils.IS_OS_WINDOWS);
+ assertEquals(false, SystemUtils.IS_OS_UNIX);
+ assertEquals(true, SystemUtils.IS_OS_WINDOWS);
} else if (osName.startsWith("Solaris")) {
- assertTrue(SystemUtils.IS_OS_SOLARIS);
+ assertEquals(true, SystemUtils.IS_OS_SOLARIS);
+ assertEquals(true, SystemUtils.IS_OS_UNIX);
+ assertEquals(false, SystemUtils.IS_OS_WINDOWS);
} else if (osName.toLowerCase().startsWith("linux")) {
- assertTrue(SystemUtils.IS_OS_LINUX);
+ assertEquals(true, SystemUtils.IS_OS_LINUX);
+ assertEquals(true, SystemUtils.IS_OS_UNIX);
+ assertEquals(false, SystemUtils.IS_OS_WINDOWS);
} else if (osName.startsWith("Mac OS X")) {
- assertTrue(SystemUtils.IS_OS_MAC_OSX);
+ assertEquals(true, SystemUtils.IS_OS_MAC_OSX);
+ assertEquals(true, SystemUtils.IS_OS_UNIX);
+ assertEquals(false, SystemUtils.IS_OS_WINDOWS);
} else if (osName.startsWith("OS/2")) {
- assertTrue(SystemUtils.IS_OS_OS2);
+ assertEquals(true, SystemUtils.IS_OS_OS2);
+ assertEquals(false, SystemUtils.IS_OS_UNIX);
+ assertEquals(false, SystemUtils.IS_OS_WINDOWS);
} else if (osName.startsWith("SunOS")) {
- assertTrue(SystemUtils.IS_OS_SUN_OS);
+ assertEquals(true, SystemUtils.IS_OS_SUN_OS);
+ assertEquals(true, SystemUtils.IS_OS_UNIX);
+ assertEquals(false, SystemUtils.IS_OS_WINDOWS);
} else {
System.out.println("Can't test IS_OS value");
}
1.16 +8 -0 jakarta-commons/lang/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/lang/project.xml,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- project.xml 2 Oct 2003 20:34:16 -0000 1.15
+++ project.xml 7 Oct 2003 20:59:46 -0000 1.16
@@ -267,6 +267,14 @@
</roles>
</contributor>
<contributor>
+ <name>Rafal Krupinski</name>
+ <email></email>
+ <organization></organization>
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ </contributor>
+ <contributor>
<name>Rafal Krzewski</name>
<email></email>
<organization></organization>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]