Author: lektran
Date: Mon Apr 27 14:19:33 2009
New Revision: 768999

URL: http://svn.apache.org/viewvc?rev=768999&view=rev
Log:
Wrap EntityListIterator usage in a transaction

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java

Modified: 
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java?rev=768999&r1=768998&r2=768999&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java 
(original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java 
Mon Apr 27 14:19:33 2009
@@ -399,7 +399,9 @@
      * This test will use the large number of unique items from above and test 
the EntityListIterator looping through the list
      */
     public void testEntityListIterator() throws Exception {
+        boolean beganTransaction = false;
         try {
+            beganTransaction = TransactionUtil.begin();
             EntityListIterator iterator = delegator.find("Testing", 
EntityCondition.makeCondition("testingId", EntityOperator.LIKE, "T2-%"), null, 
null, null, null);
             assertTrue("Test if EntityListIterator was created: ", iterator != 
null);
 
@@ -413,9 +415,11 @@
             assertTrue("Test if EntitlyListIterator iterates exactly " + 
TEST_COUNT + " times: " , i == TEST_COUNT);
             iterator.close();
         } catch (GenericEntityException e) {
+            TransactionUtil.rollback(beganTransaction, "GenericEntityException 
occurred while iterating with EntityListIterator", e);
             assertTrue("GenericEntityException:" + e.toString(), false);
             return;
         } finally {
+            TransactionUtil.commit(beganTransaction);
             List<GenericValue> entitiesToRemove = 
delegator.findList("Testing", EntityCondition.makeCondition("testingId", 
EntityOperator.LIKE, "T2-%"), null, null, null, false);
             delegator.removeAll(entitiesToRemove);
         }


Reply via email to