lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r922991 - in /lucene/solr/trunk: CHANGES.txt contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java
Date Sun, 14 Mar 2010 22:50:37 GMT
Author: rmuir
Date: Sun Mar 14 22:50:37 2010
New Revision: 922991

URL: http://svn.apache.org/viewvc?rev=922991&view=rev
Log:
SOLR-1821: Fix TimeZone-dependent test failure, triggered by US Daylight Savings Time

Modified:
    lucene/solr/trunk/CHANGES.txt
    lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java

Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=922991&r1=922990&r2=922991&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Sun Mar 14 22:50:37 2010
@@ -261,6 +261,9 @@ Other Changes
 * SOLR-1776: DismaxQParser and ExtendedDismaxQParser now use the schema.xml
   "defaultSearchField" as the default value for the "qf" param instead of failing
   with an error when "qf" is not specified.  (hossman)
+
+* SOLR-1821: Fix TimeZone-dependent test failure in TestEvaluatorBag.
+  (Chris Male via rmuir)
   
 Build
 ----------------------

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java?rev=922991&r1=922990&r2=922991&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestEvaluatorBag.java
Sun Mar 14 22:50:37 2010
@@ -123,15 +123,20 @@ public class TestEvaluatorBag {
     ContextImpl context = new ContextImpl(null, resolver, null, Context.FULL_DUMP, Collections.EMPTY_MAP,
null, null);
     Context.CURRENT_CONTEXT.set(context);
     try {
-      long time = System.currentTimeMillis();
-      assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date(time - 2*86400*1000)),
+      Calendar calendar = new GregorianCalendar();
+      calendar.add(Calendar.DAY_OF_YEAR, -2);
+
+      assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(calendar.getTime()),
               dateFormatEval.evaluate("'NOW-2DAYS','yyyy-MM-dd HH:mm'", Context.CURRENT_CONTEXT.get()));
 
+      calendar = new GregorianCalendar();
+      Date date = calendar.getTime();
+      
       Map<String, Object> map = new HashMap<String, Object>();
-      map.put("key", new Date(time));
+      map.put("key", date);
       resolver.addNamespace("A", map);
 
-      assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date(time)),
+      assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(date),
               dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm'", Context.CURRENT_CONTEXT.get()));
     } finally {
       Context.CURRENT_CONTEXT.remove();



Mime
View raw message