* Same as testReadCollection, except that the attributes list has "commonName" in
* it, e.g. (name (animals commonName)), so no lazy loads should be executed.
*/
public void testReadHeterogeneousCollectionWithNonLazyPrimitives()
{
Metaclass penClass = m_metadata.getMetaclass("AnimalPen");
Metaclass animalClass = m_metadata.getMetaclass("Animal");
Instance inst, assocInst;
InstanceArrayList list, collection;
int nStartCallCount, nEndCallCount;
list = (InstanceArrayList)penClass.invoke("read", new Object[]{
parse("(name (animals commonName (@@ DomesticAnimal petName)))"), null, null, null, null, null
});
assertEquals(2, list.size());
inst = list.getInstance(0);
assertEquals("Dog pen", inst.getValue("name"));
collection = (InstanceArrayList)inst.getValue("animals");
assertEquals(2, collection.size());
assocInst = collection.getInstance(0);
nStartCallCount = ((Integer)animalClass.getValue("objectKeyReadCount")).intValue();
assertEquals("Dog", assocInst.getValue("commonName")); // Loaded during read
assertEquals("Kerberos", assocInst.getValue("petName"));
nEndCallCount = ((Integer)animalClass.getValue("objectKeyReadCount")).intValue();
assertEquals(nStartCallCount, nEndCallCount);
assertSame(inst, assocInst.getValue("pen"));
assocInst = collection.getInstance(1);
assertEquals("Spider", assocInst.getValue("commonName"));
assertFalse(assocInst.hasValue("petName"));