IMO this is a really bad idea. Enum's shouldn't ever change, since
changing them can break code that use them. Clearly this enum will
need to change every time a new version of Java is released. I'm
against this.

Niall

On Sun, Jan 30, 2011 at 3:48 AM,  <bay...@apache.org> wrote:
> Author: bayard
> Date: Sun Jan 30 03:48:40 2011
> New Revision: 1065174
>
> URL: http://svn.apache.org/viewvc?rev=1065174&view=rev
> Log:
> Removed isJavaVersionAtLeast(float) and (int), and added an enum variant with 
> the new JavaVersion enum. Updated the rest of the code, switched 
> isJavaVersionAtLeast over to using java.specification.version and not 
> java.version (the vendor code) and dropped JAVA_VERSION_TRIMMED, 
> JAVA_VERSION_FLOAT and JAVA_VERSION_INT. See: LANG-624
>
> Added:
>    
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/JavaVersion.java
>    (with props)
> Modified:
>    
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ClassUtils.java
>    
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SystemUtils.java
>    
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharEncodingTest.java
>    
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
>    
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
>    
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
>    
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
>    
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
>    
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
>
> Modified: 
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ClassUtils.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ClassUtils.java?rev=1065174&r1=1065173&r2=1065174&view=diff
> ==============================================================================
> --- 
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ClassUtils.java
>  (original)
> +++ 
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ClassUtils.java
>  Sun Jan 30 03:48:40 2011
> @@ -436,7 +436,7 @@ public class ClassUtils {
>      * @return <code>true</code> if assignment possible
>      */
>     public static boolean isAssignable(Class<?>[] classArray, Class<?>[] 
> toClassArray) {
> -        return isAssignable(classArray, toClassArray, 
> SystemUtils.isJavaVersionAtLeast(1.5f));
> +        return isAssignable(classArray, toClassArray, 
> SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_5));
>     }
>
>     /**
> @@ -521,7 +521,7 @@ public class ClassUtils {
>      * @return <code>true</code> if assignment possible
>      */
>     public static boolean isAssignable(Class<?> cls, Class<?> toClass) {
> -        return isAssignable(cls, toClass, 
> SystemUtils.isJavaVersionAtLeast(1.5f));
> +        return isAssignable(cls, toClass, 
> SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_5));
>     }
>
>     /**
>
> Added: 
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/JavaVersion.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/JavaVersion.java?rev=1065174&view=auto
> ==============================================================================
> --- 
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/JavaVersion.java
>  (added)
> +++ 
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/JavaVersion.java
>  Sun Jan 30 03:48:40 2011
> @@ -0,0 +1,82 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.apache.commons.lang3;
> +
> +/**
> + * <p>An enum representing all the versions of the Java specification.
> + * This is intended to mirror available values from the
> + * <em>java.specification.version</em> System property. </p>
> + *
> + * @author Apache Software Foundation
> + * @since 3.0
> + * @version $Id: $
> + */
> +public enum JavaVersion {
> +    JAVA_0_9(1.5f, "0.9"),    // Android
> +    JAVA_1_1(1.1f, "1.1"),
> +    JAVA_1_2(1.2f, "1.2"),
> +    JAVA_1_3(1.3f, "1.3"),
> +    JAVA_1_4(1.4f, "1.4"),
> +    JAVA_1_5(1.5f, "1.5"),
> +    JAVA_1_6(1.6f, "1.6"),
> +    JAVA_1_7(1.7f, "1.7");
> +
> +    private float value;
> +    private String name;
> +
> +    JavaVersion(final float value, final String name) {
> +        this.value = value;
> +        this.name = name;
> +    }
> +
> +    public boolean atLeast(JavaVersion requiredVersion) {
> +        return this.value >= requiredVersion.value;
> +    }
> +
> +    // helper for static importing
> +    static JavaVersion getJavaVersion(final String nom) {
> +        return getJavaVersion(nom);
> +    }
> +    static JavaVersion get(final String nom) {
> +        if("0.9".equals(nom)) {
> +            return JAVA_0_9;
> +        } else
> +        if("1.1".equals(nom)) {
> +            return JAVA_1_1;
> +        } else
> +        if("1.2".equals(nom)) {
> +            return JAVA_1_2;
> +        } else
> +        if("1.3".equals(nom)) {
> +            return JAVA_1_3;
> +        } else
> +        if("1.4".equals(nom)) {
> +            return JAVA_1_4;
> +        } else
> +        if("1.5".equals(nom)) {
> +            return JAVA_1_5;
> +        } else
> +        if("1.6".equals(nom)) {
> +            return JAVA_1_6;
> +        } else
> +        if("1.7".equals(nom)) {
> +            return JAVA_1_7;
> +        } else {
> +            return null;
> +        }
> +    }
> +}
>
> Propchange: 
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/JavaVersion.java
> ------------------------------------------------------------------------------
>    svn:eol-style = native
>
> Modified: 
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SystemUtils.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SystemUtils.java?rev=1065174&r1=1065173&r2=1065174&view=diff
> ==============================================================================
> --- 
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SystemUtils.java
>  (original)
> +++ 
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SystemUtils.java
>  Sun Jan 30 03:48:40 2011
> @@ -473,6 +473,7 @@ public class SystemUtils {
>      * @since Java 1.3
>      */
>     public static final String JAVA_SPECIFICATION_VERSION = 
> getSystemProperty("java.specification.version");
> +    private static final JavaVersion JAVA_SPECIFICATION_VERSION_AS_ENUM = 
> JavaVersion.get(JAVA_SPECIFICATION_VERSION);
>
>     /**
>      * <p>
> @@ -898,71 +899,6 @@ public class SystemUtils {
>      */
>     public static final String USER_TIMEZONE = 
> getSystemProperty("user.timezone");
>
> -    // Java version
> -    // 
> -----------------------------------------------------------------------
> -    // This MUST be declared after those above as it depends on the
> -    // values being set up
> -
> -    /**
> -     * <p>
> -     * Gets the Java version as a <code>String</code> trimming leading 
> letters.
> -     * </p>
> -     *
> -     * <p>
> -     * The field will return <code>null</code> if {@link #JAVA_VERSION} is 
> <code>null</code>.
> -     * </p>
> -     *
> -     * @since 2.1
> -     */
> -    public static final String JAVA_VERSION_TRIMMED = 
> getJavaVersionTrimmed();
> -
> -    // Java version values
> -    // 
> -----------------------------------------------------------------------
> -    // These MUST be declared after the trim above as they depend on the
> -    // value 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 Java 1.2
> -     * <li><code>1.31f</code> for Java 1.3.1
> -     * </ul>
> -     *
> -     * <p>
> -     * The field will return zero if {@link #JAVA_VERSION} is 
> <code>null</code>.
> -     * </p>
> -     *
> -     * @since 2.0
> -     */
> -    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 Java 1.2
> -     * <li><code>131</code> for Java 1.3.1
> -     * </ul>
> -     *
> -     * <p>
> -     * The field will return zero if {@link #JAVA_VERSION} is 
> <code>null</code>.
> -     * </p>
> -     *
> -     * @since 2.0
> -     */
> -    public static final int JAVA_VERSION_INT = getJavaVersionAsInt();
> -
>     // Java version checks
>     // -----------------------------------------------------------------------
>     // These MUST be declared after those above as they depend on the
> @@ -1342,54 +1278,6 @@ public class SystemUtils {
>
>     /**
>      * <p>
> -     * Gets the Java version number as a <code>float</code>.
> -     * </p>
> -     *
> -     * <p>
> -     * Example return values:
> -     * </p>
> -     * <ul>
> -     * <li><code>1.2f</code> for Java 1.2</li>
> -     * <li><code>1.31f</code> for Java 1.3.1</li>
> -     * <li><code>1.6f</code> for Java 1.6.0_20</li>
> -     * </ul>
> -     *
> -     * <p>
> -     * Patch releases are not reported.
> -     * </p>
> -     *
> -     * @return the version, for example 1.31f for Java 1.3.1
> -     */
> -    private static float getJavaVersionAsFloat() {
> -        return 
> toVersionFloat(toJavaVersionIntArray(SystemUtils.JAVA_VERSION, 
> JAVA_VERSION_TRIM_SIZE));
> -    }
> -
> -    /**
> -     * <p>
> -     * Gets the Java version number as an <code>int</code>.
> -     * </p>
> -     *
> -     * <p>
> -     * Example return values:
> -     * </p>
> -     * <ul>
> -     * <li><code>120</code> for Java 1.2</li>
> -     * <li><code>131</code> for Java 1.3.1</li>
> -     * <li><code>160</code> for Java 1.6.0_20</li>
> -     * </ul>
> -     *
> -     * <p>
> -     * Patch releases are not reported.
> -     * </p>
> -     *
> -     * @return the version, for example 131 for Java 1.3.1
> -     */
> -    private static int getJavaVersionAsInt() {
> -        return toVersionInt(toJavaVersionIntArray(SystemUtils.JAVA_VERSION, 
> JAVA_VERSION_TRIM_SIZE));
> -    }
> -
> -    /**
> -     * <p>
>      * Decides if the Java version matches.
>      * </p>
>      *
> @@ -1398,24 +1286,7 @@ public class SystemUtils {
>      * @return true if matches, or false if not or can't determine
>      */
>     private static boolean getJavaVersionMatches(String versionPrefix) {
> -        return isJavaVersionMatch(JAVA_VERSION_TRIMMED, versionPrefix);
> -    }
> -
> -    /**
> -     * Trims the text of the java version to start with numbers.
> -     *
> -     * @return the trimmed java version
> -     */
> -    private static String getJavaVersionTrimmed() {
> -        if (JAVA_VERSION != null) {
> -            for (int i = 0; i < JAVA_VERSION.length(); i++) {
> -                char ch = JAVA_VERSION.charAt(i);
> -                if (ch >= '0' && ch <= '9') {
> -                    return JAVA_VERSION.substring(i);
> -                }
> -            }
> -        }
> -        return null;
> +        return isJavaVersionMatch(JAVA_SPECIFICATION_VERSION, versionPrefix);
>     }
>
>     /**
> @@ -1530,30 +1401,8 @@ public class SystemUtils {
>      *            the required version, for example 1.31f
>      * @return <code>true</code> if the actual version is equal or greater 
> than the required version
>      */
> -    public static boolean isJavaVersionAtLeast(float requiredVersion) {
> -        return JAVA_VERSION_FLOAT >= requiredVersion;
> -    }
> -
> -    /**
> -     * <p>
> -     * Is the Java version at least the requested version.
> -     * </p>
> -     *
> -     * <p>
> -     * Example input:
> -     * </p>
> -     * <ul>
> -     * <li><code>120</code> to test for Java 1.2 or greater</li>
> -     * <li><code>131</code> to test for Java 1.3.1 or greater</li>
> -     * </ul>
> -     *
> -     * @param requiredVersion
> -     *            the required version, for example 131
> -     * @return <code>true</code> if the actual version is equal or greater 
> than the required version
> -     * @since 2.0
> -     */
> -    public static boolean isJavaVersionAtLeast(int requiredVersion) {
> -        return JAVA_VERSION_INT >= requiredVersion;
> +    public static boolean isJavaVersionAtLeast(JavaVersion requiredVersion) {
> +        return JAVA_SPECIFICATION_VERSION_AS_ENUM.atLeast(requiredVersion);
>     }
>
>     /**
> @@ -1619,193 +1468,6 @@ public class SystemUtils {
>         return osName.startsWith(osNamePrefix);
>     }
>
> -    /**
> -     * <p>
> -     * Converts the given Java version string to a <code>float</code>.
> -     * </p>
> -     *
> -     * <p>
> -     * Example return values:
> -     * </p>
> -     * <ul>
> -     * <li><code>1.2f</code> for Java 1.2</li>
> -     * <li><code>1.31f</code> for Java 1.3.1</li>
> -     * <li><code>1.6f</code> for Java 1.6.0_20</li>
> -     * </ul>
> -     *
> -     * <p>
> -     * Patch releases are not reported.
> -     * </p>
> -     * <p>
> -     * This method is package private instead of private to support unit 
> test invocation.
> -     * </p>
> -     *
> -     * @return the version, for example 1.31f for Java 1.3.1
> -     */
> -    static float toJavaVersionFloat(String version) {
> -        return toVersionFloat(toJavaVersionIntArray(version, 
> JAVA_VERSION_TRIM_SIZE));
> -    }
> -
> -    /**
> -     * <p>
> -     * Converts the given Java version string to an <code>int</code>.
> -     * </p>
> -     *
> -     * <p>
> -     * Example return values:
> -     * </p>
> -     * <ul>
> -     * <li><code>120</code> for Java 1.2</li>
> -     * <li><code>131</code> for Java 1.3.1</li>
> -     * <li><code>160</code> for Java 1.6.0_20</li>
> -     * </ul>
> -     *
> -     * <p>
> -     * Patch releases are not reported.
> -     * </p>
> -     * <p>
> -     * This method is package private instead of private to support unit 
> test invocation.
> -     * </p>
> -     *
> -     * @return the version, for example 131 for Java 1.3.1
> -     */
> -    static int toJavaVersionInt(String version) {
> -        return toVersionInt(toJavaVersionIntArray(version, 
> JAVA_VERSION_TRIM_SIZE));
> -    }
> -
> -    /**
> -     * <p>
> -     * Converts the given Java version string to an <code>int[]</code> of 
> maximum size <code>3</code>.
> -     * </p>
> -     *
> -     * <p>
> -     * Example return values:
> -     * </p>
> -     * <ul>
> -     * <li><code>[1, 2, 0]</code> for Java 1.2</li>
> -     * <li><code>[1, 3, 1]</code> for Java 1.3.1</li>
> -     * <li><code>[1, 5, 0]</code> for Java 1.5.0_21</li>
> -     * </ul>
> -     * <p>
> -     * This method is package private instead of private to support unit 
> test invocation.
> -     * </p>
> -     *
> -     * @return the version, for example [1, 5, 0] for Java 1.5.0_21
> -     */
> -    static int[] toJavaVersionIntArray(String version) {
> -        return toJavaVersionIntArray(version, Integer.MAX_VALUE);
> -    }
> -
> -    /**
> -     * <p>
> -     * Converts the given Java version string to an <code>int[]</code> of 
> maximum size <code>limit</code>.
> -     * </p>
> -     *
> -     * <p>
> -     * Example return values:
> -     * </p>
> -     * <ul>
> -     * <li><code>[1, 2, 0]</code> for Java 1.2</li>
> -     * <li><code>[1, 3, 1]</code> for Java 1.3.1</li>
> -     * <li><code>[1, 5, 0, 21]</code> for Java 1.5.0_21</li>
> -     * </ul>
> -     *
> -     * @return the version, for example [1, 5, 0, 21] for Java 1.5.0_21
> -     */
> -    private static int[] toJavaVersionIntArray(String version, int limit) {
> -        if (version == null) {
> -            return ArrayUtils.EMPTY_INT_ARRAY;
> -        }
> -        String[] strings = Pattern.compile("[^\\d]").split(version);
> -        int[] ints = new int[Math.min(limit, strings.length)];
> -        int j = 0;
> -        for (int i = 0; i < strings.length && j < limit; i++) {
> -            String s = strings[i];
> -            if (s.length() > 0) {
> -                ints[j++] = Integer.parseInt(s);
> -            }
> -        }
> -        return ints;
> -    }
> -
> -    /**
> -     * <p>
> -     * Converts given the Java version array to a <code>float</code>.
> -     * </p>
> -     *
> -     * <p>
> -     * Example return values:
> -     * </p>
> -     * <ul>
> -     * <li><code>1.2f</code> for Java 1.2</li>
> -     * <li><code>1.31f</code> for Java 1.3.1</li>
> -     * <li><code>1.6f</code> for Java 1.6.0_20</li>
> -     * </ul>
> -     *
> -     * <p>
> -     * Patch releases are not reported.
> -     * </p>
> -     *
> -     * @return the version, for example 1.31f for Java 1.3.1
> -     */
> -    private static float toVersionFloat(int[] javaVersions) {
> -        if (javaVersions == null || javaVersions.length == 0) {
> -            return 0f;
> -        }
> -        if (javaVersions.length == 1) {
> -            return javaVersions[0];
> -        }
> -        StringBuilder builder = new StringBuilder();
> -        builder.append(javaVersions[0]);
> -        builder.append('.');
> -        for (int i = 1; i < javaVersions.length; i++) {
> -            builder.append(javaVersions[i]);
> -        }
> -        try {
> -            return Float.parseFloat(builder.toString());
> -        } catch (Exception ex) {
> -            return 0f;
> -        }
> -    }
> -
> -    /**
> -     * <p>
> -     * Converts given the Java version array to an <code>int</code>.
> -     * </p>
> -     *
> -     * <p>
> -     * Example return values:
> -     * </p>
> -     * <ul>
> -     * <li><code>120</code> for Java 1.2</li>
> -     * <li><code>131</code> for Java 1.3.1</li>
> -     * <li><code>160</code> for Java 1.6.0_20</li>
> -     * </ul>
> -     *
> -     * <p>
> -     * Patch releases are not reported.
> -     * </p>
> -     *
> -     * @return the version, for example 1.31f for Java 1.3.1
> -     */
> -    private static int toVersionInt(int[] javaVersions) {
> -        if (javaVersions == null) {
> -            return 0;
> -        }
> -        int intVersion = 0;
> -        int len = javaVersions.length;
> -        if (len >= 1) {
> -            intVersion = javaVersions[0] * 100;
> -        }
> -        if (len >= 2) {
> -            intVersion += javaVersions[1] * 10;
> -        }
> -        if (len >= 3) {
> -            intVersion += javaVersions[2];
> -        }
> -        return intVersion;
> -    }
> -
>     // -----------------------------------------------------------------------
>     /**
>      * <p>
>
> Modified: 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharEncodingTest.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharEncodingTest.java?rev=1065174&r1=1065173&r2=1065174&view=diff
> ==============================================================================
> --- 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharEncodingTest.java
>  (original)
> +++ 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharEncodingTest.java
>  Sun Jan 30 03:48:40 2011
> @@ -19,6 +19,8 @@ package org.apache.commons.lang3;
>
>  import junit.framework.TestCase;
>
> +import static org.apache.commons.lang3.JavaVersion.*;
> +
>  /**
>  * Tests CharEncoding.
>  *
> @@ -40,7 +42,7 @@ public class CharEncodingTest extends Te
>     }
>
>     public void testMustBeSupportedJava1_3_1() {
> -        if (SystemUtils.isJavaVersionAtLeast(1.3f)) {
> +        if (SystemUtils.isJavaVersionAtLeast(JAVA_1_3)) {
>             this.assertSupportedEncoding(CharEncoding.ISO_8859_1);
>             this.assertSupportedEncoding(CharEncoding.US_ASCII);
>             this.assertSupportedEncoding(CharEncoding.UTF_16);
> @@ -48,7 +50,7 @@ public class CharEncodingTest extends Te
>             this.assertSupportedEncoding(CharEncoding.UTF_16LE);
>             this.assertSupportedEncoding(CharEncoding.UTF_8);
>         } else {
> -            this.warn("Java 1.3 tests not run since the current version is " 
> + SystemUtils.JAVA_VERSION);
> +            this.warn("Java 1.3 tests not run since the current version is " 
> + SystemUtils.JAVA_SPECIFICATION_VERSION);
>         }
>     }
>
> @@ -66,12 +68,12 @@ public class CharEncodingTest extends Te
>         // In this test, I simply deleted the encodings from the 1.3.1 list.
>         // The Javadoc do not specify which encodings are required.
>         //
> -        if (SystemUtils.isJavaVersionAtLeast(1.1f)) {
> +        if (SystemUtils.isJavaVersionAtLeast(JAVA_1_1)) {
>             this.assertSupportedEncoding(CharEncoding.ISO_8859_1);
>             this.assertSupportedEncoding(CharEncoding.US_ASCII);
>             this.assertSupportedEncoding(CharEncoding.UTF_8);
>         } else {
> -            this.warn("Java 1.1 tests not run since the current version is " 
> + SystemUtils.JAVA_VERSION);
> +            this.warn("Java 1.1 tests not run since the current version is " 
> + SystemUtils.JAVA_SPECIFICATION_VERSION);
>         }
>     }
>
> @@ -80,12 +82,12 @@ public class CharEncodingTest extends Te
>         // In this test, I simply deleted the encodings from the 1.3.1 list.
>         // The Javadoc do not specify which encodings are required.
>         //
> -        if (SystemUtils.isJavaVersionAtLeast(1.2f)) {
> +        if (SystemUtils.isJavaVersionAtLeast(JAVA_1_2)) {
>             this.assertSupportedEncoding(CharEncoding.ISO_8859_1);
>             this.assertSupportedEncoding(CharEncoding.US_ASCII);
>             this.assertSupportedEncoding(CharEncoding.UTF_8);
>         } else {
> -            this.warn("Java 1.2 tests not run since the current version is " 
> + SystemUtils.JAVA_VERSION);
> +            this.warn("Java 1.2 tests not run since the current version is " 
> + SystemUtils.JAVA_SPECIFICATION_VERSION);
>         }
>     }
>
>
> Modified: 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java?rev=1065174&r1=1065173&r2=1065174&view=diff
> ==============================================================================
> --- 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
>  (original)
> +++ 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
>  Sun Jan 30 03:48:40 2011
> @@ -27,6 +27,8 @@ import java.util.List;
>  import java.util.Map;
>  import java.util.Set;
>
> +import static org.apache.commons.lang3.JavaVersion.*;
> +
>  import junit.framework.TestCase;
>
>  /**
> @@ -265,7 +267,7 @@ public class ClassUtilsTest extends Test
>         assertTrue(ClassUtils.isAssignable(array1s, array1s));
>         assertTrue(ClassUtils.isAssignable(array1s, array1));
>
> -        boolean autoboxing = SystemUtils.isJavaVersionAtLeast(1.5f);
> +        boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
>
>         assertEquals(autoboxing, ClassUtils.isAssignable(arrayPrimitives, 
> arrayWrappers));
>         assertEquals(autoboxing, ClassUtils.isAssignable(arrayWrappers, 
> arrayPrimitives));
> @@ -340,7 +342,7 @@ public class ClassUtilsTest extends Test
>         assertTrue(ClassUtils.isAssignable(String.class, String.class));
>         assertFalse(ClassUtils.isAssignable(Object.class, String.class));
>
> -        boolean autoboxing = SystemUtils.isJavaVersionAtLeast(1.5f);
> +        boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
>
>         assertEquals(autoboxing, ClassUtils.isAssignable(Integer.TYPE, 
> Integer.class));
>         assertEquals(autoboxing, ClassUtils.isAssignable(Integer.TYPE, 
> Object.class));
> @@ -485,7 +487,7 @@ public class ClassUtilsTest extends Test
>     }
>
>     public void test_isAssignable_DefaultUnboxing_Widening() throws Exception 
> {
> -        boolean autoboxing = SystemUtils.isJavaVersionAtLeast(1.5f);
> +        boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
>
>         // test byte conversions
>         assertFalse("byte -> char", ClassUtils.isAssignable(Byte.class, 
> Character.TYPE));
>
> Modified: 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java?rev=1065174&r1=1065173&r2=1065174&view=diff
> ==============================================================================
> --- 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
>  (original)
> +++ 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
>  Sun Jan 30 03:48:40 2011
> @@ -26,6 +26,8 @@ import java.util.List;
>  import java.util.Locale;
>  import java.util.Set;
>
> +import static org.apache.commons.lang3.JavaVersion.*;
> +
>  import junit.framework.TestCase;
>
>  /**
> @@ -212,7 +214,7 @@ public class LocaleUtilsTest extends Tes
>         assertValidToLocale("us_EN_A", "us", "EN", "A");
>         // this isn't pretty, but was caused by a jdk bug it seems
>         // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4210525
> -        if (SystemUtils.isJavaVersionAtLeast(1.4f)) {
> +        if (SystemUtils.isJavaVersionAtLeast(JAVA_1_4)) {
>             assertValidToLocale("us_EN_a", "us", "EN", "a");
>             assertValidToLocale("us_EN_SFsafdFDsdfF", "us", "EN", 
> "SFsafdFDsdfF");
>         } else {
>
> Modified: 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java?rev=1065174&r1=1065173&r2=1065174&view=diff
> ==============================================================================
> --- 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
>  (original)
> +++ 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
>  Sun Jan 30 03:48:40 2011
> @@ -27,6 +27,8 @@ import java.util.Locale;
>  import junit.framework.Assert;
>  import junit.framework.TestCase;
>
> +import static org.apache.commons.lang3.JavaVersion.*;
> +
>  /**
>  * Unit tests {@link org.apache.commons.lang3.SystemUtils}.
>  *
> @@ -187,62 +189,6 @@ public class SystemUtilsTest extends Tes
>         }
>     }
>
> -    public void testJavaVersionAsFloat() {
> -        assertEquals(0f, SystemUtils.toJavaVersionFloat(null), 0.000001f);
> -        assertEquals(0f, SystemUtils.toJavaVersionFloat(""), 0.000001f);
> -        assertEquals(0f, SystemUtils.toJavaVersionFloat("0"), 0.000001f);
> -        assertEquals(1.1f, SystemUtils.toJavaVersionFloat("1.1"), 0.000001f);
> -        assertEquals(1.2f, SystemUtils.toJavaVersionFloat("1.2"), 0.000001f);
> -        assertEquals(1.3f, SystemUtils.toJavaVersionFloat("1.3.0"), 
> 0.000001f);
> -        assertEquals(1.31f, SystemUtils.toJavaVersionFloat("1.3.1"), 
> 0.000001f);
> -        assertEquals(1.4f, SystemUtils.toJavaVersionFloat("1.4.0"), 
> 0.000001f);
> -        assertEquals(1.41f, SystemUtils.toJavaVersionFloat("1.4.1"), 
> 0.000001f);
> -        assertEquals(1.42f, SystemUtils.toJavaVersionFloat("1.4.2"), 
> 0.000001f);
> -        assertEquals(1.5f, SystemUtils.toJavaVersionFloat("1.5.0"), 
> 0.000001f);
> -        assertEquals(1.6f, SystemUtils.toJavaVersionFloat("1.6.0"), 
> 0.000001f);
> -        assertEquals(1.31f, SystemUtils.toJavaVersionFloat("JavaVM-1.3.1"), 
> 0.000001f);
> -        assertEquals(1.3f, SystemUtils.toJavaVersionFloat("1.3.0 subset"), 
> 0.000001f);
> -        // This used to return 0f in [lang] version 2.5:
> -        assertEquals(1.3f, SystemUtils.toJavaVersionFloat("XXX-1.3.x"), 
> 0.000001f);
> -    }
> -
> -    public void testJavaVersionAsInt() {
> -        assertEquals(0, SystemUtils.toJavaVersionInt(null));
> -        assertEquals(0, SystemUtils.toJavaVersionInt(""));
> -        assertEquals(0, SystemUtils.toJavaVersionInt("0"));
> -        assertEquals(110, SystemUtils.toJavaVersionInt("1.1"));
> -        assertEquals(120, SystemUtils.toJavaVersionInt("1.2"));
> -        assertEquals(130, SystemUtils.toJavaVersionInt("1.3.0"));
> -        assertEquals(131, SystemUtils.toJavaVersionInt("1.3.1"));
> -        assertEquals(140, SystemUtils.toJavaVersionInt("1.4.0"));
> -        assertEquals(141, SystemUtils.toJavaVersionInt("1.4.1"));
> -        assertEquals(142, SystemUtils.toJavaVersionInt("1.4.2"));
> -        assertEquals(150, SystemUtils.toJavaVersionInt("1.5.0"));
> -        assertEquals(160, SystemUtils.toJavaVersionInt("1.6.0"));
> -        assertEquals(131, SystemUtils.toJavaVersionInt("JavaVM-1.3.1"));
> -        assertEquals(131, SystemUtils.toJavaVersionInt("1.3.1 subset"));
> -        // This used to return 0f in [lang] version 2.5:
> -        assertEquals(130, SystemUtils.toJavaVersionInt("XXX-1.3.x"));
> -    }
> -
> -    public void testJavaVersionAtLeastFloat() {
> -        float version = SystemUtils.JAVA_VERSION_FLOAT;
> -        assertEquals(true, SystemUtils.isJavaVersionAtLeast(version));
> -        version -= 0.1f;
> -        assertEquals(true, SystemUtils.isJavaVersionAtLeast(version));
> -        version += 0.2f;
> -        assertEquals(false, SystemUtils.isJavaVersionAtLeast(version));
> -    }
> -
> -    public void testJavaVersionAtLeastInt() {
> -        int version = SystemUtils.JAVA_VERSION_INT;
> -        assertEquals(true, SystemUtils.isJavaVersionAtLeast(version));
> -        version -= 10;
> -        assertEquals(true, SystemUtils.isJavaVersionAtLeast(version));
> -        version += 20;
> -        assertEquals(false, SystemUtils.isJavaVersionAtLeast(version));
> -    }
> -
>     public void testJavaVersionMatches() {
>         String javaVersion = null;
>         assertEquals(false, SystemUtils.isJavaVersionMatch(javaVersion, 
> "1.0"));
> @@ -401,7 +347,7 @@ public class SystemUtilsTest extends Tes
>     }
>
>     public void testJavaAwtHeadless() {
> -        boolean atLeastJava14 = SystemUtils.isJavaVersionAtLeast(140);
> +        boolean atLeastJava14 = SystemUtils.isJavaVersionAtLeast(JAVA_1_4);
>         String expectedStringValue = System.getProperty("java.awt.headless");
>         String expectedStringValueWithDefault = 
> System.getProperty("java.awt.headless", "false");
>         assertNotNull(expectedStringValueWithDefault);
>
> Modified: 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java?rev=1065174&r1=1065173&r2=1065174&view=diff
> ==============================================================================
> --- 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
>  (original)
> +++ 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
>  Sun Jan 30 03:48:40 2011
> @@ -23,6 +23,7 @@ import java.math.BigInteger;
>
>  import junit.framework.TestCase;
>
> +import static org.apache.commons.lang3.JavaVersion.*;
>  import org.apache.commons.lang3.SystemUtils;
>
>  /**
> @@ -198,7 +199,7 @@ public class NumberUtilsTest extends Tes
>                 .createNumber("12345678901234567890L"));
>
>         // jdk 1.2 doesn't support this. unsure about jdk 1.2.2
> -        if (SystemUtils.isJavaVersionAtLeast(1.3f)) {
> +        if (SystemUtils.isJavaVersionAtLeast(JAVA_1_3)) {
>             assertEquals("createNumber(String) 15 failed", new 
> BigDecimal("1.1E-700"), NumberUtils
>                     .createNumber("1.1E-700F"));
>         }
>
> Modified: 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java?rev=1065174&r1=1065173&r2=1065174&view=diff
> ==============================================================================
> --- 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
>  (original)
> +++ 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
>  Sun Jan 30 03:48:40 2011
> @@ -34,6 +34,7 @@ import java.util.Map;
>
>  import junit.framework.TestCase;
>
> +import static org.apache.commons.lang3.JavaVersion.*;
>  import org.apache.commons.lang3.SystemUtils;
>
>  /**
> @@ -359,7 +360,7 @@ public class ExtendedMessageFormatTest e
>
>     //can't trust what MessageFormat does with toPattern() pre 1.4:
>     private void assertPatternsEqual(String message, String expected, String 
> actual) {
> -        if (SystemUtils.isJavaVersionAtLeast(1.4f)) {
> +        if (SystemUtils.isJavaVersionAtLeast(JAVA_1_4)) {
>             assertEquals(message, expected, actual);
>         }
>     }
>
> Modified: 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java?rev=1065174&r1=1065173&r2=1065174&view=diff
> ==============================================================================
> --- 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
>  (original)
> +++ 
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
>  Sun Jan 30 03:48:40 2011
> @@ -32,6 +32,7 @@ import java.util.TimeZone;
>  import junit.framework.AssertionFailedError;
>  import junit.framework.TestCase;
>
> +import static org.apache.commons.lang3.JavaVersion.*;
>  import org.apache.commons.lang3.SystemUtils;
>
>  /**
> @@ -805,7 +806,7 @@ public class DateUtilsTest extends TestC
>         assertEquals("round MET date across DST change-over",
>                 dateTimeParser.parse("March 30, 2003 01:00:00.000"),
>                 DateUtils.round((Object) cal4, Calendar.HOUR_OF_DAY));
> -        if (SystemUtils.isJavaVersionAtLeast(1.4f)) {
> +        if (SystemUtils.isJavaVersionAtLeast(JAVA_1_4)) {
>             assertEquals("round MET date across DST change-over",
>                     dateTimeParser.parse("March 30, 2003 03:00:00.000"),
>                     DateUtils.round(date5, Calendar.HOUR_OF_DAY));
> @@ -825,7 +826,7 @@ public class DateUtilsTest extends TestC
>                     dateTimeParser.parse("March 30, 2003 04:00:00.000"),
>                     DateUtils.round((Object) cal7, Calendar.HOUR_OF_DAY));
>         } else {
> -            this.warn("WARNING: Some date rounding tests not run since the 
> current version is " + SystemUtils.JAVA_VERSION);
> +            this.warn("WARNING: Some date rounding tests not run since the 
> current version is " + SystemUtils.JAVA_SPECIFICATION_VERSION);
>         }
>         TimeZone.setDefault(defaultZone);
>         dateTimeParser.setTimeZone(defaultZone);
> @@ -1091,8 +1092,8 @@ public class DateUtilsTest extends TestC
>      * see http://issues.apache.org/jira/browse/LANG-59
>      */
>     public void testTruncateLang59() throws Exception {
> -        if (!SystemUtils.isJavaVersionAtLeast(1.4f)) {
> -            this.warn("WARNING: Test for LANG-59 not run since the current 
> version is " + SystemUtils.JAVA_VERSION);
> +        if (!SystemUtils.isJavaVersionAtLeast(JAVA_1_4)) {
> +            this.warn("WARNING: Test for LANG-59 not run since the current 
> version is " + SystemUtils.JAVA_SPECIFICATION_VERSION);
>             return;
>         }
>
> @@ -1379,7 +1380,7 @@ public class DateUtilsTest extends TestC
>         assertEquals("ceiling MET date across DST change-over",
>                 dateTimeParser.parse("March 30, 2003 03:00:00.000"),
>                 DateUtils.ceiling((Object) cal4, Calendar.HOUR_OF_DAY));
> -        if (SystemUtils.isJavaVersionAtLeast(1.4f)) {
> +        if (SystemUtils.isJavaVersionAtLeast(JAVA_1_4)) {
>             assertEquals("ceiling MET date across DST change-over",
>                     dateTimeParser.parse("March 30, 2003 03:00:00.000"),
>                     DateUtils.ceiling(date5, Calendar.HOUR_OF_DAY));
> @@ -1399,7 +1400,7 @@ public class DateUtilsTest extends TestC
>                     dateTimeParser.parse("March 30, 2003 04:00:00.000"),
>                     DateUtils.ceiling((Object) cal7, Calendar.HOUR_OF_DAY));
>         } else {
> -            this.warn("WARNING: Some date ceiling tests not run since the 
> current version is " + SystemUtils.JAVA_VERSION);
> +            this.warn("WARNING: Some date ceiling tests not run since the 
> current version is " + SystemUtils.JAVA_SPECIFICATION_VERSION);
>         }
>         TimeZone.setDefault(defaultZone);
>         dateTimeParser.setTimeZone(defaultZone);
>
>
>

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

Reply via email to