From: Alexey L. <lou...@us...> - 2003-06-24 11:02:57
|
User: loubyansky Date: 03/06/24 04:02:56 Modified: src/main/org/jboss/test/cmp/jbossdo/tx TxUnitTestCase.java Log: added tests for PersistenceManager.close() Revision Changes Path 1.4 +53 -0 jbosstest/src/main/org/jboss/test/cmp/jbossdo/tx/TxUnitTestCase.java Index: TxUnitTestCase.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/cmp/jbossdo/tx/TxUnitTestCase.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TxUnitTestCase.java 23 Jun 2003 13:40:21 -0000 1.3 +++ TxUnitTestCase.java 24 Jun 2003 11:02:56 -0000 1.4 @@ -15,6 +15,7 @@ import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import javax.jdo.JDOUserException; +import javax.jdo.JDOFatalUserException; import javax.naming.InitialContext; import javax.transaction.UserTransaction; import javax.transaction.Synchronization; @@ -150,6 +151,58 @@ pm.currentTransaction().setSynchronization(us); utx.commit(); us.assertCalled(); + } + + public void testPersistenceManagerCloseWithoutTx() throws Exception + { + PersistenceManagerFactory pmf = getPMF(); + FieldCallbacksHistory fieldCallbacks = new FieldCallbacksHistory(); + JBossPersistenceManager pm = (JBossPersistenceManager)pmf.getPersistenceManager(); + pm.setFieldCallbacks(fieldCallbacks); + + Animal animal = new Animal("Bugs Bunny"); + pm.makePersistent(animal); + pm.close(); + assertStoredExactly(fieldCallbacks, new HistoryItem[]{ + new HistoryItem("Animal.name", "Bugs Bunny") + }); + + try + { + pm.getExtent(Animal.class, true); + fail("JDOFatalUserException should have been thrown."); + } + catch(JDOFatalUserException expected){} + } + + public void testPersistenceManagerCloseWithTx() throws Exception + { + PersistenceManagerFactory pmf = getPMF(); + FieldCallbacksHistory fieldCallbacks = new FieldCallbacksHistory(); + + UserTransaction utx = getUserTransaction(); + utx.begin(); + + JBossPersistenceManager pm = (JBossPersistenceManager)pmf.getPersistenceManager(); + pm.setFieldCallbacks(fieldCallbacks); + + Animal animal = new Animal("Bugs Bunny"); + pm.makePersistent(animal); + pm.close(); + + assertNoFieldsStored(fieldCallbacks); + + try + { + pm.getExtent(Animal.class, true); + fail("JDOFatalUserException should have been thrown."); + } + catch(JDOFatalUserException expected){} + + utx.commit(); + assertStoredExactly(fieldCallbacks, new HistoryItem[]{ + new HistoryItem("Animal.name", "Bugs Bunny") + }); } // Private |