svn commit: r883882 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r883882 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java

adrianc
Author: adrianc
Date: Tue Nov 24 21:24:10 2009
New Revision: 883882

URL: http://svn.apache.org/viewvc?rev=883882&view=rev
Log:
Improved entity engine Blob 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=883882&r1=883881&r2=883882&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 Tue Nov 24 21:24:10 2009
@@ -506,19 +506,29 @@
    */
   public void testBlobCreate() throws Exception {
       try {
-          byte[] b = new byte[1];
-          b[0] = (byte)0x01;
+          byte[] b = new byte[100000];
+          for (int i = 0; i < b.length; i++) {
+              b[i] = (byte) i;
+          }
           GenericValue testingBlob = delegator.makeValue("TestBlob", "testBlobId", "byte-blob");
           testingBlob.setBytes("testBlobField", b);
           testingBlob.create();
-
-          TestCase.assertTrue("Blob with byte value successfully created...", true);
+          TestCase.assertTrue("Blob with byte array created successfully", true);
+          testingBlob = delegator.findOne("TestBlob", UtilMisc.toMap("testBlobId", "byte-blob"), false);
+          byte[] c = testingBlob.getBytes("testBlobField");
+          TestCase.assertTrue("Byte array read from Blob data is the same length", b.length == c.length);
+          for (int i = 0; i < b.length; i++) {
+              if (b[i] != c[i]) {
+                  TestCase.fail("Blob data mismatch at " + i);
+              }
+          }
+          TestCase.assertTrue("Blob with byte array read successfully", true);
       } catch (Exception ex) {
-        TestCase.fail(ex.getMessage());
+          TestCase.fail(ex.getMessage());
       } finally {
           // Remove all our newly inserted values.
-        List<GenericValue> values = delegator.findList("TestBlob", null, null, null, null, false);
-        delegator.removeAll(values);
+          List<GenericValue> values = delegator.findList("TestBlob", null, null, null, null, false);
+          delegator.removeAll(values);
       }
   }