svn commit: r178911 - /jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r178911 - /jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java

stevencaswell
Author: stevencaswell
Date: Sat May 28 18:10:24 2005
New Revision: 178911

URL: http://svn.apache.org/viewcvs?rev=178911&view=rev
Log:
added guard around some rounding tests that do not work in JDK versions prior to 1.4

Modified:
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java?rev=178911&r1=178910&r2=178911&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java (original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java Sat May 28 18:10:24 2005
@@ -34,6 +34,8 @@
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 
+import org.apache.commons.lang.SystemUtils;
+
 /**
  * Unit tests {@link org.apache.commons.lang.time.DateUtils}.
  *
@@ -469,24 +471,28 @@
         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));
-        assertEquals("round MET date across DST change-over",
-                dateTimeParser.parse("March 30, 2003 03:00:00.000"),
-                DateUtils.round(date5, Calendar.HOUR_OF_DAY));
-        assertEquals("round MET date across DST change-over",
-                dateTimeParser.parse("March 30, 2003 03:00:00.000"),
-                DateUtils.round((Object) cal5, Calendar.HOUR_OF_DAY));
-        assertEquals("round MET date across DST change-over",
-                dateTimeParser.parse("March 30, 2003 03:00:00.000"),
-                DateUtils.round(date6, Calendar.HOUR_OF_DAY));
-        assertEquals("round MET date across DST change-over",
-                dateTimeParser.parse("March 30, 2003 03:00:00.000"),
-                DateUtils.round((Object) cal6, Calendar.HOUR_OF_DAY));
-        assertEquals("round MET date across DST change-over",
-                dateTimeParser.parse("March 30, 2003 04:00:00.000"),
-                DateUtils.round(date7, Calendar.HOUR_OF_DAY));
-        assertEquals("round MET date across DST change-over",
-                dateTimeParser.parse("March 30, 2003 04:00:00.000"),
-                DateUtils.round((Object) cal7, Calendar.HOUR_OF_DAY));
+        if (SystemUtils.isJavaVersionAtLeast(1.4f)) {
+            assertEquals("round MET date across DST change-over",
+                    dateTimeParser.parse("March 30, 2003 03:00:00.000"),
+                    DateUtils.round(date5, Calendar.HOUR_OF_DAY));
+            assertEquals("round MET date across DST change-over",
+                    dateTimeParser.parse("March 30, 2003 03:00:00.000"),
+                    DateUtils.round((Object) cal5, Calendar.HOUR_OF_DAY));
+            assertEquals("round MET date across DST change-over",
+                    dateTimeParser.parse("March 30, 2003 03:00:00.000"),
+                    DateUtils.round(date6, Calendar.HOUR_OF_DAY));
+            assertEquals("round MET date across DST change-over",
+                    dateTimeParser.parse("March 30, 2003 03:00:00.000"),
+                    DateUtils.round((Object) cal6, Calendar.HOUR_OF_DAY));
+            assertEquals("round MET date across DST change-over",
+                    dateTimeParser.parse("March 30, 2003 04:00:00.000"),
+                    DateUtils.round(date7, Calendar.HOUR_OF_DAY));
+            assertEquals("round MET date across DST change-over",
+                    dateTimeParser.parse("March 30, 2003 04:00:00.000"),
+                    DateUtils.round((Object) cal7, Calendar.HOUR_OF_DAY));
+        } else {
+            this.warn("Some date rounding tests not run since the current version is " + SystemUtils.JAVA_VERSION);
+        }
         TimeZone.setDefault(defaultZone);
         dateTimeParser.setTimeZone(defaultZone);
     }
@@ -838,6 +844,10 @@
             throw new AssertionFailedError(
                     message + " expected " + cal1.getTime() + " but got " + cal2.getTime());
         }
+    }
+
+    void warn(String msg) {
+        System.err.println(msg);
     }
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]