You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2013/04/03 13:31:16 UTC

[jira] [Updated] (DERBY-3519) junit regression test failure in testInertTime(org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest)junit.framework.AssertionFailedError: expected:<2> but was:<3>

     [ https://issues.apache.org/jira/browse/DERBY-3519?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-3519:
--------------------------------------

    Attachment: d3519-1a.diff

The problem happens around the day DST starts in the local timezone. The failing test inserts many random TIME values into a table and reads them back out. The failure happens when reading the TIME values using getTimestamp().

When reading a TIME value with getTimestamp(), Derby fills the date component of the timestamp with the values of the current date. DERBY-889 discusses why that's the right thing to do.

So, in the CET/CEST timezone at least, if the TIME value is between 2am and 3am, and getTimestamp() is called during the day DST starts, the hour component of the returned timestamp will be adjusted from 2 to 3, as there is no valid timestamp on that day for the hour between 2am and 3am. Since the test compares the time components of the timestamp and the original time value, and sees that they are different, it thinks the timestamp value was unexpected and fails.

The attached patch makes the test calculate the existing timestamp using the same conversion rules as Derby's JDBC drivers. I've verified that this makes the test pass when I change the time to March 31 (the day DST started in CET). It fails without the patch.

I also took the opportunity to do some other cleanup in TimeHandlingTest:

- removed some unnecessary throws clauses

- simplified some of the calendar manipulation methods
                
> junit regression test failure in testInertTime(org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest)junit.framework.AssertionFailedError: expected:<2> but was:<3>
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3519
>                 URL: https://issues.apache.org/jira/browse/DERBY-3519
>             Project: Derby
>          Issue Type: Bug
>          Components: Test
>    Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.1.1, 10.9.1.0, 10.8.3.0
>            Reporter: Mike Matrigali
>            Priority: Trivial
>              Labels: derby_triage10_8
>         Attachments: d3519-1a.diff
>
>
> see ibm15 trunk testing:
> http://people.apache.org/~myrnavl/derby_test_results/main/windows/testlog/ibm15/635136-suites.All_diff.txt
> There were 2 failures:
> 1) testInertTime(org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest)junit.framework.AssertionFailedError: expected:<2> but was:<3>
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.assertTimeEqual(TimeHandlingTest.java:927)
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.checkTimeValue(TimeHandlingTest.java:647)
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.testInertTime(TimeHandlingTest.java:208)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at <unknown class>.<unknown method>(Unknown Source)
> 	at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:101)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> 2) testInertTime(org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest)junit.framework.AssertionFailedError: expected:<2> but was:<3>
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.assertTimeEqual(TimeHandlingTest.java:927)
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.checkTimeValue(TimeHandlingTest.java:647)
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.testInertTime(TimeHandlingTest.java:208)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at <unknown class>.<unknown method>(Unknown Source)
> 	at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:101)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> FAILURES!!!
> Tests run: 8740,  Failures: 2,  Errors: 6
> Also failed on j2me testing:
> http://people.apache.org/~myrnavl/derby_test_results/main/windows/testlog/weme6.1/635136-suites.All_diff.txt
> There were 2 failures:
> 1) testInertTime(org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest)junit.framework.AssertionFailedError: expected:<2> but was:<3>
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.assertTimeEqual(TimeHandlingTest.java:927)
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.checkTimeValue(TimeHandlingTest.java:647)
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.testInertTime(TimeHandlingTest.java:208)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at <unknown class>.<unknown method>(Unknown Source)
> 	at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:101)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> 2) testInertTime(org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest)junit.framework.AssertionFailedError: expected:<2> but was:<3>
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.assertTimeEqual(TimeHandlingTest.java:927)
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.checkTimeValue(TimeHandlingTest.java:647)
> 	at org.apache.derbyTesting.functionTests.tests.lang.TimeHandlingTest.testInertTime(TimeHandlingTest.java:208)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at <unknown class>.<unknown method>(Unknown Source)
> 	at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:101)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> FAILURES!!!
> Tests run: 8740,  Failures: 2,  Errors: 6

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira