On Wed, July 18, 2007 14:04, Matthias Klose wrote:
> Jan-Pascal van Best writes:
>> Hi,
>>
>> I forgot to mention that this bug triggers a unit test failure in Lucene
>> 2.2.0 (Debian package liblucene2-java), meaning the the Lucene package
>> cannot be built using gcj, and so cannot go into Debian main (it is
>> build
>> using the Sun toolchain now).
>
> it would be helpful if you attach the failing testcase to the bug
> report. did you check with both gcj-4.1 and gcj-4.2?
TestDateTools.java contains the failing unit test in the Lucene 2.2.0 source.
Test.java contains a cut-down version of this, not depending on Lucene or
junit, but containing a few extra debug statements.
I'll check with gcj-4.2 later.
Jan-Pascal
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
public class Test
{
public static void main( String[] args ) throws Exception {
Calendar cal = Calendar.getInstance();
System.out.println( "Calendar: " + cal.toString() );
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
cal.set(1970, 0, 1, // year=1970, month=january, day=1
0, 0, 0); // hour, minute, second
cal.set(Calendar.MILLISECOND, 0);
System.out.println( "Calendar: " + cal.toString() );
System.out.println( "cal: " + cal.getTime().getTime() );
}
}
package org.apache.lucene.document;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import junit.framework.TestCase;
public void testStringtoTime() throws ParseException {
long time = DateTools.stringToTime("197001010000");
Calendar cal = Calendar.getInstance();
cal.set(1970, 0, 1, // year=1970, month=january, day=1
0, 0, 0); // hour, minute, second
cal.set(Calendar.MILLISECOND, 0);
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
assertEquals(cal.getTime().getTime(), time);
cal.set(1980, 1, 2, // year=1980, month=february, day=2
11, 5, 0); // hour, minute, second
cal.set(Calendar.MILLISECOND, 0);
time = DateTools.stringToTime("198002021105");
assertEquals(cal.getTime().getTime(), time);
}