Index: topiatest/src/test/org/codelutin/test2/AppTest.java diff -u topiatest/src/test/org/codelutin/test2/AppTest.java:1.10 topiatest/src/test/org/codelutin/test2/AppTest.java:1.11 --- topiatest/src/test/org/codelutin/test2/AppTest.java:1.10 Tue Aug 30 13:21:54 2005 +++ topiatest/src/test/org/codelutin/test2/AppTest.java Wed Sep 21 20:32:15 2005 @@ -40,10 +40,29 @@ CallAnalyse.getThreadStatistics().clear(); } + public void testGetParentContext() throws Exception { + try{ + CallAnalyse.enter(AppTest.class.getName() + ".testEventListener"); + test2Context child1 = topiaContext.beginTransaction(); + test2Context child2 = child1.beginTransaction(); + + assertEquals(child1, child2.getParentContext()); + assertEquals(topiaContext, child1.getParentContext()); + assertEquals(null, topiaContext.getParentContext()); + + assertEquals(topiaContext, topiaContext.getRootContext()); + assertEquals(topiaContext, child1.getRootContext()); + assertEquals(topiaContext, child2.getRootContext()); + } finally { + CallAnalyse.exit(AppTest.class.getName() + ".testEventListener"); + } + } + public void testEventListener() throws Exception { try{ CallAnalyse.enter(AppTest.class.getName() + ".testEventListener"); // TODO + } finally { CallAnalyse.exit(AppTest.class.getName() + ".testEventListener"); } @@ -126,15 +145,28 @@ 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 + assertTrue(false); + }catch(TopiaException eee){ + //l'objet est en cours de "modif" dans la transaction parente System.err.println(eee.getMessage()); - catched = true; + assertTrue(true); + } + + try { + child1.commitTransaction(); + assertTrue(false); + }catch(TopiaException eee){ + // l'objet est en cours de "modif" dans la transaction parente + // donc lorsque l'on va commiter child1, on va essayer de commiter + // child2 qui va lever une exception, il faut donc faire un + // rollback sur child2 pour pouvoir commiter child1 + System.err.println(eee.getMessage()); + assertTrue(true); } - assertTrue(catched); + child2.rollbackTransaction(); child1.commitTransaction(); comp = companyPS1.findBy_TopiaId_(id);