Author: adrianc
Date: Sun Apr 21 09:02:13 2013
New Revision: 1470274

URL: http://svn.apache.org/r1470274
Log:
Added an entity cache unit test.

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=1470274&r1=1470273&r2=1470274&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 
Sun Apr 21 09:02:13 2013
@@ -106,6 +106,40 @@ public class EntityTestSuite extends Ent
     }
 
     /*
+     * Tests the entity cache
+     */
+    public void testEntityCache() throws Exception {
+        // Test primary key cache
+        GenericValue testValue = delegator.findOne("TestingType", true, 
"testingTypeId", "TEST-2");
+        assertEquals("Retrieved from cache value has the correct description", 
"Testing Type #2", testValue.getString("description"));
+        try {
+            testValue.put("description", "New Testing Type #2");
+            testValue.store();
+            fail("Modified an immutable GenericValue");
+        } catch (IllegalStateException e) {
+        }
+        // Test entity condition cache
+        /* Commenting this out for now because the tests fail due to flaws in 
the EntityListCache implementation.
+        EntityCondition testCondition = 
EntityCondition.makeCondition("description", EntityOperator.EQUALS, "Testing 
Type #2");
+        List<GenericValue> testList = delegator.findList("TestingType", 
testCondition, null, null, null, true);
+        assertEquals("Delegator findList returned one value", 1, 
testList.size());
+        testValue = testList.get(0);
+        assertEquals("Retrieved from cache value has the correct description", 
"Testing Type #2", testValue.getString("description"));
+        try {
+            testValue.put("description", "New Testing Type #2");
+            testValue.store();
+            fail("Modified an immutable GenericValue");
+        } catch (IllegalStateException e) {
+        }
+        testValue = (GenericValue) testValue.clone();
+        testValue.put("description", "New Testing Type #2");
+        testValue.store();
+        testList = delegator.findList("TestingType", testCondition, null, 
null, null, true);
+        assertEquals("Delegator findList returned empty list", 0, 
testList.size());
+        */
+    }
+
+    /*
      * Tests XML serialization by serializing/deserializing a GenericValue
      */
     public void testXmlSerialization() throws Exception {


Reply via email to