[exo-jcr-commits] exo-jcr SVN: r2741 - jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jul 5 07:31:55 EDT 2010


Author: nzamosenchuk
Date: 2010-07-05 07:31:55 -0400 (Mon, 05 Jul 2010)
New Revision: 2741

Modified:
   jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java
Log:
EXOJCR-810 : Added check if value storages are configured.

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java	2010-07-05 09:48:12 UTC (rev 2740)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java	2010-07-05 11:31:55 UTC (rev 2741)
@@ -19,6 +19,8 @@
 package org.exoplatform.services.jcr.impl.storage.value.fs;
 
 import org.exoplatform.services.jcr.BaseStandaloneTest;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
 import org.exoplatform.services.jcr.datamodel.PropertyData;
 import org.exoplatform.services.jcr.impl.core.PropertyImpl;
 import org.exoplatform.services.jcr.impl.core.SessionImpl;
@@ -27,6 +29,7 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Random;
@@ -98,7 +101,7 @@
          generator.nextBytes(smallValue);
          values[i] = testRoot.getSession().getValueFactory().createValue(new ByteArrayInputStream(smallValue));
       }
-      
+
       if (values.length == 1)
       {
          prop = testRoot.setProperty("binaryProperty", values[0]);
@@ -112,59 +115,68 @@
 
    public void testRemoveValue() throws Exception
    {
-      // reading values directly from value storage
-      PropertyImpl propertyImpl = (PropertyImpl)prop;
-      ValueStoragePluginProvider storageProvider =
-         (ValueStoragePluginProvider)mySession.getContainer().getComponentInstanceOfType(
-            ValueStoragePluginProvider.class);
+      WorkspaceContainerFacade containerFacade = repository.getWorkspaceContainer(mySession.getWorkspace().getName());
+      WorkspaceEntry wsConfig = (WorkspaceEntry)containerFacade.getComponent(WorkspaceEntry.class);
 
-      String propertyId = propertyImpl.getInternalIdentifier();
-      int count = prop.getValues().length;
-      Map<Integer, FileIOChannel> channels = new HashMap<Integer, FileIOChannel>();
+      if (wsConfig.getContainer().getValueStorages() != null && wsConfig.getContainer().getValueStorages().size() > 0)
+      {
 
-      for (int i = 0; i < count; i++)
-      {
-         ValueIOChannel channel = storageProvider.getApplicableChannel((PropertyData)propertyImpl.getData(), i);
-         if (channel != null)
+         // reading values directly from value storage
+         PropertyImpl propertyImpl = (PropertyImpl)prop;
+         ValueStoragePluginProvider storageProvider =
+            (ValueStoragePluginProvider)containerFacade.getComponent(ValueStoragePluginProvider.class);
+
+         String propertyId = propertyImpl.getInternalIdentifier();
+         int count = prop.getValues().length;
+         Map<Integer, FileIOChannel> channels = new HashMap<Integer, FileIOChannel>();
+
+         for (int i = 0; i < count; i++)
          {
-            channels.put(i, (FileIOChannel)channel);
+            ValueIOChannel channel = storageProvider.getApplicableChannel((PropertyData)propertyImpl.getData(), i);
+            if (channel != null)
+            {
+               channels.put(i, (FileIOChannel)channel);
+            }
          }
-      }
 
-      for (int i = 0; i < count; i++)
-      {
-         try
+         for (int i = 0; i < count; i++)
          {
-            channels.get(i).read(propertyId, i, 2100 * 1024);
+            try
+            {
+               channels.get(i).read(propertyId, i, 2100 * 1024);
+            }
+            catch (IOException e)
+            {
+               fail("Poperty value " + i + " can't be read!");
+            }
          }
-         catch (Exception e)
-         {
-            fail("Poperty value " + i + " can't be read!");
-         }
-      }
 
-      prop.remove();
-      mySession.save();
+         prop.remove();
+         mySession.save();
 
-      // checking whether values are still in value storage.
-      for (int i = 0; i < count; i++)
-      {
-         try
+         // checking whether values are still in value storage.
+         for (int i = 0; i < count; i++)
          {
-            // TreeFileIOChannel always returns a File. But if this file doesn't
-            // really exists is size is 0.
-            File value = channels.get(i).getFile(propertyId, i);
-            if (value.length() == 0)
+            try
             {
-               throw new Exception("");
+               // TreeFileIOChannel always returns a File. But if this file doesn't
+               // really exists is size is 0.
+               File value = channels.get(i).getFile(propertyId, i);
+               if (value.length() != 0)
+               {
+                  fail("Poperty value still can be found in value-storage but should have been already deleted!");
+               }
             }
-            fail("Poperty value still can be found in value-storage but should have been already deleted!");
+            catch (IOException e)
+            {
+               // ok
+            }
          }
-         catch (Exception e)
-         {
-            // ok
-         }
       }
+      else
+      {
+         log.warn("Value storages are not configured, test skipped.");
+      }
 
    }
 



More information about the exo-jcr-commits mailing list