commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang SystemUtilsTest.java
Date Mon, 21 Jul 2003 22:57:51 GMT
scolebourne    2003/07/21 15:57:51

  Modified:    lang/src/java/org/apache/commons/lang SystemUtils.java
               lang/src/test/org/apache/commons/lang SystemUtilsTest.java
  Log:
  Fix class so IS_JAVA_* and IS_OS_* constants work correctly.
  bug 21767, from Tetsuya Kaneuchi
  
  Revision  Changes    Path
  1.19      +235 -219  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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- SystemUtils.java	18 Jul 2003 16:48:25 -0000	1.18
  +++ SystemUtils.java	21 Jul 2003 22:57:50 -0000	1.19
  @@ -66,12 +66,16 @@
    * @author <a href="mailto:sdowney@panix.com">Steve Downey</a>
    * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
    * @author Michael Becke
  + * @author Tetsuya Kaneuchi
    * @since 1.0
    * @version $Id$
    */
   public class SystemUtils {
   
  +    // System property constants
       //-----------------------------------------------------------------------
  +    // These MUST be declared first. Other constants depend on this.
  +    
       /**
        * <p>The <code>file.encoding</code> System Property.</p>
        * <p>File encoding, such as <code>Cp1252</code>.</p>
  @@ -94,185 +98,6 @@
        */
       public static final String FILE_SEPARATOR = getSystemProperty("file.separator");
   
  -    //-----------------------------------------------------------------------
  -    /**
  -     * <p>Is <code>true</code> if this is Java version 1.1 (also 1.1.x
versions).</p>
  -     *
  -     * <p>The field will return <code>false</code> if {@link #JAVA_VERSION}
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_JAVA_1_1 = getJavaVersionMatches("1.1");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Java version 1.2 (also 1.2.x
versions).</p>
  -     *
  -     * <p>The field will return <code>false</code> if {@link #JAVA_VERSION}
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_JAVA_1_2 = getJavaVersionMatches("1.2");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Java version 1.3 (also 1.3.x
versions).</p>
  -     *
  -     * <p>The field will return <code>false</code> if {@link #JAVA_VERSION}
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_JAVA_1_3 = getJavaVersionMatches("1.3");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Java version 1.4 (also 1.4.x
versions).</p>
  -     *
  -     * <p>The field will <code>false</code> false if {@link #JAVA_VERSION}
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_JAVA_1_4 = getJavaVersionMatches("1.4");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Java version 1.5 (also 1.5.x
versions).</p>
  -     *
  -     * <p>The field will return <code>false</code> if {@link #JAVA_VERSION}
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_JAVA_1_5 = getJavaVersionMatches("1.5");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is AIX.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_AIX = getOSMatches("AIX");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is HP-UX.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_HP_UX = getOSMatches("HP-UX");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Irix.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_IRIX = getOSMatches("Irix");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Linux.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_LINUX = getOSMatches("Linux") || getOSMatches("LINUX");
  -    // Windows XP returns 'Windows 2000' just for fun...
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Mac.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_MAC = getOSMatches("Mac");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Mac.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_MAC_OSX = getOSMatches("Mac OS X");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is OS/2.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_OS2 = getOSMatches("OS/2");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Solaris.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_SOLARIS = getOSMatches("Solaris");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is SunOS.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_SUN_OS = getOSMatches("SunOS");
  -
  -    //-----------------------------------------------------------------------
  -    // OS names from http://www.vamphq.com/os.html
  -    // Selected ones included - please advise commons-dev@jakarta.apache.org
  -    // if you want another added or a mistake corrected
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Windows.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_WINDOWS = getOSMatches("Windows");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Windows 2000.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_WINDOWS_2000 = getOSMatches("Windows", "5.0");
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Windows 95.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_WINDOWS_95 = getOSMatches("Windows 9", "4.0");
  -    // JDK 1.2 running on Windows98 returns 'Windows 95', hence the above
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Windows 98.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_WINDOWS_98 = getOSMatches("Windows 9", "4.1");
  -    // JDK 1.2 running on Windows98 returns 'Windows 95', hence the above
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Windows ME.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_WINDOWS_ME = getOSMatches("Windows", "4.9");
  -    // JDK 1.2 running on WindowsME may return 'Windows 95', hence the above
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Windows NT.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_WINDOWS_NT = getOSMatches("Windows NT");
  -    // Windows 2000 returns 'Windows 2000' but may suffer from same JDK1.2 problem
  -
  -    /**
  -     * <p>Is <code>true</code> if this is Windows XP.</p>
  -     *
  -     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  -     * <code>null</code>.</p>
  -     */
  -    public static final boolean IS_OS_WINDOWS_XP = getOSMatches("Windows", "5.1");
  -
       /**
        * <p>The <code>java.class.path</code> System Property. Java class
path.</p>
        *
  @@ -432,33 +257,6 @@
        */
       public static final String JAVA_VERSION = getSystemProperty("java.version");
   
  -    //-----------------------------------------------------------------------
  -    /**
  -     * <p>Gets the Java version as a <code>float</code>.</p>
  -     *
  -     * <p>Example return values:</p>
  -     * <ul>
  -     *  <li><code>1.2f</code> for JDK 1.2
  -     *  <li><code>1.31f</code> for JDK 1.3.1
  -     * </ul>
  -     *
  -     * <p>The field will return zero if {@link #JAVA_VERSION} is <code>null</code>.</p>
  -     */
  -    public static final float JAVA_VERSION_FLOAT = getJavaVersionAsFloat();
  -
  -    /**
  -     * <p>Gets the Java version as an <code>int</code>.</p>
  -     *
  -     * <p>Example return values:</p>
  -     * <ul>
  -     *  <li><code>120</code> for JDK 1.2
  -     *  <li><code>131</code> for JDK 1.3.1
  -     * </ul>
  -     *
  -     * <p>The field will return zero if {@link #JAVA_VERSION} is <code>null</code>.</p>
  -     */
  -    public static final int JAVA_VERSION_INT = getJavaVersionAsInt();
  -
       /**
        * <p>The <code>java.vm.info</code> System Property. Java Virtual
Machine implementation
        * info.</p>
  @@ -644,6 +442,235 @@
        */
       public static final String USER_NAME = getSystemProperty("user.name");
   
  +    // Java version
  +    //-----------------------------------------------------------------------
  +    // These MUST be declared after those above as they depend on the
  +    // values being set up
  +    
  +    /**
  +     * <p>Gets the Java version as a <code>float</code>.</p>
  +     *
  +     * <p>Example return values:</p>
  +     * <ul>
  +     *  <li><code>1.2f</code> for JDK 1.2
  +     *  <li><code>1.31f</code> for JDK 1.3.1
  +     * </ul>
  +     *
  +     * <p>The field will return zero if {@link #JAVA_VERSION} is <code>null</code>.</p>
  +     */
  +    public static final float JAVA_VERSION_FLOAT = getJavaVersionAsFloat();
  +
  +    /**
  +     * <p>Gets the Java version as an <code>int</code>.</p>
  +     *
  +     * <p>Example return values:</p>
  +     * <ul>
  +     *  <li><code>120</code> for JDK 1.2
  +     *  <li><code>131</code> for JDK 1.3.1
  +     * </ul>
  +     *
  +     * <p>The field will return zero if {@link #JAVA_VERSION} is <code>null</code>.</p>
  +     */
  +    public static final int JAVA_VERSION_INT = getJavaVersionAsInt();
  +
  +    // Java version checks
  +    //-----------------------------------------------------------------------
  +    // These MUST be declared after those above as they depend on the
  +    // values being set up
  +    
  +    /**
  +     * <p>Is <code>true</code> if this is Java version 1.1 (also 1.1.x
versions).</p>
  +     *
  +     * <p>The field will return <code>false</code> if {@link #JAVA_VERSION}
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_JAVA_1_1 = getJavaVersionMatches("1.1");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Java version 1.2 (also 1.2.x
versions).</p>
  +     *
  +     * <p>The field will return <code>false</code> if {@link #JAVA_VERSION}
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_JAVA_1_2 = getJavaVersionMatches("1.2");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Java version 1.3 (also 1.3.x
versions).</p>
  +     *
  +     * <p>The field will return <code>false</code> if {@link #JAVA_VERSION}
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_JAVA_1_3 = getJavaVersionMatches("1.3");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Java version 1.4 (also 1.4.x
versions).</p>
  +     *
  +     * <p>The field will <code>false</code> false if {@link #JAVA_VERSION}
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_JAVA_1_4 = getJavaVersionMatches("1.4");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Java version 1.5 (also 1.5.x
versions).</p>
  +     *
  +     * <p>The field will return <code>false</code> if {@link #JAVA_VERSION}
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_JAVA_1_5 = getJavaVersionMatches("1.5");
  +
  +    // Operating system checks
  +    //-----------------------------------------------------------------------
  +    // These MUST be declared after those above as they depend on the
  +    // values being set up
  +    // OS names from http://www.vamphq.com/os.html
  +    // Selected ones included - please advise commons-dev@jakarta.apache.org
  +    // if you want another added or a mistake corrected
  +
  +    /**
  +     * <p>Is <code>true</code> if this is AIX.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_AIX = getOSMatches("AIX");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is HP-UX.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_HP_UX = getOSMatches("HP-UX");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Irix.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_IRIX = getOSMatches("Irix");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Linux.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_LINUX = getOSMatches("Linux") || getOSMatches("LINUX");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Mac.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_MAC = getOSMatches("Mac");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Mac.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_MAC_OSX = getOSMatches("Mac OS X");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is OS/2.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_OS2 = getOSMatches("OS/2");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Solaris.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_SOLARIS = getOSMatches("Solaris");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is SunOS.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_SUN_OS = getOSMatches("SunOS");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Windows.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_WINDOWS = getOSMatches("Windows");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Windows 2000.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_WINDOWS_2000 = getOSMatches("Windows", "5.0");
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Windows 95.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_WINDOWS_95 = getOSMatches("Windows 9", "4.0");
  +    // JDK 1.2 running on Windows98 returns 'Windows 95', hence the above
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Windows 98.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_WINDOWS_98 = getOSMatches("Windows 9", "4.1");
  +    // JDK 1.2 running on Windows98 returns 'Windows 95', hence the above
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Windows ME.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_WINDOWS_ME = getOSMatches("Windows", "4.9");
  +    // JDK 1.2 running on WindowsME may return 'Windows 95', hence the above
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Windows NT.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_WINDOWS_NT = getOSMatches("Windows NT");
  +    // Windows 2000 returns 'Windows 2000' but may suffer from same JDK1.2 problem
  +
  +    /**
  +     * <p>Is <code>true</code> if this is Windows XP.</p>
  +     *
  +     * <p>The field will return <code>false</code> if <code>OS_NAME</code>
is
  +     * <code>null</code>.</p>
  +     */
  +    public static final boolean IS_OS_WINDOWS_XP = getOSMatches("Windows", "5.1");
  +    // Windows XP returns 'Windows 2000' just for fun...
  +
  +    //-----------------------------------------------------------------------    
  +    /**
  +     * <p>SystemUtils instances should NOT be constructed in standard
  +     * programming. Instead, the class should be used as
  +     * <code>SystemUtils.FILE_SEPARATOR</code>.</p>
  +     *
  +     * <p>This constructor is public to permit tools that require a JavaBean
  +     * instance to operate.</p>
  +     */
  +    public SystemUtils() {
  +    }
  +    
       //-----------------------------------------------------------------------    
       /**
        * <p>Gets the Java version number as a <code>float</code>.</p>
  @@ -654,9 +681,9 @@
        *  <li><code>1.31f</code> for JDK 1.3.1
        * </ul>
        * 
  +     * @return the version, for example 1.31f for JDK 1.3.1
        * @deprecated Use {@link #JAVA_VERSION_FLOAT} instead.
        *             Method will be removed in Commons Lang 3.0.
  -     * @return the version, for example 1.31f for JDK 1.3.1
        */
       public static float getJavaVersion() {
           return JAVA_VERSION_FLOAT;
  @@ -811,17 +838,6 @@
        */
       public static boolean isJavaVersionAtLeast(int requiredVersion) {
           return (JAVA_VERSION_INT >= requiredVersion);
  -    }
  -    
  -    /**
  -     * <p>SystemUtils instances should NOT be constructed in standard
  -     * programming. Instead, the class should be used as
  -     * <code>SystemUtils.FILE_SEPARATOR</code>.</p>
  -     *
  -     * <p>This constructor is public to permit tools that require a JavaBean
  -     * instance to operate.</p>
  -     */
  -    public SystemUtils() {
       }
       
   }
  
  
  
  1.3       +49 -17    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SystemUtilsTest.java	24 May 2003 14:34:14 -0000	1.2
  +++ SystemUtilsTest.java	21 Jul 2003 22:57:51 -0000	1.3
  @@ -64,6 +64,7 @@
    * Only limited testing can be performed.
    *
    * @author Stephen Colebourne
  + * @author Tetsuya Kaneuchi
    * @version $Id$
    */
   public class SystemUtilsTest extends TestCase {
  @@ -74,22 +75,6 @@
   
       public static void main(String[] args) {
           TestRunner.run(suite());
  -//        SystemUtils s = new SystemUtils();
  -//        System.out.println(s.IS_OS_WINDOWS);
  -//        System.out.println(s.IS_OS_WINDOWS_95);
  -//        System.out.println(s.IS_OS_WINDOWS_98);
  -//        java.util.Properties p = System.getProperties();
  -//        java.util.Enumeration keys = p.keys();
  -//        java.util.List list = new java.util.ArrayList();
  -//        while( keys.hasMoreElements() ) {
  -//            list.add(keys.nextElement());
  -//        }
  -//        java.util.Collections.sort(list);
  -//        for (java.util.Iterator it = list.iterator(); it.hasNext();) {
  -//            String key = (String) it.next();
  -//            System.out.println(key + " " + p.getProperty(key));
  -//        }
  -    
       }
   
       public static Test suite() {
  @@ -354,6 +339,53 @@
           OS_NAME = "OS/2";
           OS_VERSION = "4.0";
           assertEquals(false, getOSMatches("Windows 9", "4.1"));
  +    }
  +
  +    public void testIS_OS() {
  +        String osName = System.getProperty("os.name");
  +        if (osName == null) {
  +            assertEquals(false, SystemUtils.IS_OS_WINDOWS);
  +            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);
  +        } else if (osName.startsWith("Solaris")) {
  +            assertTrue(SystemUtils.IS_OS_SOLARIS);
  +        } else if (osName.toLowerCase().startsWith("linux")) {
  +            assertTrue(SystemUtils.IS_OS_LINUX);
  +        } else if (osName.startsWith("Mac OS X")) {
  +            assertTrue(SystemUtils.IS_OS_MAC_OSX);
  +        } else if (osName.startsWith("OS/2")) {
  +            assertTrue(SystemUtils.IS_OS_OS2);
  +        } else if (osName.startsWith("SunOS")) {
  +            assertTrue(SystemUtils.IS_OS_SUN_OS);
  +        } else {
  +            System.out.println("Can't test IS_OS value");
  +        }
  +    }
  +
  +    public void testIS_JAVA() {
  +        String javaVersion = System.getProperty("java.version");
  +        if (javaVersion == null) {
  +            assertEquals(false, SystemUtils.IS_JAVA_1_1);
  +            assertEquals(false, SystemUtils.IS_JAVA_1_2);
  +            assertEquals(false, SystemUtils.IS_JAVA_1_3);
  +            assertEquals(false, SystemUtils.IS_JAVA_1_4);
  +            assertEquals(false, SystemUtils.IS_JAVA_1_5);
  +        } else if (javaVersion.startsWith("1.1")) {
  +            assertTrue(SystemUtils.IS_JAVA_1_1);
  +        } else if (javaVersion.startsWith("1.2")) {
  +            assertTrue(SystemUtils.IS_JAVA_1_2);
  +        } else if (javaVersion.startsWith("1.3")) {
  +            assertTrue(SystemUtils.IS_JAVA_1_3);
  +        } else if (javaVersion.startsWith("1.4")) {
  +            assertTrue(SystemUtils.IS_JAVA_1_4);
  +        } else if (javaVersion.startsWith("1.5")) {
  +            assertTrue(SystemUtils.IS_JAVA_1_5);
  +        } else {
  +            System.out.println("Can't test IS_JAVA value");
  +        }
       }
       
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message