mirror of https://github.com/apache/lucene.git
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
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1329934 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9713155458
commit
0501fcc8d9
|
@ -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 LuceneTestCase {
|
|||
|
||||
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 LuceneTestCase {
|
|||
"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 LuceneTestCase {
|
|||
"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 LuceneTestCase {
|
|||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue