[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/loader ...

Manik Surtani msurtani at jboss.com
Tue Sep 19 09:52:33 EDT 2006


  User: msurtani
  Date: 06/09/19 09:52:33

  Modified:    tests/functional/org/jboss/cache/loader  
                        AbstractCacheLoaderTestBase.java
                        DummyInMemoryCacheLoader.java
  Log:
  Fixed moving with cache loaders
  
  Revision  Changes    Path
  1.9       +36 -27    JBossCache/tests/functional/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AbstractCacheLoaderTestBase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- AbstractCacheLoaderTestBase.java	30 May 2006 18:40:25 -0000	1.8
  +++ AbstractCacheLoaderTestBase.java	19 Sep 2006 13:52:33 -0000	1.9
  @@ -7,11 +7,10 @@
   package org.jboss.cache.loader;
   
   import junit.framework.TestCase;
  -import org.w3c.dom.Element;
  -import org.jboss.cache.xml.XmlHelper;
  -
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.jboss.cache.xml.XmlHelper;
  +import org.w3c.dom.Element;
   
   /**
    * Very basic test case that provides methods to create a cache loader config.
  @@ -23,17 +22,22 @@
   
      protected final Log log = LogFactory.getLog(getClass());
   
  -   public AbstractCacheLoaderTestBase(String name) {
  +   public AbstractCacheLoaderTestBase(String name)
  +   {
         super(name);
      }
   
  -   public AbstractCacheLoaderTestBase() {}
  +   public AbstractCacheLoaderTestBase()
  +   {
  +   }
   
  -   protected void setUp() throws Exception {
  +   protected void setUp() throws Exception
  +   {
         log.debug("");
         log.debug("test " + getName());
      }
   
  +
       protected Element getSingleCacheLoaderConfig(String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean shared) throws Exception
       {
           return getSingleCacheLoaderConfig(preload, cacheloaderClass, properties, async, fetchPersistentState, shared, false);
  @@ -41,8 +45,13 @@
   
       protected Element getSingleCacheLoaderConfig(String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception
       {
  +      return getSingleCacheLoaderConfig(false, preload, cacheloaderClass, properties, async, fetchPersistentState, shared, false);
  +   }
  +
  +   protected Element getSingleCacheLoaderConfig(boolean passivation, String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception
  +   {
           String xml = "<config>\n" +
  -                "<passivation>false</passivation>\n" +
  +                   "<passivation>" + passivation + "</passivation>\n" +
                   "<preload>" + preload + "</preload>\n" +
                   "<cacheloader>\n" +
                   "<class>" + cacheloaderClass + "</class>\n" +
  
  
  
  1.2       +62 -9     JBossCache/tests/functional/org/jboss/cache/loader/DummyInMemoryCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DummyInMemoryCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/DummyInMemoryCacheLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- DummyInMemoryCacheLoader.java	16 Sep 2006 00:23:35 -0000	1.1
  +++ DummyInMemoryCacheLoader.java	19 Sep 2006 13:52:33 -0000	1.2
  @@ -6,10 +6,13 @@
    */
   package org.jboss.cache.loader;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.Modification;
   
   import java.util.HashMap;
  +import java.util.HashSet;
   import java.util.List;
   import java.util.Map;
   import java.util.Properties;
  @@ -23,6 +26,7 @@
   public class DummyInMemoryCacheLoader extends AbstractCacheLoader
   {
      private Map<Fqn, Node> nodes = new HashMap<Fqn, Node>();
  +   private Log log = LogFactory.getLog(DummyInMemoryCacheLoader.class);
   
      public void setConfig(Properties properties)
      {
  @@ -30,12 +34,36 @@
   
      public Set getChildrenNames(Fqn fqn) throws Exception
      {
  -      return nodes.get(fqn).children.keySet();
  +      log.debug("Calling getChildrenNames on Fqn " + fqn);
  +      if (!nodes.containsKey(fqn))
  +      {
  +         log.debug("node not in loader");
  +         return null;
  +      }
  +
  +      Set children = findChildren(fqn);
  +      log.debug("Fqn " + fqn + " has children " + children);
  +      return children;
  +   }
  +
  +   private Set findChildren(Fqn p)
  +   {
  +      Set c = new HashSet();
  +      for (Fqn f : nodes.keySet())
  +      {
  +         if (f.getParent().equals(p))
  +         {
  +            c.add(f.getName());
  +         }
  +      }
  +      return c;
      }
   
      public Map get(Fqn name) throws Exception
      {
  -      return nodes.get(name).data;
  +      Map d = nodes.containsKey(name) ? nodes.get(name).data : null;
  +      log.debug("Getting data for fqn " + name + " = " + d);
  +      return d;
      }
   
      public boolean exists(Fqn name) throws Exception
  @@ -46,25 +74,33 @@
      public Object put(Fqn name, Object key, Object value) throws Exception
      {
         Node n = nodes.get(name);
  -      if (n == null) n = new Node();
  +      if (n == null)
  +      {
  +         n = new Node();
         n.fqn = name;
  +      }
         Object old = n.data.put(key, value);
         nodes.put(name, n);
  +      log.debug("Did a put on " + name + ", data is " + n.data);
         return old;
      }
   
      public void put(Fqn name, Map attributes) throws Exception
      {
         Node n = nodes.get(name);
  -      if (n == null) n = new Node();
  +      if (n == null)
  +      {
  +         n = new Node();
         n.fqn = name;
  +      }
         n.data.putAll(attributes);
         nodes.put(name, n);
  -
  +      log.debug("Did a put on " + name + ", data is " + n.data);
      }
   
      public Object remove(Fqn fqn, Object key) throws Exception
      {
  +      log.debug("Removing data from " + fqn);
         Node n = nodes.get(fqn);
         if (n == null) n = new Node();
         n.fqn = fqn;
  @@ -75,11 +111,13 @@
   
      public void remove(Fqn fqn) throws Exception
      {
  -      nodes.remove(fqn);
  +      log.debug("Removing fqn " + fqn);
  +      Node n = nodes.remove(fqn);
      }
   
      public void removeData(Fqn fqn) throws Exception
      {
  +      log.debug("Removing data from " + fqn);
         Node n = nodes.get(fqn);
         if (n == null) n = new Node();
         n.fqn = fqn;
  @@ -87,6 +125,7 @@
         nodes.put(fqn, n);
      }
   
  +
      public void prepare(Object tx, List<Modification> modifications, boolean one_phase) throws Exception
      {
      }
  @@ -119,9 +158,23 @@
      public class Node
      {
         Map data = new HashMap();
  -      Map children = new HashMap();
         Fqn fqn;
  +
  +
  +      public String toString()
  +      {
  +         return "Node{" +
  +                "data=" + data +
  +                ", fqn=" + fqn +
  +                '}';
  +      }
      }
   
   
  +   public String toString()
  +   {
  +      return "DummyInMemoryCacheLoader{" +
  +             "nodes=" + nodes +
  +             '}';
  +   }
   }
  
  
  



More information about the jboss-cvs-commits mailing list