lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r1329934 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java
Date Tue, 24 Apr 2012 18:50:46 GMT
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));
     }
   }
 }



Mime
View raw message