Index: topiatest/src/test/org/codelutin/test2/AppTest.java diff -u topiatest/src/test/org/codelutin/test2/AppTest.java:1.9 topiatest/src/test/org/codelutin/test2/AppTest.java:1.10 --- topiatest/src/test/org/codelutin/test2/AppTest.java:1.9 Fri Aug 19 16:14:39 2005 +++ topiatest/src/test/org/codelutin/test2/AppTest.java Tue Aug 30 13:21:54 2005 @@ -18,6 +18,7 @@ import org.codelutin.topia.persistence.PersistenceStorageJDBC; import org.codelutin.topia.persistence.TopiaPersistenceObject; import org.codelutin.topia.persistence.TopiaTransaction; +import org.codelutin.util.CallAnalyse; public class AppTest extends TestCase { @@ -27,134 +28,150 @@ protected TopiaTransaction trans = null; public void setUp() throws Exception { + CallAnalyse.activate(); + CallAnalyse.getThreadStatistics().clear(); topiaContext = test2Context.getContext(); child = topiaContext.beginTransaction(); companyPS = child.getCompanyPersistenceService(); } + public void tearDown() throws Exception { + System.out.println(CallAnalyse.getThreadStatistics()); + CallAnalyse.getThreadStatistics().clear(); + } + public void testEventListener() throws Exception { - // TODO + try{ + CallAnalyse.enter(AppTest.class.getName() + ".testEventListener"); + // TODO + } finally { + CallAnalyse.exit(AppTest.class.getName() + ".testEventListener"); + } } public void testSousTransaction() throws Exception { - test2Context child1; - test2Context child2; - CompanyPersistenceService companyPS1; - CompanyPersistenceService companyPS2; - - // 1. On créé une transaction et une sous-transaction, - child1 = topiaContext.beginTransaction(); - companyPS1 = child1.getCompanyPersistenceService(); - child2 = child1.beginTransaction(); - companyPS2 = child2.getCompanyPersistenceService(); - // - on ajoute un elem dans la 1ere, il existe dans la 2eme, - Company comp = companyPS1.create(); - comp.setName("thim"); - String id = comp.get_topiaId_(); - companyPS1.update(comp); - comp = companyPS1.findBy_TopiaId_(id); - assertNotSame(null, comp); - assertEquals("thim", comp.getName()); - comp = companyPS2.findBy_TopiaId_(id); - assertNotSame(null, comp); - assertEquals("thim", comp.getName()); - // - puis on rollback la 1ere, il n'existe plus dans la 2eme - child1.rollbackTransaction(); - assertEquals(child1.getTransaction().getId(), child2.getTransaction().getParent().getId()); - boolean catched = false; - try { - companyPS1.findBy_TopiaId_(id); - }catch(TopiaException eee){ //Doit renvoyer une exception pour dire le l'objet n'a pas été trouvé - System.err.println(eee.getMessage()); - catched = true; - } - assertTrue(catched); - catched = false; - try { - companyPS2.findBy_TopiaId_(id); - }catch(TopiaException eee){ //idem - System.err.println(eee.getMessage()); - catched = true; - } - assertTrue(catched); - - - - // 2. Meme schéma - child1 = topiaContext.beginTransaction(); - companyPS1 = child1.getCompanyPersistenceService(); - child2 = child1.beginTransaction(); - companyPS2 = child2.getCompanyPersistenceService(); - - // - on ajoute un elem dans la 1ere, on le modifie dans la 2eme, on recup la valeur pour les deux, la valeur est modifiée slt pr la deuxieme - comp = companyPS1.create(); - id = comp.get_topiaId_(); - comp.setName("thim"); - companyPS1.update(comp); - comp = companyPS2.findBy_TopiaId_(id); - comp.setName("thimel"); - companyPS2.update(comp); - - comp = companyPS1.findBy_TopiaId_(id); - assertEquals("thim", comp.getName()); - comp = companyPS2.findBy_TopiaId_(id); - assertEquals("thimel", comp.getName()); - - // - on rollback la 2eme, la premiere doit reprendre la valeur avant le debut de la 2eme - child2.rollbackTransaction(); - comp = companyPS1.findBy_TopiaId_(id); - assertEquals("thim", comp.getName()); - comp = companyPS2.findBy_TopiaId_(id); - assertEquals("thim", comp.getName()); - - comp = companyPS2.findBy_TopiaId_(id); - comp.setName("thimel"); - companyPS2.update(comp); + try{ + CallAnalyse.enter(AppTest.class.getName() + ".testSousTransaction"); + test2Context child1; + test2Context child2; + CompanyPersistenceService companyPS1; + CompanyPersistenceService companyPS2; + + // 1. On créé une transaction et une sous-transaction, + child1 = topiaContext.beginTransaction(); + companyPS1 = child1.getCompanyPersistenceService(); + child2 = child1.beginTransaction(); + companyPS2 = child2.getCompanyPersistenceService(); + // - on ajoute un elem dans la 1ere, il existe dans la 2eme, + Company comp = companyPS1.create(); + comp.setName("thim"); + String id = comp.get_topiaId_(); + companyPS1.update(comp); + comp = companyPS1.findBy_TopiaId_(id); + assertNotSame(null, comp); + assertEquals("thim", comp.getName()); + comp = companyPS2.findBy_TopiaId_(id); + assertNotSame(null, comp); + assertEquals("thim", comp.getName()); + // - puis on rollback la 1ere, il n'existe plus dans la 2eme + child1.rollbackTransaction(); + assertEquals(child1.getTransaction().getId(), child2.getTransaction().getParent().getId()); + boolean catched = false; + try { + companyPS1.findBy_TopiaId_(id); + }catch(TopiaException eee){ //Doit renvoyer une exception pour dire le l'objet n'a pas été trouvé + System.err.println(eee.getMessage()); + catched = true; + } + assertTrue(catched); + catched = false; + try { + companyPS2.findBy_TopiaId_(id); + }catch(TopiaException eee){ //idem + System.err.println(eee.getMessage()); + catched = true; + } + assertTrue(catched); + + + + // 2. Meme schéma + child1 = topiaContext.beginTransaction(); + companyPS1 = child1.getCompanyPersistenceService(); + child2 = child1.beginTransaction(); + companyPS2 = child2.getCompanyPersistenceService(); + + // - on ajoute un elem dans la 1ere, on le modifie dans la 2eme, on recup la valeur pour les deux, la valeur est modifiée slt pr la deuxieme + comp = companyPS1.create(); + id = comp.get_topiaId_(); + comp.setName("thim"); + companyPS1.update(comp); + comp = companyPS2.findBy_TopiaId_(id); + comp.setName("thimel"); + companyPS2.update(comp); + + comp = companyPS1.findBy_TopiaId_(id); + assertEquals("thim", comp.getName()); + comp = companyPS2.findBy_TopiaId_(id); + assertEquals("thimel", comp.getName()); + + // - on rollback la 2eme, la premiere doit reprendre la valeur avant le debut de la 2eme + child2.rollbackTransaction(); + comp = companyPS1.findBy_TopiaId_(id); + assertEquals("thim", comp.getName()); + comp = companyPS2.findBy_TopiaId_(id); + assertEquals("thim", comp.getName()); + + comp = companyPS2.findBy_TopiaId_(id); + comp.setName("thimel"); + companyPS2.update(comp); + + catched = false; + try { + child2.commitTransaction(); + }catch(TopiaException eee){ //l'objet est en cours de "modif" dans la transaction parente + System.err.println(eee.getMessage()); + catched = true; + } + assertTrue(catched); + + child1.commitTransaction(); + + comp = companyPS1.findBy_TopiaId_(id); + assertEquals("thim", comp.getName()); + // comp = companyPS2.findBy_TopiaId_(id); //FIXME Le child2 ne peut pas voir les elemes commité par son parent !!! + // assertEquals("thim", comp.getName()); + + + // 3. Même schéma + child1 = topiaContext.beginTransaction(); + companyPS1 = child1.getCompanyPersistenceService(); + child2 = child1.beginTransaction(); + companyPS2 = child2.getCompanyPersistenceService(); + + comp = companyPS2.create(); + id = comp.get_topiaId_(); + + comp.setName("Thimel"); + companyPS2.update(comp); + try { + companyPS1.findBy_TopiaId_(id); + }catch(TopiaException eee){ //Doit renvoyer une exception pour dire le l'objet n'a pas été trouvé + System.err.println(eee.getMessage()); + catched = true; + } + comp = companyPS2.findBy_TopiaId_(id); + assertEquals("Thimel", comp.getName()); - catched = false; - try { child2.commitTransaction(); - }catch(TopiaException eee){ //l'objet est en cours de "modif" dans la transaction parente - System.err.println(eee.getMessage()); - catched = true; - } - assertTrue(catched); - child1.commitTransaction(); - - comp = companyPS1.findBy_TopiaId_(id); - assertEquals("thim", comp.getName()); -// comp = companyPS2.findBy_TopiaId_(id); //FIXME Le child2 ne peut pas voir les elemes commité par son parent !!! -// assertEquals("thim", comp.getName()); - - - // 3. Même schéma - child1 = topiaContext.beginTransaction(); - companyPS1 = child1.getCompanyPersistenceService(); - child2 = child1.beginTransaction(); - companyPS2 = child2.getCompanyPersistenceService(); - - comp = companyPS2.create(); - id = comp.get_topiaId_(); - - comp.setName("Thimel"); - companyPS2.update(comp); - try { - companyPS1.findBy_TopiaId_(id); - }catch(TopiaException eee){ //Doit renvoyer une exception pour dire le l'objet n'a pas été trouvé - System.err.println(eee.getMessage()); - catched = true; + comp = companyPS1.findBy_TopiaId_(id); + assertEquals("Thimel", comp.getName()); + comp = companyPS2.findBy_TopiaId_(id); + assertEquals("Thimel", comp.getName()); + } finally { + CallAnalyse.exit(AppTest.class.getName() + ".testSousTransaction"); } - comp = companyPS2.findBy_TopiaId_(id); - assertEquals("Thimel", comp.getName()); - - child2.commitTransaction(); - - comp = companyPS1.findBy_TopiaId_(id); - assertEquals("Thimel", comp.getName()); - comp = companyPS2.findBy_TopiaId_(id); - assertEquals("Thimel", comp.getName()); - } @@ -162,247 +179,261 @@ * Rigourous Test :-) */ public void testApp() throws Exception { - Company company; - List companies; + try{ + CallAnalyse.enter(AppTest.class.getName() + ".testApp"); + Company company; + List companies; + + System.out.println("-------- suppression --------"); + companies = companyPS.findAll(); + System.out.println("companies: " + companies); + for(Company c : companies){ + companyPS.delete(c); + } + + assertEquals(0, companyPS.findAll().size()); + + System.out.println("-------- creation --------"); + for(int i=0; i<10; i++){ + company = companyPS.create(); + company.setName("Company" + i); + company.setEntier(i); + company.setReel((float)(i+i/100.0)); + company.setBool(i % 2 == 0); + company = companyPS.update(company); + } + + System.out.println("-------- size --------"); + int count = companyPS.size(); + System.out.println("size: " + count); - System.out.println("-------- suppression --------"); - companies = companyPS.findAll(); - System.out.println("companies: " + companies); - for(Company c : companies){ - companyPS.delete(c); - } + assertEquals(10, count); - assertEquals(0, companyPS.findAll().size()); - - System.out.println("-------- creation --------"); - for(int i=0; i<10; i++){ + System.out.println("-------- makePersistent --------"); company = companyPS.create(); - company.setName("Company" + i); - company.setEntier(i); - company.setReel((float)(i+i/100.0)); - company.setBool(i % 2 == 0); + System.out.println("company: " + company); + System.out.println("company: " + test2EntitiesHelper.toString(company)); + System.out.println("company.getClass()" + company.getClass().getName()); + company.setName("Company" + count); + company.setEntier(count); + company.setReel((float)(count+count/100.0)); + company.setBool(count % 2 == 0); + System.out.println("company: " + company); company = companyPS.update(company); + System.out.println(company.getName()); + System.out.println("company: " + company); + assertEquals(count + 1, companyPS.size()); + + System.out.println("-------- findAll --------"); + companies = companyPS.findAll(); + System.out.println("companies: " + companies); + assertEquals(count + 1, companies.size()); + + System.out.println("-------- find name=? --------"); + companies = companyPS.find(companyPS.newQuery().where("name = ?").addArg("Company" + count)); + System.out.println("companies: " + companies); + assertEquals(1, companies.size()); + Company comp = (Company)companies.iterator().next(); + System.out.println("comp:"+comp+" company:"+company); + assertEquals(comp, company); + + System.out.println("-------- Update --------"); + comp.setReel((float) 0.07); + comp = (Company) companyPS.update(comp); + + System.out.println("-------- find name like 'Compa%' --------"); + companies = companyPS.find(companyPS.newQuery().where("name like \"Compa%\"")); + System.out.println("size:" + companies.size() + " count:" + count); + assertEquals(count + 1, companies.size()); + + System.out.println("-------- find name like '%'"+count+" --------"); + companies = companyPS.find(companyPS.newQuery().where("name like \"%"+count+"\"")); + assertEquals(1, companies.size()); + + System.out.println("-------- find name not like 'Compa%' --------"); + companies = companyPS.find(companyPS.newQuery().where("name not like \"Compa%\"")); + System.out.println("size:" + companies.size() + " count:" + count); + assertEquals(0, companies.size()); + + System.out.println("-------- find name not like '%'"+count+" --------"); + companies = companyPS.find(companyPS.newQuery().where("name not like \"%"+count+"\"")); + assertEquals(count, companies.size()); + + System.out.println("-------- find entier = "+count+" --------"); + companies = companyPS.find(companyPS.newQuery().where("entier = " + count)); + assertEquals(1, companies.size()); + + System.out.println("-------- find entier = ? ("+count+") --------"); + companies = companyPS.find(companyPS.newQuery().where("entier = ?").addArg(count)); + assertEquals(1, companies.size()); + + System.out.println("-------- find entier > "+count+" --------"); + companies = companyPS.find(companyPS.newQuery().where("entier > ?").addArg(count)); + assertEquals(0, companies.size()); + + System.out.println("-------- find entier < "+count+" --------"); + companies = companyPS.find(companyPS.newQuery().where("entier < ?").addArg(count)); + assertEquals(count, companies.size()); + + System.out.println("-------- find entier >= "+count+" --------"); + companies = companyPS.find(companyPS.newQuery().where("entier >= ?").addArg(count)); + assertEquals(1, companies.size()); + + System.out.println("-------- find entier <= "+count+" --------"); + companies = companyPS.find(companyPS.newQuery().where("entier <= ?").addArg(count)); + assertEquals(count + 1, companies.size()); + + System.out.println("-------- find entier != "+count+" --------"); + companies = companyPS.find(companyPS.newQuery().where("entier != ?").addArg(count)); + assertEquals(count, companies.size()); + + System.out.println("-------- find entier < 3 --------"); + companies = companyPS.find(companyPS.newQuery().where("entier < 3")); + System.out.println("size:" + companies.size() + " count:" + count); + assertEquals(Math.min(3,count+1), companies.size()); + + System.out.println("-------- find and1 --------"); + companies = companyPS.find(companyPS.newQuery().where("bool = true and entier <= 0 ")); + assertEquals(1, companies.size()); + + System.out.println("-------- find and2 --------"); + companies = companyPS.find(companyPS.newQuery().where("bool = true and entier <= ? ").addArg(count)); + assertEquals(count/2+1, companies.size()); + + System.out.println("-------- find not and3 --------"); + companies = companyPS.find(companyPS.newQuery().where("not bool = true and entier <= ? ").addArg(count)); + assertEquals((count+1)/2, companies.size()); + + System.out.println("-------- find and4 --------"); + companies = companyPS.find(companyPS.newQuery().where("name like ? and entier = ? ").addArg("Compa%").addArg(0)); + assertEquals(1, companies.size()); + + System.out.println("-------- find and5 --------"); + companies = companyPS.find(companyPS.newQuery().where("name like ? and entier != ? ").addArg("Compa%").addArg(count)); + assertEquals(count, companies.size()); + + System.out.println("-------- find not and6 --------"); + companies = companyPS.find(companyPS.newQuery().where("name like ? and not entier != ? ").addArg("Compa%").addArg(count)); + assertEquals(1, companies.size()); + + System.out.println("-------- find not and7 --------"); + companies = companyPS.find(companyPS.newQuery().where("not (name like ? and entier != ?)").addArg("Compa%").addArg(count)); + assertEquals(1, companies.size()); + + System.out.println("-------- find or --------"); + companies = companyPS.find(companyPS.newQuery().where("bool = true or bool = false")); + assertEquals(count + 1, companies.size()); + + System.out.println("-------- find not (or) --------"); + companies = companyPS.find(companyPS.newQuery().where("not (bool = true or bool = false)")); + assertEquals(0, companies.size()); + + // System.out.println("-------- find in --------"); + // companies = companyPS.find(companyPS.newQuery().where("entier in (1,2,3)")); + // assertEquals(3, companies.size()); + // + // System.out.println("-------- find not in --------"); + // companies = companyPS.find(companyPS.newQuery().where("entier not in (1,2,3)")); + // assertEquals(count + 1 - 3, companies.size()); + // + // System.out.println("-------- find in coll --------"); + // HashSet list = new HashSet(); + // list.add("Company1"); + // list.add("Company2"); + // list.add("Company3"); + // companies = companyPS.find(companyPS.newQuery().where("name in ?").addArg(list)); + // assertEquals(3, companies.size()); + + + System.out.println("-------- suppression --------"); + companies = companyPS.findAll(); + for(Company c : companies){ + companyPS.delete(c); + } + + assertEquals(companyPS.size(), 0); + + child.commitTransaction(); + } finally { + CallAnalyse.exit(AppTest.class.getName() + ".testApp"); } - - System.out.println("-------- size --------"); - int count = companyPS.size(); - System.out.println("size: " + count); - - assertEquals(10, count); - - System.out.println("-------- makePersistent --------"); - company = companyPS.create(); - System.out.println("company: " + company); - System.out.println("company: " + test2EntitiesHelper.toString(company)); - System.out.println("company.getClass()" + company.getClass().getName()); - company.setName("Company" + count); - company.setEntier(count); - company.setReel((float)(count+count/100.0)); - company.setBool(count % 2 == 0); - System.out.println("company: " + company); - company = companyPS.update(company); -System.out.println(company.getName()); - System.out.println("company: " + company); - assertEquals(count + 1, companyPS.size()); - - System.out.println("-------- findAll --------"); - companies = companyPS.findAll(); - System.out.println("companies: " + companies); - assertEquals(count + 1, companies.size()); - - System.out.println("-------- find name=? --------"); - companies = companyPS.find(companyPS.newQuery().where("name = ?").addArg("Company" + count)); - System.out.println("companies: " + companies); - assertEquals(1, companies.size()); - Company comp = (Company)companies.iterator().next(); - System.out.println("comp:"+comp+" company:"+company); - assertEquals(comp, company); - - System.out.println("-------- Update --------"); - comp.setReel((float) 0.07); - comp = (Company) companyPS.update(comp); - - System.out.println("-------- find name like 'Compa%' --------"); - companies = companyPS.find(companyPS.newQuery().where("name like \"Compa%\"")); - System.out.println("size:" + companies.size() + " count:" + count); - assertEquals(count + 1, companies.size()); - - System.out.println("-------- find name like '%'"+count+" --------"); - companies = companyPS.find(companyPS.newQuery().where("name like \"%"+count+"\"")); - assertEquals(1, companies.size()); - - System.out.println("-------- find name not like 'Compa%' --------"); - companies = companyPS.find(companyPS.newQuery().where("name not like \"Compa%\"")); - System.out.println("size:" + companies.size() + " count:" + count); - assertEquals(0, companies.size()); - - System.out.println("-------- find name not like '%'"+count+" --------"); - companies = companyPS.find(companyPS.newQuery().where("name not like \"%"+count+"\"")); - assertEquals(count, companies.size()); - - System.out.println("-------- find entier = "+count+" --------"); - companies = companyPS.find(companyPS.newQuery().where("entier = " + count)); - assertEquals(1, companies.size()); - - System.out.println("-------- find entier = ? ("+count+") --------"); - companies = companyPS.find(companyPS.newQuery().where("entier = ?").addArg(count)); - assertEquals(1, companies.size()); - - System.out.println("-------- find entier > "+count+" --------"); - companies = companyPS.find(companyPS.newQuery().where("entier > ?").addArg(count)); - assertEquals(0, companies.size()); - - System.out.println("-------- find entier < "+count+" --------"); - companies = companyPS.find(companyPS.newQuery().where("entier < ?").addArg(count)); - assertEquals(count, companies.size()); - - System.out.println("-------- find entier >= "+count+" --------"); - companies = companyPS.find(companyPS.newQuery().where("entier >= ?").addArg(count)); - assertEquals(1, companies.size()); - - System.out.println("-------- find entier <= "+count+" --------"); - companies = companyPS.find(companyPS.newQuery().where("entier <= ?").addArg(count)); - assertEquals(count + 1, companies.size()); - - System.out.println("-------- find entier != "+count+" --------"); - companies = companyPS.find(companyPS.newQuery().where("entier != ?").addArg(count)); - assertEquals(count, companies.size()); - - System.out.println("-------- find entier < 3 --------"); - companies = companyPS.find(companyPS.newQuery().where("entier < 3")); - System.out.println("size:" + companies.size() + " count:" + count); - assertEquals(Math.min(3,count+1), companies.size()); - - System.out.println("-------- find and1 --------"); - companies = companyPS.find(companyPS.newQuery().where("bool = true and entier <= 0 ")); - assertEquals(1, companies.size()); - - System.out.println("-------- find and2 --------"); - companies = companyPS.find(companyPS.newQuery().where("bool = true and entier <= ? ").addArg(count)); - assertEquals(count/2+1, companies.size()); - - System.out.println("-------- find not and3 --------"); - companies = companyPS.find(companyPS.newQuery().where("not bool = true and entier <= ? ").addArg(count)); - assertEquals((count+1)/2, companies.size()); - - System.out.println("-------- find and4 --------"); - companies = companyPS.find(companyPS.newQuery().where("name like ? and entier = ? ").addArg("Compa%").addArg(0)); - assertEquals(1, companies.size()); - - System.out.println("-------- find and5 --------"); - companies = companyPS.find(companyPS.newQuery().where("name like ? and entier != ? ").addArg("Compa%").addArg(count)); - assertEquals(count, companies.size()); - - System.out.println("-------- find not and6 --------"); - companies = companyPS.find(companyPS.newQuery().where("name like ? and not entier != ? ").addArg("Compa%").addArg(count)); - assertEquals(1, companies.size()); - - System.out.println("-------- find not and7 --------"); - companies = companyPS.find(companyPS.newQuery().where("not (name like ? and entier != ?)").addArg("Compa%").addArg(count)); - assertEquals(1, companies.size()); - - System.out.println("-------- find or --------"); - companies = companyPS.find(companyPS.newQuery().where("bool = true or bool = false")); - assertEquals(count + 1, companies.size()); - - System.out.println("-------- find not (or) --------"); - companies = companyPS.find(companyPS.newQuery().where("not (bool = true or bool = false)")); - assertEquals(0, companies.size()); - -// System.out.println("-------- find in --------"); -// companies = companyPS.find(companyPS.newQuery().where("entier in (1,2,3)")); -// assertEquals(3, companies.size()); -// -// System.out.println("-------- find not in --------"); -// companies = companyPS.find(companyPS.newQuery().where("entier not in (1,2,3)")); -// assertEquals(count + 1 - 3, companies.size()); -// -// System.out.println("-------- find in coll --------"); -// HashSet list = new HashSet(); -// list.add("Company1"); -// list.add("Company2"); -// list.add("Company3"); -// companies = companyPS.find(companyPS.newQuery().where("name in ?").addArg(list)); -// assertEquals(3, companies.size()); - - - System.out.println("-------- suppression --------"); - companies = companyPS.findAll(); - for(Company c : companies){ - companyPS.delete(c); - } - - assertEquals(companyPS.size(), 0); - - child.commitTransaction(); } static int MAX = 10; public void testPerf() throws Exception { + try{ + CallAnalyse.enter(AppTest.class.getName() + ".testPerf"); - Company company; - List companies; - - System.out.println("-------- creation "+MAX+" --------"); - long time = System.currentTimeMillis(); - for(int i=0; i employees; - employees = comp.getEmployee(); - assertEquals(nbEmployees, employees.size()); - for(Employee e: employees){ - assertEquals(comp, e.getCompany()); + public void testEmployee() throws Exception { + try{ + CallAnalyse.enter(AppTest.class.getName() + ".testEmployee"); + test2Context ctx = test2Context.getContext().beginTransaction(); + EmployeePersistenceService empPS = ctx.getEmployeePersistenceService(); + CompanyPersistenceService companyPS = ctx.getCompanyPersistenceService(); + // for(Employee emp : empPS.findAll()){ + // empPS.delete(emp); + // } + // assertEquals(0, empPS.findAll().size()); + + Company comp = companyPS.create(); + comp.setName("Code Lutin"); + Employee emp; + int nbEmployees = 12; + for(int i=0; i employees; + employees = comp.getEmployee(); + assertEquals(nbEmployees, employees.size()); + for(Employee e: employees){ + assertEquals(comp, e.getCompany()); + } + employees = empPS.findAllByCompany(comp); + assertEquals(nbEmployees, employees.size()); + } finally { + CallAnalyse.exit(AppTest.class.getName() + ".testEmployee"); } - employees = empPS.findAllByCompany(comp); - assertEquals(nbEmployees, employees.size()); } static public void main(String [] args) throws Exception { @@ -410,6 +441,7 @@ AppTest test = new AppTest(); test.setUp(); test.testPerf(); + test.tearDown(); System.in.read(); }