lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1690046 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/solrj/ solr/solrj/src/test/org/apache/solr/common/util/TestDateUtil.java
Date Thu, 09 Jul 2015 10:03:18 GMT
Author: uschindler
Date: Thu Jul  9 10:03:18 2015
New Revision: 1690046

URL: http://svn.apache.org/r1690046
Log:
Merged revision(s) 1690044 from lucene/dev/trunk:
Fix broken test - sorry!

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/common/util/TestDateUtil.java

Modified: lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/common/util/TestDateUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/common/util/TestDateUtil.java?rev=1690046&r1=1690045&r2=1690046&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/common/util/TestDateUtil.java
(original)
+++ lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/common/util/TestDateUtil.java
Thu Jul  9 10:03:18 2015
@@ -19,23 +19,24 @@ package org.apache.solr.common.util;
 
 import java.text.ParseException;
 import java.util.Date;
+import java.util.Locale;
 
 import org.apache.lucene.util.LuceneTestCase;
 
 public class TestDateUtil extends LuceneTestCase {
 
-  public void testCurrentTime() throws ParseException {
-    long now = System.currentTimeMillis();
-    assertParsedDate(now, new Date(now).toString(), 1000L);
+  public void testDateToString() throws ParseException {
+    long ts = 1226583351000L;
+    assertParsedDate(ts, new Date(ts).toString());
   }
   
   public void testParseDate() throws ParseException {
-    assertParsedDate(1226583351000L, "Thu Nov 13 04:35:51 AKST 2008", 0L);
+    assertParsedDate(1226583351000L, "Thu Nov 13 04:35:51 AKST 2008");
   }
     
-  private static void assertParsedDate(long ts, String dateStr, long epsilon) throws ParseException
{
-    System.out.println(DateUtil.parseDate(dateStr).getTime());
-    assertTrue("Incorrect parsed timestamp", Math.abs(ts - DateUtil.parseDate(dateStr).getTime())
<= epsilon);
+  private static void assertParsedDate(long ts, String dateStr) throws ParseException {
+    long parsed = DateUtil.parseDate(dateStr).getTime();
+    assertTrue(String.format(Locale.ENGLISH, "Incorrect parsed timestamp: %d != %d (%s)",
ts, parsed, dateStr), Math.abs(ts - parsed) <= 1000L);
   }
 
 }



Mime
View raw message