You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Craig L Russell <cr...@oracle.com> on 2013/03/29 23:03:33 UTC

Problem with query method getDay

I notice that a TCK test fails (1)

I hadn't noticed before, but the getDay method is not only deprecated  
but also returns the day of the week, not the day of the month. So the  
test case is bogus.

If we really want to give users the ability to get the day of the  
month, the proper method is getDate (2).

WDYT?

Craig

1)  
testGetDay 
(org 
.apache 
.jdo 
.tck 
.query 
.jdoql 
.methods.SupportedDateMethods)junit.framework.AssertionFailedError:  
Assertion A14.6.2-60 (SupportedDateMethods) failed:
Wrong query result:
query: SELECT FROM org.apache.jdo.tck.pc.company.Person WHERE  
birthdate.getDay() == 10
expected: java.util.ArrayList of size 1
[FullTimeEmployee(1, emp1Last, emp1First, born 9/Jun/1970, phone  
{work=123456-1, home=1111}, hired 31/Dec/1998, weeklyhours 40.0,  
$20000.0)]
got:      java.util.ArrayList of size 0
[]
	at org.apache.jdo.tck.JDO_Test.fail(JDO_Test.java:719)
	at org.apache.jdo.tck.query.QueryTest.queryFailed(QueryTest.java:518)
	at  
org 
.apache 
.jdo.tck.query.QueryTest.checkQueryResultWithoutOrder(QueryTest.java: 
548)
	at org.apache.jdo.tck.query.QueryTest.execute(QueryTest.java:1293)
	at org.apache.jdo.tck.query.QueryTest.execute(QueryTest.java:1133)
	at org.apache.jdo.tck.query.QueryTest.executeAPIQuery(QueryTest.java: 
1069)
	at org.apache.jdo.tck.query.QueryTest.executeAPIQuery(QueryTest.java: 
1049)
	at  
org 
.apache 
.jdo 
.tck 
.query 
.jdoql 
.methods.SupportedDateMethods.executeQuery(SupportedDateMethods.java: 
143)
	at  
org 
.apache 
.jdo 
.tck 
.query 
.jdoql 
.methods.SupportedDateMethods.testGetDay(SupportedDateMethods.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at  
sun 
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 
39)
	at  
sun 
.reflect 
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 
25)
	at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:284)
	at org.apache.jdo.tck.util.BatchTestRunner.doRun(BatchTestRunner.java: 
108)
	at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java: 
148)
	at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java: 
123)
FAILURES!!!

2) public int getDate()
Deprecated. As of JDK version 1.1, replaced by  
Calendar.get(Calendar.DAY_OF_MONTH).

Returns the day of the month represented by this Date object. The  
value returned is between 1 and 31 representing the day of the month  
that contains or begins with the instant in time represented by this  
Date object, as interpreted in the local time zone.




Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@oracle.com
P.S. A good JDO? O, Gasp!


Re: Problem with query method getDay

Posted by Michael Bouschen <mi...@akquinet.de>.
Hi Craig,

i think we have two separate issues here.

(1) I do not get the TCK test failure. I noticed that the 
FullTimeEmployee instance has strange date values: the birthday is 
9/Jun/1970 and the hired field is 31/Dec/1998. The expected value is one 
day later for both of the fields: 10/Jun/1970 and 1/Jan/1999. I think 
this is the reason for the test case failure.

I have no idea why it is different at my end. Here is the toString of 
the same employee on my computer:
FullTimeEmployee(1, emp1Last, emp1First, born 10/Jun/1970, phone 
{work=123456-1, home=1111}, hired 1/Jan/1999, weeklyhours 40.0, $20000.0)

Do we have a timezone issue here? The CompanyModelReader uses 
America/New_York as timezone when reading the testdata from teh xml.

(2) I agree JDO should support Date.getDate instead of Date.getDay.
I propose I change the TCK test class SupportedDateMethods to call 
getDate and the spec (chapter 14) unless I hear objections.

Regards Michael

> I notice that a TCK test fails (1)
>
> I hadn't noticed before, but the getDay method is not only deprecated 
> but also returns the day of the week, not the day of the month. So the 
> test case is bogus.
>
> If we really want to give users the ability to get the day of the 
> month, the proper method is getDate (2).
>
> WDYT?
>
> Craig
>
> 1) 
> testGetDay(org.apache.jdo.tck.query.jdoql.methods.SupportedDateMethods)junit.framework.AssertionFailedError: 
> Assertion A14.6.2-60 (SupportedDateMethods) failed:
> Wrong query result:
> query: SELECT FROM org.apache.jdo.tck.pc.company.Person WHERE 
> birthdate.getDay() == 10
> expected: java.util.ArrayList of size 1
> [FullTimeEmployee(1, emp1Last, emp1First, born 9/Jun/1970, phone 
> {work=123456-1, home=1111}, hired 31/Dec/1998, weeklyhours 40.0, 
> $20000.0)]
> got:      java.util.ArrayList of size 0
> []
>     at org.apache.jdo.tck.JDO_Test.fail(JDO_Test.java:719)
>     at org.apache.jdo.tck.query.QueryTest.queryFailed(QueryTest.java:518)
>     at 
> org.apache.jdo.tck.query.QueryTest.checkQueryResultWithoutOrder(QueryTest.java:548)
>     at org.apache.jdo.tck.query.QueryTest.execute(QueryTest.java:1293)
>     at org.apache.jdo.tck.query.QueryTest.execute(QueryTest.java:1133)
>     at 
> org.apache.jdo.tck.query.QueryTest.executeAPIQuery(QueryTest.java:1069)
>     at 
> org.apache.jdo.tck.query.QueryTest.executeAPIQuery(QueryTest.java:1049)
>     at 
> org.apache.jdo.tck.query.jdoql.methods.SupportedDateMethods.executeQuery(SupportedDateMethods.java:143)
>     at 
> org.apache.jdo.tck.query.jdoql.methods.SupportedDateMethods.testGetDay(SupportedDateMethods.java:118)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:284)
>     at 
> org.apache.jdo.tck.util.BatchTestRunner.doRun(BatchTestRunner.java:108)
>     at 
> org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:148)
>     at 
> org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:123)
> FAILURES!!!
>
> 2) public int getDate()
> Deprecated. As of JDK version 1.1, replaced by 
> Calendar.get(Calendar.DAY_OF_MONTH).
>
> Returns the day of the month represented by this Date object. The 
> value returned is between 1 and 31 representing the day of the month 
> that contains or begins with the instant in time represented by this 
> Date object, as interpreted in the local time zone.
>
>
>
>
> Craig L Russell
> Architect, Oracle
> http://db.apache.org/jdo
> 408 276-5638 mailto:Craig.Russell@oracle.com
> P.S. A good JDO? O, Gasp!
>


-- 
*Michael Bouschen*
*Prokurist*

akquinet tech@spree GmbH
Bülowstr. 66, D-10783 Berlin

Fon:   +49 30 235 520-33
Fax:   +49 30 217 520-12
Email: michael.bouschen@akquinet.de
Web: www.akquinet.de <http://www.akquinet.de>

akquinet tech@spree GmbH, Berlin
Geschäftsführung: Martin Weber, Dr. Torsten Fink
Amtsgericht Berlin-Charlottenburg HRB 86780 B
USt.-Id. Nr.: DE 225 964 680