lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jd...@apache.org
Subject svn commit: r1411334 - /lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestBuiltInEvaluators.java
Date Mon, 19 Nov 2012 17:58:07 GMT
Author: jdyer
Date: Mon Nov 19 17:58:06 2012
New Revision: 1411334

URL: http://svn.apache.org/viewvc?rev=1411334&view=rev
Log:
SOLR-4086: fix dateformat evaluator unit test

Modified:
    lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestBuiltInEvaluators.java

Modified: lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestBuiltInEvaluators.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestBuiltInEvaluators.java?rev=1411334&r1=1411333&r2=1411334&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestBuiltInEvaluators.java
(original)
+++ lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestBuiltInEvaluators.java
Mon Nov 19 17:58:06 2012
@@ -112,30 +112,38 @@ public class TestBuiltInEvaluators exten
   @Test
   public void testDateFormatEvaluator() {
     Evaluator dateFormatEval = new DateFormatEvaluator();
-    ContextImpl context = new ContextImpl(null, resolver, null, Context.FULL_DUMP, Collections.<String,
Object>emptyMap(), null, null);
-    
-    Calendar calendar = new GregorianCalendar();
-    calendar.add(Calendar.DAY_OF_YEAR, -2);
-    
+    ContextImpl context = new ContextImpl(null, resolver, null,
+        Context.FULL_DUMP, Collections.<String,Object> emptyMap(), null, null);
     String currentLocale = Locale.getDefault().toString();
-
-    assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ROOT).format(calendar.getTime()),
-            dateFormatEval.evaluate("'NOW-2DAYS','yyyy-MM-dd HH:mm'", context));    
-    assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).format(calendar.getTime()),
-        dateFormatEval.evaluate("'NOW-2DAYS','yyyy-MM-dd HH:mm','" + currentLocale + "'",
context));
-    
-    calendar = new GregorianCalendar();
-    Date date = calendar.getTime();
+    {
+      Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"),
+          Locale.ROOT);
+      calendar.add(Calendar.DAY_OF_YEAR, -2);
+      Date d = calendar.getTime();
+      
+      assertEquals(
+          new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ROOT).format(d),
+          dateFormatEval.evaluate("'NOW-2DAYS','yyyy-MM-dd HH:mm'", context));
+      assertEquals(
+          new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault())
+              .format(d),
+          dateFormatEval.evaluate("'NOW-2DAYS','yyyy-MM-dd HH:mm','"
+              + currentLocale + "'", context));
+    }
+    Date d = new Date();
     
-    Map<String, Object> map = new HashMap<String, Object>();
-    map.put("key", date);
+    Map<String,Object> map = new HashMap<String,Object>();
+    map.put("key", d);
     resolver.addNamespace("A", map);
-
-    assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ROOT).format(date),
-            dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm'", context));
-    assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).format(date),
-       dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm','" + currentLocale + "'", context));
-   
+    
+    assertEquals(
+        new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ROOT).format(d),
+        dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm'", context));
+    assertEquals(
+        new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).format(d),
+        dateFormatEval.evaluate("A.key, 'yyyy-MM-dd HH:mm','" + currentLocale
+            + "'", context));
+    
   }
 
   private void runTests(Map<String, String> tests, Evaluator evaluator) {



Mime
View raw message