Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3E62F9CAE for ; Tue, 24 Apr 2012 18:51:11 +0000 (UTC) Received: (qmail 17750 invoked by uid 500); 24 Apr 2012 18:51:11 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 17741 invoked by uid 99); 24 Apr 2012 18:51:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Apr 2012 18:51:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Apr 2012 18:51:08 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0D0A423888CD; Tue, 24 Apr 2012 18:50:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@lucene.apache.org From: hossman@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120424185047.0D0A423888CD@eris.apache.org> 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 idsTested = new HashSet(); @@ -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)); } } }