[exo-jcr-commits] exo-jcr SVN: r3603 - in jcr/trunk/exo.jcr.component.ext: src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms and 5 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Dec 6 09:34:57 EST 2010


Author: tolusha
Date: 2010-12-06 09:34:57 -0500 (Mon, 06 Dec 2010)
New Revision: 3603

Added:
   jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsFullBackupJob.java
   jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsWorkspaceInitializer.java
   jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/RdbmsWorkspaceInitializerWrapper.java
   jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java
Removed:
   jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestFullBackupJob.java
Modified:
   jcr/trunk/exo.jcr.component.ext/pom.xml
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java
   jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java
   jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml
Log:
EXOJCR-1078: test RDBMS workspace initialzer

Modified: jcr/trunk/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/pom.xml	2010-12-06 14:25:34 UTC (rev 3602)
+++ jcr/trunk/exo.jcr.component.ext/pom.xml	2010-12-06 14:34:57 UTC (rev 3603)
@@ -185,12 +185,13 @@
               <include>**/replication/*.java</include>
               <include>**/replication/external/*.java</include>
               <include>**/replication/async/**/*.java</include>
-              <include>**/backup/TestBackupManager.java</include>
-              <include>**/backup/TestFileNameProduser.java</include>
-              <include>**/**/TestFullBackupJob.java</include>
+              <include>**/backup/*.java</include>
             </includes>
             <excludes>
               <exclude>**/BaseStandaloneTest.java</exclude>
+              <exclude>**/backup/AbstractBackupTestCase.java</exclude>
+              <exclude>**/backup/TestBackupScheduler.java</exclude>
+              <exclude>**/backup/TestBackupRestart.java</exclude>
               <exclude>**/replication/*.java</exclude>
               <exclude>**/replication/external/*.java</exclude>
               <exclude>**/replication/external/BaseTestCaseChecker.java</exclude>

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java	2010-12-06 14:25:34 UTC (rev 3602)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java	2010-12-06 14:34:57 UTC (rev 3603)
@@ -31,6 +31,7 @@
 import org.exoplatform.services.jcr.ext.backup.impl.AbstractFullBackupJob;
 import org.exoplatform.services.jcr.ext.backup.impl.FileNameProducer;
 import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.RdbmsWorkspaceInitializer;
 import org.exoplatform.services.jcr.impl.core.query.SystemSearchManager;
 import org.exoplatform.services.jcr.impl.dataflow.serialization.ObjectWriterImpl;
 import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
@@ -74,31 +75,6 @@
    protected static Log log = ExoLogger.getLogger("exo.jcr.component.ext.FullBackupJob");
 
    /**
-    * Index directory in full backup storage.
-    */
-   public static final String INDEX_DIR = "index";
-
-   /**
-    * System index directory in full backup storage.
-    */
-   public static final String SYSTEM_INDEX_DIR = INDEX_DIR + "_" + SystemSearchManager.INDEX_DIR_SUFFIX;
-
-   /**
-    * Value storage directory in full backup storage.
-    */
-   public static final String VALUE_STORAGE_DIR = "values";
-
-   /**
-    * Suffix for content file.
-    */
-   public static final String CONTENT_FILE_SUFFIX = ".dump";
-
-   /**
-    * Suffix for content length file.
-    */
-   public static final String CONTENT_LEN_FILE_SUFFIX = ".len";
-
-   /**
     * Content is absent.
     */
    public static final byte NULL_LEN = 0;
@@ -200,40 +176,37 @@
                + workspaceName);
          }
 
+         String multiDb = workspaceEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB);
+         if (multiDb == null)
+         {
+            throw new RepositoryConfigurationException(JDBCWorkspaceDataContainer.MULTIDB
+               + " parameter not found in workspace " + workspaceName + " configuration");
+         }
+
          final DataSource ds = (DataSource)new InitialContext().lookup(dsName);
          if (ds == null)
          {
             throw new NameNotFoundException("Data source " + dsName + " not found");
          }
 
-         jdbcConn =
-            SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
+         jdbcConn = SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
+         {
+            public Connection run() throws Exception
             {
-               public Connection run() throws Exception
-               {
-                  return ds.getConnection();
+               return ds.getConnection();
 
-               }
-            });
-            
+            }
+         });
+
          transactionIsolation = jdbcConn.getTransactionIsolation();
          jdbcConn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
 
-         String multiDb = workspaceEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB);
-         if (multiDb == null)
-         {
-            throw new RepositoryConfigurationException(JDBCWorkspaceDataContainer.MULTIDB
-               + " parameter not found in workspace " + workspaceName + " configuration");
-         }
-
          // dump JCR data
          String[][] scripts;
          if (Boolean.parseBoolean(multiDb))
          {
             scripts =
-               new String[][]{
-                  {"JCR_MVALUE", "select * from JCR_MVALUE"},
-                  {"JCR_MREF", "select * from JCR_MREF"},
+               new String[][]{{"JCR_MVALUE", "select * from JCR_MVALUE"}, {"JCR_MREF", "select * from JCR_MREF"},
                   {"JCR_MITEM", "select * from JCR_MITEM"}};
          }
          else
@@ -269,62 +242,10 @@
             {
                dumpTable(jdbcConn, script[0], script[1]);
             }
-            else
-            {
-               log.warn("Table " + script[0] + " doesn't exist");
-            }
          }
 
-         // copy value storage directory
-         if (workspaceEntry.getContainer().getValueStorages() != null)
-         {
-            for (ValueStorageEntry valueStorage : workspaceEntry.getContainer().getValueStorages())
-            {
-               File srcDir = new File(valueStorage.getParameterValue(FileValueStorage.PATH));
-               if (!PrivilegedFileHelper.exists(srcDir))
-               {
-                  log.warn("Can't not backup value storage. Directory " + srcDir.getName() + " doesn't exists");
-               }
-               else
-               {
-                  File destValuesDir = new File(getStorageURL().getFile(), VALUE_STORAGE_DIR);
-                  File destDir = new File(destValuesDir, valueStorage.getId());
-
-                  copyDirectory(srcDir, destDir);
-               }
-            }
-         }
-
-         // copy index directory 
-         if (workspaceEntry.getQueryHandler() != null)
-         {
-            File srcDir =
-               new File(workspaceEntry.getQueryHandler().getParameterValue(QueryHandlerParams.PARAM_INDEX_DIR));
-            if (!PrivilegedFileHelper.exists(srcDir))
-            {
-               log.warn("Can't not backup index. Directory " + srcDir.getName() + " doesn't exists");
-            }
-            else
-            {
-               File destDir = new File(getStorageURL().getFile(), INDEX_DIR);
-               copyDirectory(srcDir, destDir);
-            }
-
-            if (repository.getConfiguration().getSystemWorkspaceName().equals(workspaceName))
-            {
-               srcDir =
-                  new File(PrivilegedFileHelper.getCanonicalPath(srcDir) + "_" + SystemSearchManager.INDEX_DIR_SUFFIX);
-               if (!PrivilegedFileHelper.exists(srcDir))
-               {
-                  log.warn("Can't not backup system index. Directory " + srcDir.getName() + " doesn't exists");
-               }
-               else
-               {
-                  File destDir = new File(getStorageURL().getFile(), SYSTEM_INDEX_DIR);
-                  copyDirectory(srcDir, destDir);
-               }
-            }
-         }
+         backupValueStorage(workspaceEntry);
+         backupIndex(workspaceEntry);
       }
       catch (RepositoryConfigurationException e)
       {
@@ -382,9 +303,83 @@
    }
 
    /**
+    * Backup index files.
+    * 
+    * @param workspaceEntry
+    * @throws RepositoryConfigurationException
+    * @throws BackupOperationException
+    * @throws IOException
+    */
+   protected void backupIndex(WorkspaceEntry workspaceEntry) throws RepositoryConfigurationException,
+      BackupOperationException, IOException
+   {
+      if (workspaceEntry.getQueryHandler() != null)
+      {
+         File srcDir = new File(workspaceEntry.getQueryHandler().getParameterValue(QueryHandlerParams.PARAM_INDEX_DIR));
+         if (!PrivilegedFileHelper.exists(srcDir))
+         {
+            throw new BackupOperationException("Can't backup index. Directory " + srcDir.getName() + " doesn't exists");
+         }
+         else
+         {
+            File destDir = new File(getStorageURL().getFile(), RdbmsWorkspaceInitializer.INDEX_DIR);
+            copyDirectory(srcDir, destDir);
+         }
+
+         if (repository.getConfiguration().getSystemWorkspaceName().equals(workspaceName))
+         {
+            srcDir =
+               new File(PrivilegedFileHelper.getCanonicalPath(srcDir) + "_" + SystemSearchManager.INDEX_DIR_SUFFIX);
+            if (!PrivilegedFileHelper.exists(srcDir))
+            {
+               throw new BackupOperationException("Can't backup system index. Directory " + srcDir.getName()
+                  + " doesn't exists");
+            }
+            else
+            {
+               File destDir = new File(getStorageURL().getFile(), RdbmsWorkspaceInitializer.SYSTEM_INDEX_DIR);
+               copyDirectory(srcDir, destDir);
+            }
+         }
+      }
+   }
+
+   /**
+    * Backup value storage files.
+    * 
+    * @param workspaceEntry
+    * @throws RepositoryConfigurationException
+    * @throws BackupOperationException
+    * @throws IOException
+    */
+   protected void backupValueStorage(WorkspaceEntry workspaceEntry) throws RepositoryConfigurationException,
+      BackupOperationException, IOException
+   {
+      if (workspaceEntry.getContainer().getValueStorages() != null)
+      {
+         for (ValueStorageEntry valueStorage : workspaceEntry.getContainer().getValueStorages())
+         {
+            File srcDir = new File(valueStorage.getParameterValue(FileValueStorage.PATH));
+            if (!PrivilegedFileHelper.exists(srcDir))
+            {
+               throw new BackupOperationException("Can't backup value storage. Directory " + srcDir.getName()
+                  + " doesn't exists");
+            }
+            else
+            {
+               File destValuesDir = new File(getStorageURL().getFile(), RdbmsWorkspaceInitializer.VALUE_STORAGE_DIR);
+               File destDir = new File(destValuesDir, valueStorage.getId());
+
+               copyDirectory(srcDir, destDir);
+            }
+         }
+      }
+   }
+
+   /**
     * Dump table.
     */
-   private void dumpTable(Connection jdbcConn, String tableName, String script) throws SQLException, IOException,
+   protected void dumpTable(Connection jdbcConn, String tableName, String script) throws SQLException, IOException,
       BackupOperationException
    {
       int getValueMethod = GET_BINARY_STREAM_METHOD;
@@ -401,10 +396,12 @@
       ResultSet rs = null;
       try
       {
-         File contentFile = new File(getStorageURL().getFile(), tableName + CONTENT_FILE_SUFFIX);
+         File contentFile =
+            new File(getStorageURL().getFile(), tableName + RdbmsWorkspaceInitializer.CONTENT_FILE_SUFFIX);
          contentWriter = new ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(contentFile));
 
-         File contentLenFile = new File(getStorageURL().getFile(), tableName + CONTENT_LEN_FILE_SUFFIX);
+         File contentLenFile =
+            new File(getStorageURL().getFile(), tableName + RdbmsWorkspaceInitializer.CONTENT_LEN_FILE_SUFFIX);
          contentLenWriter = new ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(contentLenFile));
 
          stmt = jdbcConn.prepareStatement(script);

Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java	2010-12-06 14:25:34 UTC (rev 3602)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java	2010-12-06 14:34:57 UTC (rev 3603)
@@ -34,6 +34,7 @@
 import org.exoplatform.services.jcr.impl.core.NodeImpl;
 import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
 import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
 import org.exoplatform.services.jcr.impl.dataflow.serialization.ReaderSpoolFileHolder;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
 import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
@@ -83,6 +84,8 @@
 
    protected PersistentDataManager dataManager;
 
+   protected CacheableWorkspaceDataManager cacheableDataManager;
+
    protected ValueFactory valueFactory;
 
    protected StandaloneContainer container;
@@ -107,6 +110,7 @@
       }
    }
 
+   @Override
    public void setUp() throws Exception
    {
       String containerConf = BaseStandaloneTest.class.getResource("/conf/standalone/test-configuration.xml").toString();
@@ -146,8 +150,10 @@
 
       wsc = repository.getWorkspaceContainer("ws4");
       dataManager = (PersistentDataManager)wsc.getComponent(PersistentDataManager.class);
+      cacheableDataManager = (CacheableWorkspaceDataManager)wsc.getComponent(PersistentDataManager.class);
    }
 
+   @Override
    protected void tearDown() throws Exception
    {
 

Deleted: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestFullBackupJob.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestFullBackupJob.java	2010-12-06 14:25:34 UTC (rev 3602)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestFullBackupJob.java	2010-12-06 14:34:57 UTC (rev 3603)
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.ext.backup;
-
-import org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Calendar;
-
-/**
- * @author <a href="mailto:anatoliy.bazko at gmail.com">Anatoliy Bazko</a>
- * @version $Id: TestFullBackupJob.java 34360 2009-07-22 23:58:59Z tolusha $
- */
-public class TestFullBackupJob extends AbstractBackupTestCase
-{
-
-   public void testRDBMSFullBackupJobSystemWorkspace() throws Exception
-   {
-      FullBackupJob job = new FullBackupJob();
-      BackupConfig config = new BackupConfig();
-      config.setRepository("db1");
-      config.setWorkspace("ws");
-      config.setBackupDir(new File("target/backup/testJob"));
-
-      Calendar calendar = Calendar.getInstance();
-
-      job.init(repositoryService.getRepository("db1"), "ws", config, calendar);
-      job.run();
-
-      URL url = job.getStorageURL();
-      assertNotNull(url);
-
-      File valuesDir = new File(url.getFile(), FullBackupJob.VALUE_STORAGE_DIR);
-      assertTrue(valuesDir.exists());
-      String values[] = valuesDir.list();
-
-      assertEquals(values.length, 1);
-      assertTrue(new File(valuesDir, values[0]).isDirectory());
-
-      File indexesDir = new File(url.getFile(), FullBackupJob.INDEX_DIR);
-      assertTrue(indexesDir.exists());
-
-      indexesDir = new File(url.getFile(), FullBackupJob.SYSTEM_INDEX_DIR);
-      assertTrue(indexesDir.exists());
-
-      assertTrue(new File(url.getFile(), "JCR_MITEM" + FullBackupJob.CONTENT_FILE_SUFFIX).exists());
-      assertTrue(new File(url.getFile(), "JCR_MITEM" + FullBackupJob.CONTENT_LEN_FILE_SUFFIX).exists());
-
-      assertTrue(new File(url.getFile(), "JCR_MVALUE" + FullBackupJob.CONTENT_FILE_SUFFIX).exists());
-      assertTrue(new File(url.getFile(), "JCR_MVALUE" + FullBackupJob.CONTENT_LEN_FILE_SUFFIX).exists());
-
-      assertTrue(new File(url.getFile(), "JCR_MREF" + FullBackupJob.CONTENT_FILE_SUFFIX).exists());
-      assertTrue(new File(url.getFile(), "JCR_MREF" + FullBackupJob.CONTENT_LEN_FILE_SUFFIX).exists());
-
-   }
-
-   public void testRDBMSFullBackupJob() throws Exception
-   {
-      FullBackupJob job = new FullBackupJob();
-      BackupConfig config = new BackupConfig();
-      config.setRepository("db1");
-      config.setWorkspace("ws1");
-      config.setBackupDir(new File("target/backup/testJob"));
-      
-      Calendar calendar = Calendar.getInstance();
-
-      job.init(repositoryService.getRepository("db1"), "ws1", config, calendar);
-      job.run();
-
-      URL url = job.getStorageURL();
-      assertNotNull(url);
-
-      File valuesDir = new File(url.getFile(), FullBackupJob.VALUE_STORAGE_DIR);
-      assertFalse(valuesDir.exists());
-
-      File indexesDir = new File(url.getFile(), FullBackupJob.INDEX_DIR);
-      assertTrue(indexesDir.exists());
-
-      indexesDir = new File(url.getFile(), FullBackupJob.SYSTEM_INDEX_DIR);
-      assertFalse(indexesDir.exists());
-
-      assertTrue(new File(url.getFile(), "JCR_MITEM" + FullBackupJob.CONTENT_FILE_SUFFIX).exists());
-      assertTrue(new File(url.getFile(), "JCR_MITEM" + FullBackupJob.CONTENT_LEN_FILE_SUFFIX).exists());
-
-      assertTrue(new File(url.getFile(), "JCR_MVALUE" + FullBackupJob.CONTENT_FILE_SUFFIX).exists());
-      assertTrue(new File(url.getFile(), "JCR_MVALUE" + FullBackupJob.CONTENT_LEN_FILE_SUFFIX).exists());
-
-      assertTrue(new File(url.getFile(), "JCR_MREF" + FullBackupJob.CONTENT_FILE_SUFFIX).exists());
-      assertTrue(new File(url.getFile(), "JCR_MREF" + FullBackupJob.CONTENT_LEN_FILE_SUFFIX).exists());
-
-   }
-}

Copied: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsFullBackupJob.java (from rev 3597, jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestFullBackupJob.java)
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsFullBackupJob.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsFullBackupJob.java	2010-12-06 14:34:57 UTC (rev 3603)
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.ext.backup;
+
+import org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob;
+import org.exoplatform.services.jcr.impl.core.RdbmsWorkspaceInitializer;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Calendar;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko at gmail.com">Anatoliy Bazko</a>
+ * @version $Id: TestFullBackupJob.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class TestRdbmsFullBackupJob extends AbstractBackupTestCase
+{
+
+   public void testRDBMSFullBackupJobSystemWorkspace() throws Exception
+   {
+      FullBackupJob job = new FullBackupJob();
+      BackupConfig config = new BackupConfig();
+      config.setRepository("db1");
+      config.setWorkspace("ws");
+      config.setBackupDir(new File("target/backup/testJob"));
+
+      Calendar calendar = Calendar.getInstance();
+
+      job.init(repositoryService.getRepository("db1"), "ws", config, calendar);
+      job.run();
+
+      URL url = job.getStorageURL();
+      assertNotNull(url);
+
+      File valuesDir = new File(url.getFile(), RdbmsWorkspaceInitializer.VALUE_STORAGE_DIR);
+      assertTrue(valuesDir.exists());
+      String values[] = valuesDir.list();
+
+      assertEquals(values.length, 1);
+      assertTrue(new File(valuesDir, values[0]).isDirectory());
+
+      File indexesDir = new File(url.getFile(), RdbmsWorkspaceInitializer.INDEX_DIR);
+      assertTrue(indexesDir.exists());
+
+      indexesDir = new File(url.getFile(), RdbmsWorkspaceInitializer.SYSTEM_INDEX_DIR);
+      assertTrue(indexesDir.exists());
+
+      assertTrue(new File(url.getFile(), "JCR_MITEM" + RdbmsWorkspaceInitializer.CONTENT_FILE_SUFFIX).exists());
+      assertTrue(new File(url.getFile(), "JCR_MITEM" + RdbmsWorkspaceInitializer.CONTENT_LEN_FILE_SUFFIX).exists());
+
+      assertTrue(new File(url.getFile(), "JCR_MVALUE" + RdbmsWorkspaceInitializer.CONTENT_FILE_SUFFIX).exists());
+      assertTrue(new File(url.getFile(), "JCR_MVALUE" + RdbmsWorkspaceInitializer.CONTENT_LEN_FILE_SUFFIX).exists());
+
+      assertTrue(new File(url.getFile(), "JCR_MREF" + RdbmsWorkspaceInitializer.CONTENT_FILE_SUFFIX).exists());
+      assertTrue(new File(url.getFile(), "JCR_MREF" + RdbmsWorkspaceInitializer.CONTENT_LEN_FILE_SUFFIX).exists());
+
+   }
+
+   public void testRDBMSFullBackupJob() throws Exception
+   {
+      FullBackupJob job = new FullBackupJob();
+      BackupConfig config = new BackupConfig();
+      config.setRepository("db1");
+      config.setWorkspace("ws1");
+      config.setBackupDir(new File("target/backup/testJob"));
+      
+      Calendar calendar = Calendar.getInstance();
+
+      job.init(repositoryService.getRepository("db1"), "ws1", config, calendar);
+      job.run();
+
+      URL url = job.getStorageURL();
+      assertNotNull(url);
+
+      File valuesDir = new File(url.getFile(), RdbmsWorkspaceInitializer.VALUE_STORAGE_DIR);
+      assertFalse(valuesDir.exists());
+
+      File indexesDir = new File(url.getFile(), RdbmsWorkspaceInitializer.INDEX_DIR);
+      assertTrue(indexesDir.exists());
+
+      indexesDir = new File(url.getFile(), RdbmsWorkspaceInitializer.SYSTEM_INDEX_DIR);
+      assertFalse(indexesDir.exists());
+
+      assertTrue(new File(url.getFile(), "JCR_MITEM" + RdbmsWorkspaceInitializer.CONTENT_FILE_SUFFIX).exists());
+      assertTrue(new File(url.getFile(), "JCR_MITEM" + RdbmsWorkspaceInitializer.CONTENT_LEN_FILE_SUFFIX).exists());
+
+      assertTrue(new File(url.getFile(), "JCR_MVALUE" +RdbmsWorkspaceInitializer.CONTENT_FILE_SUFFIX).exists());
+      assertTrue(new File(url.getFile(), "JCR_MVALUE" + RdbmsWorkspaceInitializer.CONTENT_LEN_FILE_SUFFIX).exists());
+
+      assertTrue(new File(url.getFile(), "JCR_MREF" + RdbmsWorkspaceInitializer.CONTENT_FILE_SUFFIX).exists());
+      assertTrue(new File(url.getFile(), "JCR_MREF" + RdbmsWorkspaceInitializer.CONTENT_LEN_FILE_SUFFIX).exists());
+
+   }
+}

Added: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsWorkspaceInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsWorkspaceInitializer.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsWorkspaceInitializer.java	2010-12-06 14:34:57 UTC (rev 3603)
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.ext.backup;
+
+import org.exoplatform.services.jcr.config.SimpleParameterEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.config.WorkspaceInitializerEntry;
+import org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob;
+import org.exoplatform.services.jcr.impl.core.RdbmsWorkspaceInitializer;
+import org.exoplatform.services.jcr.impl.core.RdbmsWorkspaceInitializerWrapper;
+import org.exoplatform.services.jcr.impl.core.SysViewWorkspaceInitializer;
+import org.exoplatform.services.jcr.impl.core.query.SystemSearchManager;
+import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
+import org.exoplatform.services.jcr.util.IdGenerator;
+import org.exoplatform.services.jcr.util.TesterConfigurationHelper;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko at gmail.com">Anatoliy Bazko</a>
+ * @version $Id: TestFullBackupJob.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class TestRdbmsWorkspaceInitializer extends AbstractBackupTestCase
+{
+   TesterConfigurationHelper helper = TesterConfigurationHelper.getInstence();
+
+   public void testRDBMSInitializerSystemWorkspace() throws Exception
+   {
+      FullBackupJob job = new FullBackupJob();
+      BackupConfig config = new BackupConfig();
+      config.setRepository("db1");
+      config.setWorkspace("ws");
+      config.setBackupDir(new File("target/backup/testJob"));
+
+      Calendar calendar = Calendar.getInstance();
+
+      job.init(repositoryService.getRepository("db1"), "ws", config, calendar);
+      job.run();
+
+      URL url = job.getStorageURL();
+
+      for (WorkspaceEntry workspaceEntry : repositoryService.getRepository("db1").getConfiguration()
+         .getWorkspaceEntries())
+      {
+         if (workspaceEntry.getName().equals("ws"))
+         {
+            String newValueStoragePath = "target/temp/values/" + IdGenerator.generate();
+            String newIndexPath = "target/temp/index/" + IdGenerator.generate();
+
+            // set the initializer
+            WorkspaceEntry newEntry =
+               helper.getNewWs("ws", true, null, newValueStoragePath, newIndexPath, workspaceEntry.getContainer(),
+                  workspaceEntry.getContainer().getValueStorages());
+
+            WorkspaceInitializerEntry wiEntry = new WorkspaceInitializerEntry();
+            wiEntry.setType(RdbmsWorkspaceInitializer.class.getCanonicalName());
+
+            List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
+            wieParams.add(new SimpleParameterEntry(SysViewWorkspaceInitializer.RESTORE_PATH_PARAMETER, new File(url
+               .getFile()).getParent()));
+
+            wiEntry.setParameters(wieParams);
+
+            newEntry.setInitializer(wiEntry);
+
+            RdbmsWorkspaceInitializerWrapper initializer =
+               new RdbmsWorkspaceInitializerWrapper(newEntry,
+                  repositoryService.getRepository("db1").getConfiguration(), cacheableDataManager, null, null, null,
+                  (ValueFactoryImpl)valueFactory, null);
+
+            initializer.restoreValueFiles();
+            assertTrue(new File(newValueStoragePath).list().length > 0);
+
+            initializer.restoreIndexFiles();
+            assertTrue(new File(newIndexPath).list().length > 0);
+            assertTrue(new File(newIndexPath + "_" + SystemSearchManager.INDEX_DIR_SUFFIX).exists());
+            assertTrue(new File(newIndexPath + "_" + SystemSearchManager.INDEX_DIR_SUFFIX).list().length > 0);
+         }
+      }
+   }
+
+   public void testRDBMSInitializer() throws Exception
+   {
+      FullBackupJob job = new FullBackupJob();
+      BackupConfig config = new BackupConfig();
+      config.setRepository("db1");
+      config.setWorkspace("ws1");
+      config.setBackupDir(new File("target/backup/testJob"));
+
+      Calendar calendar = Calendar.getInstance();
+
+      job.init(repositoryService.getRepository("db1"), "ws1", config, calendar);
+      job.run();
+
+      URL url = job.getStorageURL();
+
+      for (WorkspaceEntry workspaceEntry : repositoryService.getRepository("db1").getConfiguration()
+         .getWorkspaceEntries())
+      {
+         if (workspaceEntry.getName().equals("ws1"))
+         {
+            String newValueStoragePath = "target/temp/values/" + IdGenerator.generate();
+            String newIndexPath = "target/temp/index/" + IdGenerator.generate();
+
+            // set the initializer
+            WorkspaceEntry newEntry =
+               helper.getNewWs("ws1", true, null, newValueStoragePath, newIndexPath, workspaceEntry.getContainer(),
+                  workspaceEntry.getContainer().getValueStorages());
+
+            WorkspaceInitializerEntry wiEntry = new WorkspaceInitializerEntry();
+            wiEntry.setType(RdbmsWorkspaceInitializer.class.getCanonicalName());
+
+            List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
+            wieParams.add(new SimpleParameterEntry(SysViewWorkspaceInitializer.RESTORE_PATH_PARAMETER, new File(url
+               .getFile()).getParent()));
+
+            wiEntry.setParameters(wieParams);
+
+            newEntry.setInitializer(wiEntry);
+
+            RdbmsWorkspaceInitializerWrapper initializer =
+               new RdbmsWorkspaceInitializerWrapper(newEntry,
+                  repositoryService.getRepository("db1").getConfiguration(), cacheableDataManager, null, null, null,
+                  (ValueFactoryImpl)valueFactory, null);
+
+            initializer.restoreValueFiles();
+            assertFalse(new File(newValueStoragePath).exists());
+
+            initializer.restoreIndexFiles();
+            assertTrue(new File(newIndexPath).list().length > 0);
+            assertFalse(new File(newIndexPath + "_" + SystemSearchManager.INDEX_DIR_SUFFIX).exists());
+         }
+      }
+   }
+
+}

Added: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/RdbmsWorkspaceInitializerWrapper.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/RdbmsWorkspaceInitializerWrapper.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/RdbmsWorkspaceInitializerWrapper.java	2010-12-06 14:34:57 UTC (rev 3603)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.core;
+
+import org.exoplatform.services.jcr.access.AccessManager;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
+import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
+
+import java.io.IOException;
+
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS
+ * 
+ * 04.12.2006
+ * 
+ * For testing purpose
+ * 
+ * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a>
+ * @version $Id: SessionDataManagerTestWrapper.java 11907 2008-03-13 15:36:21Z ksm $
+ */
+public class RdbmsWorkspaceInitializerWrapper extends RdbmsWorkspaceInitializer
+{
+
+   public RdbmsWorkspaceInitializerWrapper(WorkspaceEntry config, RepositoryEntry repConfig,
+      CacheableWorkspaceDataManager dataManager, NamespaceRegistryImpl namespaceRegistry,
+      LocationFactory locationFactory, NodeTypeManagerImpl nodeTypeManager, ValueFactoryImpl valueFactory,
+      AccessManager accessManager) throws RepositoryConfigurationException, PathNotFoundException, RepositoryException
+   {
+      super(config, repConfig, dataManager, namespaceRegistry, locationFactory, nodeTypeManager, valueFactory,
+         accessManager);
+   }
+
+   public void restoreValueFiles() throws RepositoryConfigurationException, IOException
+   {
+      super.restoreValueStorage();
+   }
+
+   public void restoreIndexFiles() throws RepositoryConfigurationException, IOException
+   {
+      super.restoreIndex();
+   }
+}

Added: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java	2010-12-06 14:34:57 UTC (rev 3603)
@@ -0,0 +1,347 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.util;
+
+import org.apache.commons.dbcp.BasicDataSourceFactory;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.jcr.config.CacheEntry;
+import org.exoplatform.services.jcr.config.ContainerEntry;
+import org.exoplatform.services.jcr.config.LockManagerEntry;
+import org.exoplatform.services.jcr.config.LockPersisterEntry;
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.SimpleParameterEntry;
+import org.exoplatform.services.jcr.config.ValueStorageEntry;
+import org.exoplatform.services.jcr.config.ValueStorageFilterEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DialectDetecter;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.jcr.RepositoryException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+/**
+ * Created by The eXo Platform SAS
+ * 
+ * @author <a href="mailto:Sergey.Kabashnyuk at gmail.com">Sergey Kabashnyuk</a>
+ * @version $Id: ConfigurationHelper.java 11907 2008-03-13 15:36:21Z ksm $
+ */
+public class TesterConfigurationHelper
+{
+   private static Log log = ExoLogger.getLogger("exo.jcr.component.core.ConfigurationHelper");
+
+   private static TesterConfigurationHelper instence;
+
+   private TesterConfigurationHelper()
+   {
+      System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.exoplatform.services.naming.SimpleContextFactory");
+   }
+
+   public void createWorkspace(WorkspaceEntry workspaceEntry, ExoContainer container)
+      throws RepositoryConfigurationException, RepositoryException
+   {
+      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+      RepositoryImpl defRep;
+
+      defRep = (RepositoryImpl)service.getDefaultRepository();
+      defRep.configWorkspace(workspaceEntry);
+      defRep.createWorkspace(workspaceEntry.getName());
+
+   }
+
+   public String getNewDataSource(String type) throws Exception
+   {
+
+      String newDS = IdGenerator.generate();
+      Properties properties = new Properties();
+
+      properties.setProperty("driverClassName", "org.hsqldb.jdbcDriver");
+      String newurl = "jdbc:hsqldb:file:target/temp/data/" + newDS;
+
+      log.info("New url " + newurl);
+
+      properties.setProperty("url", newurl);
+      properties.setProperty("username", "sa");
+      properties.setProperty("password", "");
+      DataSource bds = BasicDataSourceFactory.createDataSource(properties);
+      if (!newurl.contains("hsqldb"))
+      {
+         createDatabase(bds, newDS);
+      }
+
+      new InitialContext().bind(newDS, bds);
+      return newDS;
+
+   }
+
+   public WorkspaceEntry getNewWs(String wsName, boolean isMultiDb, String dsName, String vsPath, String indexDir,
+      ContainerEntry entry, List<ValueStorageEntry> valueStorage) throws Exception
+   {
+
+      String dbDialect = null;
+      if (dsName != null)
+      {
+         DataSource ds = (DataSource)new InitialContext().lookup(dsName);
+         if (ds != null)
+         {
+            Connection jdbcConn = null;
+
+            jdbcConn = ds.getConnection();
+            dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
+
+         }
+      }
+
+      if (dsName == null)
+      {
+         dsName = getNewDataSource("");
+      }
+
+      List params = new ArrayList();
+
+      params.add(new SimpleParameterEntry("source-name", dsName));
+      params.add(new SimpleParameterEntry("db-type", "generic"));
+      params.add(new SimpleParameterEntry("multi-db", isMultiDb ? "true" : "false"));
+      params.add(new SimpleParameterEntry("update-storage", "true"));
+      params.add(new SimpleParameterEntry("max-buffer-size", "204800"));
+
+      if (dbDialect != null)
+      {
+         params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_DIALECT, dbDialect));
+      }
+      else if (entry.getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT) != null)
+      {
+         params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_DIALECT, entry
+            .getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT)));
+      }
+
+      String oldSwap = entry.getParameterValue("swap-directory");
+      String newSwap = oldSwap.substring(0, oldSwap.lastIndexOf('/')) + '/' + wsName;
+
+      params.add(new SimpleParameterEntry("swap-directory", newSwap));
+
+      ContainerEntry containerEntry =
+         new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
+            (ArrayList)params);
+      containerEntry.setParameters(params);
+
+      // value storage
+      ArrayList list = new ArrayList();
+      if (valueStorage != null)
+      {
+         for (ValueStorageEntry oldValueStorageEntry : valueStorage)
+         {
+            ArrayList<ValueStorageFilterEntry> vsparams = new ArrayList<ValueStorageFilterEntry>();
+            ValueStorageFilterEntry filterEntry = new ValueStorageFilterEntry();
+            filterEntry.setPropertyType("Binary");
+            vsparams.add(filterEntry);
+
+            ValueStorageEntry valueStorageEntry =
+               new ValueStorageEntry("org.exoplatform.services.jcr.impl.storage.value.fs.SimpleFileValueStorage",
+                  vsparams);
+            ArrayList<SimpleParameterEntry> spe = new ArrayList<SimpleParameterEntry>();
+            spe.add(new SimpleParameterEntry("path", vsPath));
+            valueStorageEntry.setId(oldValueStorageEntry.getId());
+            valueStorageEntry.setParameters(spe);
+            valueStorageEntry.setFilters(vsparams);
+
+            // containerEntry.setValueStorages();
+            containerEntry.setParameters(params);
+
+            list.add(valueStorageEntry);
+         }
+      }
+
+      containerEntry.setValueStorages(list);
+
+      // Indexer
+      ArrayList qParams = new ArrayList();
+      qParams.add(new SimpleParameterEntry("index-dir", indexDir));
+      QueryHandlerEntry qEntry =
+         new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
+
+      WorkspaceEntry workspaceEntry =
+         new WorkspaceEntry(wsName != null ? wsName : IdGenerator.generate(), "nt:unstructured");
+      workspaceEntry.setContainer(containerEntry);
+
+      ArrayList cacheParams = new ArrayList();
+
+      cacheParams.add(new SimpleParameterEntry("maxSize", "2000"));
+      cacheParams.add(new SimpleParameterEntry("liveTime", "20m"));
+      CacheEntry cacheEntry = new CacheEntry(cacheParams);
+      cacheEntry.setType("org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl");
+
+      workspaceEntry.setCache(cacheEntry);
+
+      workspaceEntry.setQueryHandler(qEntry);
+
+      LockManagerEntry lockManagerEntry = new LockManagerEntry();
+      lockManagerEntry.setTimeout(900000);
+      LockPersisterEntry persisterEntry = new LockPersisterEntry();
+      persisterEntry.setType("org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister");
+      ArrayList lpParams = new ArrayList();
+      lpParams.add(new SimpleParameterEntry("path", "../temp/lock"));
+      persisterEntry.setParameters(lpParams);
+      lockManagerEntry.setPersister(persisterEntry);
+      workspaceEntry.setLockManager(lockManagerEntry);
+
+      // workspaceEntry
+      return workspaceEntry;
+   }
+
+   //   public WorkspaceEntry getNewWsOnDataSource(String wsName, boolean isMultiDb, String dsName, String vsPath,
+   //      ContainerEntry entry) throws Exception
+   //   {
+   //
+   //      String dbDialect = null;
+   //      if (dsName != null)
+   //      {
+   //         DataSource ds = (DataSource)new InitialContext().lookup(dsName);
+   //         if (ds != null)
+   //         {
+   //            Connection jdbcConn = null;
+   //
+   //            jdbcConn = ds.getConnection();
+   //            dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
+   //         }
+   //      }
+   //
+   //      List params = new ArrayList();
+   //
+   //      if (isMultiDb && dsName == null)
+   //      {
+   //         dsName = getNewDataSource("");
+   //      }
+   //
+   //      params.add(new SimpleParameterEntry("sourceName", dsName));
+   //      params.add(new SimpleParameterEntry("db-type", "generic"));
+   //      params.add(new SimpleParameterEntry("multi-db", isMultiDb ? "true" : "false"));
+   //      params.add(new SimpleParameterEntry("update-storage", "true"));
+   //      params.add(new SimpleParameterEntry("max-buffer-size", "204800"));
+   //
+   //      if (dbDialect != null)
+   //      {
+   //         params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_DIALECT, dbDialect));
+   //      }
+   //      else if (entry.getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT) != null)
+   //      {
+   //         params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_DIALECT, entry
+   //            .getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT)));
+   //      }
+   //
+   //      String oldSwap = entry.getParameterValue("swap-directory");
+   //      String newSwap = oldSwap.substring(0, oldSwap.lastIndexOf('/')) + '/' + wsName;
+   //
+   //      params.add(new SimpleParameterEntry("swap-directory", newSwap));
+   //
+   //      ContainerEntry containerEntry =
+   //         new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
+   //            (ArrayList)params);
+   //      containerEntry.setParameters(params);
+   //
+   //      if (vsPath != null)
+   //      {
+   //
+   //         ArrayList<ValueStorageFilterEntry> vsparams = new ArrayList<ValueStorageFilterEntry>();
+   //         ValueStorageFilterEntry filterEntry = new ValueStorageFilterEntry();
+   //         filterEntry.setPropertyType("Binary");
+   //         vsparams.add(filterEntry);
+   //
+   //         ValueStorageEntry valueStorageEntry =
+   //            new ValueStorageEntry("org.exoplatform.services.jcr.impl.storage.value.fs.SimpleFileValueStorage", vsparams);
+   //         ArrayList<SimpleParameterEntry> spe = new ArrayList<SimpleParameterEntry>();
+   //         spe.add(new SimpleParameterEntry("path", vsPath));
+   //         valueStorageEntry.setId(IdGenerator.generate());
+   //         valueStorageEntry.setParameters(spe);
+   //         valueStorageEntry.setFilters(vsparams);
+   //
+   //         // containerEntry.setValueStorages();
+   //         containerEntry.setParameters(params);
+   //         ArrayList list = new ArrayList(1);
+   //         list.add(valueStorageEntry);
+   //
+   //         containerEntry.setValueStorages(list);
+   //
+   //      }
+   //
+   //      // Indexer
+   //      ArrayList qParams = new ArrayList();
+   //      qParams.add(new SimpleParameterEntry("indexDir", "../temp/index/" + IdGenerator.generate()));
+   //      QueryHandlerEntry qEntry =
+   //         new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
+   //
+   //      WorkspaceEntry workspaceEntry =
+   //         new WorkspaceEntry(wsName != null ? wsName : IdGenerator.generate(), "nt:unstructured");
+   //      workspaceEntry.setContainer(containerEntry);
+   //
+   //      ArrayList cacheParams = new ArrayList();
+   //
+   //      cacheParams.add(new SimpleParameterEntry("maxSize", "2000"));
+   //      cacheParams.add(new SimpleParameterEntry("liveTime", "20m"));
+   //      CacheEntry cacheEntry = new CacheEntry(cacheParams);
+   //      cacheEntry.setType("org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl");
+   //
+   //      workspaceEntry.setCache(cacheEntry);
+   //
+   //      workspaceEntry.setQueryHandler(qEntry);
+   //
+   //      LockManagerEntry lockManagerEntry = new LockManagerEntry();
+   //      lockManagerEntry.setTimeout(900000);
+   //      LockPersisterEntry persisterEntry = new LockPersisterEntry();
+   //      persisterEntry.setType("org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister");
+   //      ArrayList lpParams = new ArrayList();
+   //      lpParams.add(new SimpleParameterEntry("path", "../temp/lock"));
+   //      persisterEntry.setParameters(lpParams);
+   //      lockManagerEntry.setPersister(persisterEntry);
+   //      workspaceEntry.setLockManager(lockManagerEntry);
+   //
+   //      // workspaceEntry
+   //      return workspaceEntry;
+   //   }
+
+   private void createDatabase(DataSource ds, String dbName) throws SQLException
+   {
+      Connection connection = ds.getConnection();
+      PreparedStatement st = connection.prepareStatement("create database " + dbName);
+      st.executeQuery();
+   }
+
+   public static TesterConfigurationHelper getInstence()
+   {
+      if (instence == null)
+      {
+         instence = new TesterConfigurationHelper();
+      }
+
+      return instence;
+   }
+}

Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml	2010-12-06 14:25:34 UTC (rev 3602)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml	2010-12-06 14:34:57 UTC (rev 3603)
@@ -39,7 +39,7 @@
                   <value-storages>
                      <value-storage id="draft" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
                         <properties>
-                           <property name="path" value="target/temp/values/backup" />
+                           <property name="path" value="target/temp/values/db1_ws" />
                         </properties>
                         <filters>
                            <filter property-type="Binary" />



More information about the exo-jcr-commits mailing list