[exo-jcr-commits] exo-jcr SVN: r505 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Nov 9 06:37:43 EST 2009


Author: skabashnyuk
Date: 2009-11-09 06:37:43 -0500 (Mon, 09 Nov 2009)
New Revision: 505

Added:
   jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
   jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
Log:
EXOJCR-202 : base cache loader test

Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java	                        (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java	2009-11-09 11:37:43 UTC (rev 505)
@@ -0,0 +1,98 @@
+/*
+ * 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.storage.jbosscache;
+
+import junit.framework.TestCase;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:Sergey.Kabashnyuk at exoplatform.org">Sergey Kabashnyuk</a>
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
+ *
+ */
+public abstract class AbstractCacheLoaderTest extends TestCase
+{
+   protected Cache<Serializable, Object> cache;
+
+   protected JBossCacheStorageConnection jBossCacheStorageConnection;
+
+   /**
+    * @see junit.framework.TestCase#setUp()
+    */
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
+      cache = factory.createCache(createCacheConfiguration());
+
+      Node<Serializable, Object> cacheRoot = cache.getRoot();
+
+      // run cache
+      cache.create();
+      cache.start();
+      cache.startBatch();
+      // prepare cache structures
+      Node<Serializable, Object> nodes = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.NODES));
+      Node<Serializable, Object> props = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.PROPS));
+
+      this.cache.endBatch(true);
+
+      // JCR connection
+      jBossCacheStorageConnection = new JBossCacheStorageConnection(cache, nodes, props);
+   }
+
+   /**
+    * Create cache configuration.
+    * @return
+    */
+   protected Configuration createCacheConfiguration()
+   {
+      Configuration config = new Configuration();
+      config.setInvocationBatchingEnabled(true);
+      config.setCacheLoaderConfig(createCacheLoaderConfig());
+      return config;
+   }
+
+   /**
+    * Create cache configuration.
+    * @return
+    */
+   protected CacheLoaderConfig createCacheLoaderConfig()
+   {
+      CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
+      cacheLoaderConfig.setPassivation(false);
+      cacheLoaderConfig.setShared(false);
+      cacheLoaderConfig.addIndividualCacheLoaderConfig(createIndividualCacheLoaderConfig());
+      return cacheLoaderConfig;
+   };
+
+   protected abstract IndividualCacheLoaderConfig createIndividualCacheLoaderConfig();
+
+}


Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java	                        (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java	2009-11-09 11:37:43 UTC (rev 505)
@@ -0,0 +1,74 @@
+/*
+ * 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.storage.jbosscache;
+
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Modification;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:Sergey.Kabashnyuk at exoplatform.org">Sergey Kabashnyuk</a>
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
+ *
+ */
+public class IndexerCacheLoaderTest extends AbstractCacheLoaderTest
+{
+   private final Log log = ExoLogger.getLogger(IndexerCacheLoaderTest.class.getName());
+
+   public void testAddRoot() throws Exception
+   {
+      // add root (/)
+      jBossCacheStorageConnection.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
+         Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, null, new AccessControlList()));
+      jBossCacheStorageConnection.commit();
+   }
+
+   /**
+    * @see org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractCacheLoaderTest#createIndividualCacheLoaderConfig()
+    */
+   @Override
+   protected IndividualCacheLoaderConfig createIndividualCacheLoaderConfig()
+   {
+      IndividualCacheLoaderConfig individualCacheLoaderConfig = new IndividualCacheLoaderConfig();
+      individualCacheLoaderConfig.setCacheLoader(new DummyCacheLoader());
+      return individualCacheLoaderConfig;
+   }
+
+   private class DummyCacheLoader extends AbstractWriteOnlyCacheLoader
+   {
+
+      /**
+       * @see org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader#put(java.util.List)
+       */
+      @Override
+      public void put(List<Modification> modifications) throws Exception
+      {
+         log.info("put:" + modifications);
+
+      }
+
+   }
+}


Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the exo-jcr-commits mailing list