SOLR-1821: Fix TimeZone-dependent test failure, triggered by US Daylight Savings Time

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@922991 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-03-14 22:50:37 +00:00
parent 3c8644bf24
commit f29488d551
2 changed files with 12 additions and 4 deletions

View File

@ -262,6 +262,9 @@ Other Changes
"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
----------------------

View File

@ -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();