You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2012/04/24 20:50:46 UTC

svn commit: r1329934 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java

Author: hossman
Date: Tue Apr 24 18:50:46 2012
New Revision: 1329934

URL: http://svn.apache.org/viewvc?rev=1329934&view=rev
Log:
SOLR-2690: to hell with JVMs that don't consistently normalize the ID in the TimeZone's returned by TimeZone.getTimeZone ... we don't give a shit, all that matters is that the rules are hte same anyway

Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java?rev=1329934&r1=1329933&r2=1329934&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java Tue Apr 24 18:50:46 2012
@@ -28,6 +28,22 @@ import java.util.Locale;
 
 public class TimeZoneUtilsTest extends LuceneTestCase {
 
+  private static void assertSameRules(final String label,
+                                      final TimeZone expected,
+                                      final TimeZone actual) {
+    
+    if (null == expected && null == actual) return;
+
+    assertNotNull(label + ": expected is null", expected);
+    assertNotNull(label + ": actual is null", actual);
+
+    final boolean same = expected.hasSameRules(actual);
+
+    assertTrue(label + ": " + expected.toString() + " [[NOT SAME RULES]] " + 
+               actual.toString(),
+               same);
+  }
+
   public void testValidIds() throws Exception {
 
     final Set<String> idsTested = new HashSet<String>();
@@ -39,7 +55,7 @@ public class TimeZoneUtilsTest extends L
 
       final TimeZone expected = TimeZone.getTimeZone(validId);
       final TimeZone actual = TimeZoneUtils.getTimeZone(validId);
-      assertEquals(validId, expected, actual);
+      assertSameRules(validId, expected, actual);
 
       idsTested.add(validId);
     }
@@ -56,9 +72,9 @@ public class TimeZoneUtilsTest extends L
                                       "GMT-0800","GMT-08:00",
                                       "GMT+23", "GMT+2300",
                                       "GMT-23", "GMT-2300"}) {
-      assertEquals(input, 
-                   TimeZone.getTimeZone(input),
-                   TimeZoneUtils.getTimeZone(input));
+      assertSameRules(input, 
+                      TimeZone.getTimeZone(input),
+                      TimeZoneUtils.getTimeZone(input));
     }
   }
 
@@ -70,9 +86,9 @@ public class TimeZoneUtilsTest extends L
                                       "GMT-0800","GMT-08:00",
                                       "GMT+23", "GMT+2300",
                                       "GMT-23", "GMT-2300"}) {
-      assertEquals(input, 
-                   TimeZone.getTimeZone(input),
-                   TimeZone.getTimeZone(input));
+      assertSameRules(input, 
+                      TimeZone.getTimeZone(input),
+                      TimeZone.getTimeZone(input));
     }
   }
 
@@ -110,9 +126,9 @@ public class TimeZoneUtilsTest extends L
       String mins = String.format(Locale.US, TWO_DIGIT, min);
       String input = "GMT" + (r.nextBoolean()?"+":"-") 
         + hours + (r.nextBoolean() ? "" : ((r.nextBoolean()?":":"") + mins));
-      assertEquals(input,  
-                   TimeZone.getTimeZone(input),
-                   TimeZoneUtils.getTimeZone(input));
+      assertSameRules(input,  
+                      TimeZone.getTimeZone(input),
+                      TimeZoneUtils.getTimeZone(input));
     }
   }
 }