Hi,

Nice analysis, Andy. I agree that the test should be changed as you suggest.

Thanks,

Craig

On Oct 22, 2005, at 3:01 AM, Andy Jefferson (JIRA) wrote:

     [ http://issues.apache.org/jira/browse/JDO-144?page=all ]

Andy Jefferson reassigned JDO-144:
----------------------------------

    Assign To: Michelle Caisse  (was: Andy Jefferson)

Thanks Michelle.
Well I'll explain what the problem is, and some options.

The test creates an object with many collections and instantiates them as Vectors (as you know). It tries to persist it, and JPOX converts all Collection fields to the equivalent wrapper type for the _instantiated_ type of the field. This is fine. The test then goes back to the datastore and retrieves the persisted object. JPOX has to look at what is in the datastore for each Collection field and create a suitable Collection. At this point it has no idea that the user wants a Vector creating since the instantiated type is not stored in the datastore anywhere. Consequently it knows it has to create a Collection type, and that the user has provided an <order>, so it create an ArrayList (since that is the JPOX-defined default for Lists).

How is JPOX to know that it should instantiate the fields as Vector when it is simply retrieving an object from the datastore and the declared type of the field is Collection ? JPOX calls the default constructor of CollectionCollections and then has to instantiate each field somehow. So it takes a guess. If anyone thinks it should do better, then please please define how.

What I would do to the test is change your "Vector.elementAt(i)" calls to be "List.get(i)" (since List.get(i) is more generic and does the same thing as Vector.elementAt(i)), and cast the Collection field to a List instead of a Vector. This will work because JPOX (CVS) has given it a List wrapper.

Hope that makes sense.


Incorrect value for public Collection CollectionOfDate12
--------------------------------------------------------

         Key: JDO-144
         URL: http://issues.apache.org/jira/browse/JDO-144
     Project: JDO
        Type: Bug
  Components: tck20
    Reporter: Michelle Caisse
    Assignee: Michelle Caisse




[java] 1) test (org.apache.jdo.tck.models.fieldtypes.TestCollectionCollections) junit.framework.AssertionFailedError: Assertion A6.4.3-33 (TestCollectionCollections) failed:
[java] Incorrect value for public Collection CollectionOfDate12
[java]      at org.apache.jdo.tck.JDO_Test.fail(JDO_Test.java:546)
[java] at org.apache.jdo.tck.models.fieldtypes.TestCollectionCollections.checkV alues(TestCollectionCollections.java:146) [java] at org.apache.jdo.tck.models.fieldtypes.TestCollectionCollections.runTes t(TestCollectionCollections.java:104) [java] at org.apache.jdo.tck.models.fieldtypes.TestCollectionCollections.test (TestCollectionCollections.java:69) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
[java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:204)
[java] at org.apache.jdo.tck.util.BatchTestRunner.start (BatchTestRunner.java:115) [java] at org.apache.jdo.tck.util.BatchTestRunner.main (BatchTestRunner.java:93)


--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



Reply via email to