commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevencasw...@apache.org
Subject cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang/time DateUtilsTest.java
Date Sun, 11 Jul 2004 18:40:35 GMT
stevencaswell    2004/07/11 11:40:35

  Modified:    lang/src/test/org/apache/commons/lang/time
                        DateUtilsTest.java
  Log:
  moved testParseCVS to sandbox DateFormatterTest.java
  
  Revision  Changes    Path
  1.14      +0 -206    jakarta-commons/lang/src/test/org/apache/commons/lang/time/DateUtilsTest.java
  
  Index: DateUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/time/DateUtilsTest.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DateUtilsTest.java	5 Jul 2004 17:55:53 -0000	1.13
  +++ DateUtilsTest.java	11 Jul 2004 18:40:35 -0000	1.14
  @@ -443,212 +443,6 @@
           dateTimeParser.setTimeZone(defaultZone);
       }
   
  -    // TODO: Decide whether this code is removed or goes into 2.1
  -    /*
  -     * Tests the parse method, which is supposed to handle various strings
  -     * as flexibly as CVS supports.
  -    public void testParseCVS() throws Exception {
  -        try {
  -            DateUtils.parseCVS(null);
  -            fail();
  -        } catch (IllegalArgumentException ex) {}
  -        try {
  -            DateUtils.parseCVS("gobbledegook");
  -            fail();
  -        } catch (IllegalArgumentException ex) {}
  -        try {
  -            DateUtils.parseCVS("ago");
  -            fail();
  -        } catch (IllegalArgumentException ex) {}
  -        try {
  -            DateUtils.parseCVS("1 junk ago");
  -            fail();
  -        } catch (IllegalArgumentException ex) {}
  -        try {
  -            DateUtils.parseCVS("1month ago");
  -            fail();
  -        } catch (IllegalArgumentException ex) {}
  -        try {
  -            DateUtils.parseCVS("last month");
  -            fail();
  -        } catch (IllegalArgumentException ex) {}
  -
  -
  -        //This is difficult to test since the "now" used in the
  -        //  parse function cannot be controlled.  We could possibly control
  -        //  it by trying before and after and making sure the value we expect
  -        //  is between the two values calculated.
  -        //For now we're just using the custom assertEquals that takes a delta
  -
  -        Calendar now = null;
  -
  -        // M/dd/yy H:mm:ss z
  -        now = Calendar.getInstance();
  -        now.set(Calendar.MILLISECOND, 0);
  -        assertEquals("parseCVS format M/dd/yy H:mm:ss z",
  -                  now, DateUtils.parseCVS(new SimpleDateFormat("M/dd/yy H:mm:ss z").format(now.getTime())),
50);
  -        // MMM d, yyyy h:mm a
  -        now = Calendar.getInstance();
  -        now.set(Calendar.MILLISECOND, 0);
  -        now.set(Calendar.SECOND, 0);
  -        assertEquals("parseCVS format MMM d, yyyy h:mm a",
  -                  now, DateUtils.parseCVS(new SimpleDateFormat("MMM d, yyyy h:mm a").format(now.getTime())),
50);
  -        // h:mm z
  -        //
  -        // This format is difficult to test using the current time because the
  -        // parseCVS method applies the default date of January 1, 1970 to the
  -        // parsed time. The most straightforward way to test the parse is to
  -        // pass in a known value, and test the output against this know value.
  -        // 
  -        now = Calendar.getInstance();
  -        now.setTime(new SimpleDateFormat("h:mm z").parse("16:30 GMT"));
  -        assertEquals("parseCVS format h:mm z 16:30 GMT", 
  -                  now, DateUtils.parseCVS("16:30 GMT"), 50);
  -        now = Calendar.getInstance();
  -        now.setTime(new SimpleDateFormat("h:mm z").parse("16:30 EST"));
  -        assertEquals("parseCVS format h:mm z 16:30 EST", 
  -                  now, DateUtils.parseCVS("16:30 EST"), 50);
  -        now = Calendar.getInstance();
  -        now.setTime(new SimpleDateFormat("h:mm z").parse("16:30 GMT-05:00"));
  -        assertEquals("parseCVS format h:mm z 16:30 GMT-05:00", 
  -                  now, DateUtils.parseCVS("16:30 GMT-05:00"), 50);
  -        now = Calendar.getInstance();
  -        now.setTime(new SimpleDateFormat("h:mm z").parse("16:30 GMT+01:00"));
  -        assertEquals("parseCVS format h:mm z 16:30 GMT+01:00", 
  -                  now, DateUtils.parseCVS("16:30 GMT+01:00"), 50);
  -        
  -        now = Calendar.getInstance();
  -        now.setTime(new SimpleDateFormat("h:mm z").parse("06:30 GMT"));
  -        assertEquals("parseCVS format h:mm z 06:30 GMT", 
  -                  now, DateUtils.parseCVS("06:30 GMT"), 50);
  -        now = Calendar.getInstance();
  -        now.setTime(new SimpleDateFormat("h:mm z").parse("06:30 EST"));
  -        assertEquals("parseCVS format h:mm z 06:30 EST", 
  -                  now, DateUtils.parseCVS("06:30 EST"), 50);
  -        now = Calendar.getInstance();
  -        now.setTime(new SimpleDateFormat("h:mm z").parse("06:30 GMT-05:00"));
  -        assertEquals("parseCVS format h:mm z 06:30 GMT-05:00", 
  -                  now, DateUtils.parseCVS("06:30 GMT-05:00"), 50);
  -        now = Calendar.getInstance();
  -        now.setTime(new SimpleDateFormat("h:mm z").parse("06:30 GMT+01:00"));
  -        assertEquals("parseCVS format h:mm z 06:30 GMT+01:00", 
  -                  now, DateUtils.parseCVS("06:30 GMT+01:00"), 50);
  -        
  -        now = Calendar.getInstance();
  -        now.add(Calendar.WEEK_OF_MONTH, -1);
  -        assertEquals("parseCVS a week ago",
  -                now, DateUtils.parseCVS("a week ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.WEEK_OF_MONTH, -1);
  -        assertEquals("parseCVS an week ago",
  -                now, DateUtils.parseCVS("an week ago"), 50);
  -        
  -        now = Calendar.getInstance();
  -        now.add(Calendar.DAY_OF_MONTH, -14);
  -        assertEquals("parseCVS 1 fortnight ago",
  -                now, DateUtils.parseCVS("1 fortnight ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.DAY_OF_MONTH, -14);
  -        assertEquals("parseCVS 1 fortnights ago",
  -                now, DateUtils.parseCVS("1 fortnights ago"), 50);
  -        
  -        now = Calendar.getInstance();
  -        now.add(Calendar.MINUTE, -1);
  -        assertEquals("parseCVS 1 minute ago",
  -                now, DateUtils.parseCVS("1 minute ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.MINUTE, -8);
  -        assertEquals("parseCVS 8 minutes ago",
  -                now, DateUtils.parseCVS("8 minutes ago"), 50);
  -
  -        now = Calendar.getInstance();
  -        now.add(Calendar.MILLISECOND, -1);
  -        assertEquals("parseCVS 1 millisecond ago",
  -                now, DateUtils.parseCVS("1 millisecond ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.MILLISECOND, -100);
  -        assertEquals("parseCVS 1 milliseconds ago",
  -                now, DateUtils.parseCVS("100 milliseconds ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.SECOND, -30);
  -        assertEquals("parseCVS 30 second ago",
  -                now, DateUtils.parseCVS("30 second ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.SECOND, -30);
  -        assertEquals("parseCVS 30 seconds ago",
  -                now, DateUtils.parseCVS("30 seconds ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.HOUR, -2);
  -        assertEquals("parseCVS 2 hour ago",
  -                now, DateUtils.parseCVS("2 hour ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.HOUR, -2);
  -        assertEquals("parseCVS 2 hours ago",
  -                now, DateUtils.parseCVS("2 hours ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.DAY_OF_MONTH, -2);
  -        assertEquals("parseCVS 2 day ago",
  -                now, DateUtils.parseCVS("2 day ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.DAY_OF_MONTH, -2);
  -        assertEquals("parseCVS 2 days ago",
  -                now, DateUtils.parseCVS("2 days ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.MONTH, -2);
  -        assertEquals("parseCVS 2 month ago",
  -                now, DateUtils.parseCVS("2 month ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.MONTH, -2);
  -        assertEquals("parseCVS 2 months ago",
  -                now, DateUtils.parseCVS("2 months ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.YEAR, -2);
  -        assertEquals("parseCVS 2 year ago",
  -                now, DateUtils.parseCVS("2 year ago"), 50);
  -        now = Calendar.getInstance();
  -        now.add(Calendar.YEAR, -2);
  -        assertEquals("parseCVS 2 years ago",
  -                now, DateUtils.parseCVS("2 years ago"), 50);
  -        
  -        now = Calendar.getInstance();
  -        now.add(Calendar.DATE, -1);
  -        assertEquals("parseCVS yesterday",
  -                now, DateUtils.parseCVS("yesterday"), 50);
  -
  -        now = Calendar.getInstance();
  -        now.add(Calendar.DATE, 1);
  -        assertEquals("parseCVS tomorrow",
  -                now, DateUtils.parseCVS("tomorrow"), 50);
  -
  -        now = Calendar.getInstance();
  -        //Sunday would be 1, Saturday would be 7, so we walk back up to 6 days.
  -        if (now.get(Calendar.DAY_OF_WEEK) == 1) {
  -            //If Sunday already, we go back a full week
  -            now.add(Calendar.DATE, -7);
  -        } else {
  -            now.add(Calendar.DATE, 1 - now.get(Calendar.DAY_OF_WEEK));
  -        }
  -        assertEquals("parseCVS last Sunday",
  -                now, DateUtils.parseCVS("last Sunday"), 50);
  -
  -        now = Calendar.getInstance();
  -        now.add(Calendar.DATE, -7);
  -        assertEquals("parseCVS last week",
  -                now, DateUtils.parseCVS("last week"), 50);
  -        
  -        now = Calendar.getInstance();
  -        //January would be 0, December would be 11, so we walk back up to 11 months
  -        if (now.get(Calendar.MONTH) == 0) {
  -            //If January already, we go back a full year
  -            now.add(Calendar.MONTH, -12);
  -        } else {
  -            now.add(Calendar.MONTH, 0 - now.get(Calendar.MONTH));
  -        }
  -        assertEquals("parseCVS last January",
  -                now, DateUtils.parseCVS("last January"), 50);
  -    }
  -     */
  -
       /**
        * Tests the iterator exceptions
        */
  
  
  

---------------------------------------------------------------------
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