mirror of https://github.com/apache/lucene.git
Add a testcase for DateUtil to debug the recent Java 9 failures (may be extended)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1690031 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ac8c26c8e0
commit
67d310288a
|
@ -0,0 +1,41 @@
|
|||
package org.apache.solr.common.util;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
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 testParseDate() throws ParseException {
|
||||
assertParsedDate(1226583351000L, "Thu Nov 13 04:35:51 AKST 2008", 0L);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue