SOLR-940 follow up -- Changing test to index and search for NOW/DAY TO NOW/DAY+5DAYS otherwise the millisecond precision fails the test intermittently

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@752823 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2009-03-12 10:03:15 +00:00
parent e53a1f29c1
commit 6c1bc2ef5f
1 changed files with 6 additions and 5 deletions

View File

@ -17,10 +17,12 @@
package org.apache.solr;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.DateField;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.DateMathParser;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Locale;
/**
* Tests for TrieField functionality
@ -126,15 +128,14 @@ public class TestTrie extends AbstractSolrTestCase {
// Test date math syntax
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
assertU(delQ("*:*"));
long curTime = System.currentTimeMillis();
DateMathParser dmp = new DateMathParser(DateField.UTC, Locale.US);
for (int i = 0; i < 10; i++) {
// index 10 days starting with today
long date = curTime + i * 86400 * 1000;
assertU(adoc("id", String.valueOf(i), "tdate", format.format(new Date(date))));
assertU(adoc("id", String.valueOf(i), "tdate", format.format(i == 0 ? dmp.parseMath("/DAY") : dmp.parseMath("/DAY+" + i + "DAYS"))));
}
assertU(commit());
assertQ("Range filter must match only 10 documents", req("q", "*:*", "fq", "tdate:[* TO *]"), "//*[@numFound='10']");
req = req("q", "*:*", "fq", "tdate:[NOW/DAY TO NOW+5DAYS]");
req = req("q", "*:*", "fq", "tdate:[NOW/DAY TO NOW/DAY+5DAYS]");
assertQ("Range filter must match only 5 documents", req, "//*[@numFound='5']");
// Test Term Queries