ImranAtBhimsoft / metadata-extractor

Automatically exported from code.google.com/p/metadata-extractor
1 stars 0 forks source link

XMPReader Test fails with unparsable Date #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This error happeeds when compiling and testing metadata-extractor on Mac OS X 
(java version "1.6.0_24"):

Testsuite: com.drew.metadata.xmp.test.XmpReaderTest
Tests run: 14, Failures: 0, Errors: 2, Time elapsed: 0,33 sec

Testcase: testExtract_LensInformation took 0,167 sec
Testcase: testExtract_Lens took 0,014 sec
Testcase: testExtract_SerialNumber took 0,013 sec
Testcase: testExtract_Firmware took 0,012 sec
Testcase: testExtract_Maker took 0,011 sec
Testcase: testExtract_Model took 0,011 sec
Testcase: testExtract_ExposureTime took 0,012 sec
Testcase: testExtract_ExposureProgram took 0,01 sec
Testcase: testExtract_FNumber took 0,01 sec
Testcase: testExtract_FocalLength took 0,009 sec
Testcase: testExtract_ShutterSpeed took 0,009 sec
Testcase: testExtract_OriginalDateTime took 0,011 sec
        Caused an ERROR
Unparseable date: "11:41:35 12 Dec 2010"
java.text.ParseException: Unparseable date: "11:41:35 12 Dec 2010"
        at java.text.DateFormat.parse(DateFormat.java:337)
        at com.drew.metadata.xmp.test.XmpReaderTest.testExtract_OriginalDateTime(Unknown Source)

Testcase: testExtract_DigitizedDateTime took 0,009 sec
        Caused an ERROR
Unparseable date: "11:41:35 12 Dec 2010"
java.text.ParseException: Unparseable date: "11:41:35 12 Dec 2010"
        at java.text.DateFormat.parse(DateFormat.java:337)
        at com.drew.metadata.xmp.test.XmpReaderTest.testExtract_DigitizedDateTime(Unknown Source)

Testcase: testGetXmpProperties took 0,008 sec

Original issue reported on code.google.com by philipp....@gmail.com on 9 May 2011 at 11:26

GoogleCodeExporter commented 9 years ago
Hi Philipp,

I believe this has been fixed in revision 91.  Thankfully it's only an issue 
with the unit test data (if I understand correctly.)

Would you mind verifying that the tests pass correctly for you now?

Thanks,

Drew.

Original comment by drewnoakes on 9 May 2011 at 12:16

GoogleCodeExporter commented 9 years ago
Hi Drew,

nope, unfortunately not fixed. I have attached a path with corrections that 
work for me.

Philipp

Original comment by philipp....@gmail.com on 9 May 2011 at 12:46

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Philipp, 

Unfortunately that patch causes the test to break in my locale.  I was sent 
another patch by Staffan which specified the time to be parsed with a " +0000" 
suffix, which he says works for him, and it works in my locale too (which is 
BST by the way, GMT+1, in London.)

I hope this fix works for you too!

Original comment by drewnoakes on 9 May 2011 at 12:57

GoogleCodeExporter commented 9 years ago
Sorry, this also does not work on my setup:

Testcase: testExtract_OriginalDateTime took 0,011 sec
        Caused an ERROR
Unparseable date: "11:41:35 12 Dec 2010 +0000"
java.text.ParseException: Unparseable date: "11:41:35 12 Dec 2010 +0000"
        at java.text.DateFormat.parse(DateFormat.java:337)
        at com.drew.metadata.xmp.test.XmpReaderTest.testExtract_OriginalDateTime(Unknown Source)

Testcase: testExtract_DigitizedDateTime took 0,008 sec
        Caused an ERROR
Unparseable date: "11:41:35 12 Dec 2010 +0000"
java.text.ParseException: Unparseable date: "11:41:35 12 Dec 2010 +0000"
        at java.text.DateFormat.parse(DateFormat.java:337)
        at com.drew.metadata.xmp.test.XmpReaderTest.testExtract_DigitizedDateTime(Unknown Source)

Original comment by philipp....@gmail.com on 9 May 2011 at 1:03

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
THis does work for me.

Original comment by philipp....@gmail.com on 9 May 2011 at 1:07

Attachments:

GoogleCodeExporter commented 9 years ago
Ok, rather than trying numerous things in SVN, could you let me know which of 
these assertions pass for you?

{{{
    @Test
    public void testExtract_OriginalDateTime() throws Exception
    {
        // Underlying string value (in XMP data) is: 2010-12-12T12:41:35.00+01:00, but we convert it to Date during extraction

        Assert.assertEquals("Sun Dec 12 11:41:35 GMT 2010", _directory.getString(XmpDirectory.TAG_DATETIME_ORIGINAL));

        Assert.assertEquals(new SimpleDateFormat("hh:mm:ss dd MM yyyy Z").parse("11:41:35 12 12 2010 +0000"), _directory.getDate(XmpDirectory.TAG_DATETIME_DIGITIZED));

        Assert.assertEquals(new SimpleDateFormat("HH:mm:ss dd MMM yyyy Z").parse("12:41:35 12 Dec 2010 +0100"), _directory.getDate(XmpDirectory.TAG_DATETIME_ORIGINAL));

        Calendar calendar = new GregorianCalendar(2010, 12-1, 12, 11, 41, 35);
        calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
        Assert.assertEquals(calendar.getTime(), _directory.getDate(XmpDirectory.TAG_DATETIME_ORIGINAL));
}}}}

All four of these pass on my machine.

Original comment by drewnoakes on 9 May 2011 at 1:33

GoogleCodeExporter commented 9 years ago
I realised I was being stupid.  I can change the timezone on my local PC and 
test this myself :\

I'll get something checked in shortly.  Thanks for your patience.

Original comment by drewnoakes on 9 May 2011 at 1:43

GoogleCodeExporter commented 9 years ago
So I tried many different timezones on my PC, and revision 93 seems to work.  I 
didn't change my locale preferences, though I don't know how that could effect 
the outcome of these two tests in particular.  I hope this is the last of it 
for this issue.  If you get a chance to check this again I will mark it as 
verified.

Original comment by drewnoakes on 9 May 2011 at 1:53

GoogleCodeExporter commented 9 years ago
Revision 93 now works for me.

Original comment by philipp....@gmail.com on 9 May 2011 at 1:58

GoogleCodeExporter commented 9 years ago
Phew!  We got there.  Thanks :)

Original comment by drewnoakes on 9 May 2011 at 2:16