Author: arminw Date: Wed Mar 14 18:02:39 2007 New Revision: 518407 URL: http://svn.apache.org/viewvc?view=rev&rev=518407 Log: extend test to check materialized object instance types
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/PolymorphicExtents.java Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/PolymorphicExtents.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/PolymorphicExtents.java?view=diff&rev=518407&r1=518406&r2=518407 ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/PolymorphicExtents.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/PolymorphicExtents.java Wed Mar 14 18:02:39 2007 @@ -1,6 +1,7 @@ package org.apache.ojb.broker; import java.util.Collection; +import java.util.List; import org.apache.ojb.broker.query.Criteria; import org.apache.ojb.broker.query.Query; @@ -63,26 +64,41 @@ * of type TestThreadsNLocks.org.apache.ojb.broker.Article which forms an extent) * ProductGroup 5 contain items from table Artikel, BOOKS and CDS */ - public void testCollectionRetrieval() + public void testCollectionRetrieval() throws Exception { - try - { - ProductGroup example = new ProductGroup(); - example.setId(new Integer(5)); - - ProductGroup group = - (ProductGroup) broker.getObjectByQuery(QueryFactory.newQuery(example)); - - // 7 Articles, 2 Books, 3 Cds - assertEquals("check size",group.getAllArticles().size(),12); - - } - catch (Throwable t) - { - fail(t.getMessage()); - } + ProductGroup example = new ProductGroup(); + example.setId(new Integer(5)); - } + ProductGroup group = + (ProductGroup) broker.getObjectByQuery(QueryFactory.newQuery(example)); + + // 7 Articles, 2 Books, 3 Cds + assertEquals("check size",group.getAllArticles().size(),12); + List articles = group.getAllArticles(); + int countArticle = 0; + int countBook = 0; + int countCD = 0; + for(int i = 0; i < articles.size(); i++) + { + Object o = articles.get(i); + //System.out.println("Result: " + o); + if(o instanceof Article) + { + countArticle++; + } + if(o instanceof BookArticle) + { + countBook++; + } + if(o instanceof CdArticle) + { + countCD++; + } + } + assertEquals(12, countArticle); + assertEquals(2, countBook); + assertEquals(3, countCD); + } /** TestThreadsNLocks EXTENT lookup: a collection with ALL objects in the Article extent*/ public void testExtentByQuery() throws Exception --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]