* Tests reading an association, with primitive and association attributes
* specified to avoid lazy loads.
*/
public void testReadManyToOneHeterogeneousAssocWithNonLazyCollectionsOnAssociatedInstances()
{
Metaclass animalClass = m_metadata.getMetaclass("Animal");
Instance inst, assocInst;
InstanceList list;
int nStartCallCount, nEndCallCount;
list = Query.createRead(animalClass, parse("(commonName limbCount (pen name animals))"),
null, null, -1, 0, false, Query.SEC_NODE, m_context).read();
assertEquals(4, list.size());
inst = list.getInstance(0);
assertEquals("Dog", inst.getValue("commonName"));
assocInst = (Instance)inst.getValue("pen");
assertNotNull(assocInst);
assertEquals("Dog pen", assocInst.getValue("name"));
nStartCallCount = ((Integer)animalClass.getValue("penAttrReadCount")).intValue();
assertEquals(2, ((InstanceList)assocInst.getValue("animals")).size());
nEndCallCount = ((Integer)animalClass.getValue("penAttrReadCount")).intValue();
assertEquals(nStartCallCount, nEndCallCount); // Loaded during read
assertSame(inst, ((InstanceList)assocInst.getValue("animals")).getInstance(0));
inst = list.getInstance(1);
assertEquals("Cat", inst.getValue("commonName"));
assocInst = (Instance)inst.getValue("pen");
assertNotNull(assocInst);
assertEquals("Cat pen", assocInst.getValue("name"));
nStartCallCount = ((Integer)animalClass.getValue("penAttrReadCount")).intValue();
assertEquals(1, ((InstanceList)assocInst.getValue("animals")).size());
nEndCallCount = ((Integer)animalClass.getValue("penAttrReadCount")).intValue();
assertEquals(nStartCallCount, nEndCallCount); // Loaded during read
assertSame(inst, ((InstanceList)assocInst.getValue("animals")).getInstance(0));
inst = list.getInstance(2);
assertEquals("Spider", inst.getValue("commonName"));
assocInst = (Instance)inst.getValue("pen");
assertNotNull(assocInst);
assertEquals("Dog pen", assocInst.getValue("name"));
nStartCallCount = ((Integer)animalClass.getValue("penAttrReadCount")).intValue();
assertEquals(2, ((InstanceList)assocInst.getValue("animals")).size());
nEndCallCount = ((Integer)animalClass.getValue("penAttrReadCount")).intValue();
assertEquals(nStartCallCount, nEndCallCount); // Loaded during read
assertSame(inst, ((InstanceList)assocInst.getValue("animals")).getInstance(1));
}