[OJB-developers] TestCase : AutomaticForeignKeys
Brought to you by:
thma
From: Domagoj J. <do...@la...> - 2002-06-03 09:05:46
|
Hi guys I just wanted to write my test case to see how OJB updates One to Many references and I first looked at AutomaticForeignKeys class at testOneManyReference() method. I think that this test case is wrong , at the comparing of the article names it is comparing the same objects : I marked bad lines with " ************** " , and there is a comment how it should be. I made the changes and run the junit tests and then this test failed. Please could someone take a peek at this because I am not yet that familiar with OJB. Cheers .............................................................................. public void testOneManyReference() { try { Article art1 = new Article(); art1.setArticleName("TOPLink"); Article art2 = new Article(); art2.setArticleName("OJB"); Article art3 = new Article(); art3.setArticleName("CASTOR"); ProductGroup pg = new ProductGroup(); pg.setName("O/R mapping tools"); pg.add(art1); pg.add(art2); pg.add(art3); Identity a1OID = new Identity(art1); Identity a2OID = new Identity(art2); Identity a3OID = new Identity(art3); Identity pgOID = new Identity(pg); broker.store(pg); broker.clearCache(); InterfaceProductGroup readInPG = (InterfaceProductGroup) broker.getObjectByIdentity(pgOID); assertEquals(pg.getName(), readInPG.getName()); assertEquals(pg.getAllArticles().size(), readInPG.getAllArticles().size()); // SHOULD BE : InterfaceArticle art1a = (InterfaceArticle) readInPG.getAllArticles().get(0); // readInPG instead pg InterfaceArticle art1a = (InterfaceArticle) pg.getAllArticles().get(0); **************** InterfaceArticle art2a = (InterfaceArticle) pg.getAllArticles().get(1); **************** InterfaceArticle art3a = (InterfaceArticle) pg.getAllArticles().get(2); **************** assertEquals(art1.getArticleName(), art1a.getArticleName()); assertEquals(art2.getArticleName(), art2a.getArticleName()); assertEquals(art3.getArticleName(), art3a.getArticleName()); } catch (Throwable t) { System.out.println(t.getMessage()); t.printStackTrace(); fail(t.getMessage()); } } |