Author: adrianc
Date: Fri Aug 29 20:56:08 2014 New Revision: 1621385 URL: http://svn.apache.org/r1621385 Log: Unit test to demonstrate the bug I found in GenericDelegator.java. Test is commented out. Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=1621385&r1=1621384&r2=1621385&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Fri Aug 29 20:56:08 2014 @@ -1203,6 +1203,11 @@ public class GenericDelegator implements if (doCacheClear) { // always clear cache before the operation + /* + * FIXME: This does not work - we still have a stale cache + * because the "remove by" condition might be different than + * the "find by" condition. + */ this.clearCacheLineByCondition(entityName, condition); } ModelEntity modelEntity = getModelReader().getModelEntity(entityName); 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=1621385&r1=1621384&r2=1621385&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 Fri Aug 29 20:56:08 2014 @@ -64,7 +64,7 @@ import org.ofbiz.entity.transaction.Tran import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.entity.util.EntitySaxReader; -import org.ofbiz.entity.util.SequenceUtil; +import org.ofbiz.entity.util.*; public class EntityTestSuite extends EntityTestCase { @@ -207,6 +207,16 @@ public class EntityTestSuite extends Ent testValue.store(); testValue = delegator.findOne("TestingType", true, "testingTypeId", "TEST-CACHE-1"); assertEquals("Retrieved from cache value has the correct description", "New Testing Type #Cache-1", testValue.getString("description")); + // Test storeByCondition updates the cache + /* + testValue = EntityUtil.getFirst(delegator.findByAnd("TestingType", UtilMisc.toMap("testingTypeId", "TEST-CACHE-1"), null, true)); + EntityCondition storeByCondition = EntityCondition.makeCondition(UtilMisc.toMap("testingTypeId", "TEST-CACHE-1", + "lastUpdatedStamp", testValue.get("lastUpdatedStamp"))); + int qtyChanged = delegator.storeByCondition("TestingType", UtilMisc.toMap("description", "New Testing Type #Cache-0"), storeByCondition); + assertTrue("Delegator.storeByCondition updated one value", qtyChanged == 1); + testValue = EntityUtil.getFirst(delegator.findByAnd("TestingType", UtilMisc.toMap("testingTypeId", "TEST-CACHE-1"), null, true)); + assertEquals("Retrieved from cache value has the correct description", "New Testing Type #Cache-0", testValue.getString("description")); + */ // Test entity value remove operation updates the cache testValue = (GenericValue) testValue.clone(); testValue.remove(); |
Free forum by Nabble | Edit this page |