directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r742085 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java
Date Sun, 08 Feb 2009 13:07:47 GMT
Author: seelmann
Date: Sun Feb  8 13:07:46 2009
New Revision: 742085

URL: http://svn.apache.org/viewvc?rev=742085&view=rev
Log:
Set the calendar back to its default lenient, added a test

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java?rev=742085&r1=742084&r2=742085&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java
Sun Feb  8 13:07:46 2009
@@ -317,6 +317,8 @@
         {
             throw new ParseException( "Invalid date/time values.", 0 );
         }
+
+        calendar.setLenient( true );
     }
 
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java?rev=742085&r1=742084&r2=742085&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java
Sun Feb  8 13:07:46 2009
@@ -990,7 +990,39 @@
         GeneralizedTime generalizedTime = new GeneralizedTime( calendar );
         String result = generalizedTime.toGeneralizedTime();
         assertEquals( "20080102121314Z", result );
+    }
+
+
+    /**
+     * Tests a complete round trip.
+     */
+    public void testRoundTrip() throws ParseException
+    {
+        Calendar calendar = Calendar.getInstance( TimeZone.getTimeZone( "GMT" ) );
+        calendar.setTimeInMillis( 123456789000L ); // default format is without millis
 
+        // create form calendar
+        GeneralizedTime generalizedTime1 = new GeneralizedTime( calendar );
+
+        // get the string value
+        String gt1 = generalizedTime1.toGeneralizedTime();
+        Calendar calendar1 = generalizedTime1.getCalendar();
+
+        // create from string value
+        GeneralizedTime generalizedTime2 = new GeneralizedTime( gt1 );
+
+        // get the calendar value 
+        Calendar calendar2 = generalizedTime2.getCalendar();
+        String gt2 = generalizedTime2.toGeneralizedTime();
+
+        // assert that all are equal
+        assertEquals( calendar, calendar1 );
+        assertEquals( calendar, calendar2 );
+        assertEquals( calendar1, calendar2 );
+        assertEquals( gt1, gt2 );
+        assertTrue( calendar.isLenient() );
+        assertTrue( calendar1.isLenient() );
+        assertTrue( calendar2.isLenient() );
     }
 
 
@@ -1040,4 +1072,5 @@
         assertFalse( generalizedTime1.equals( generalizedTime3 ) );
         assertFalse( generalizedTime1.equals( null ) );
     }
-}
+
+}
\ No newline at end of file



Mime
View raw message