[jbosscache-commits] JBoss Cache SVN: r7689 - in core/tags/3.0.3.CR1/src: main/java/org/jboss/cache/interceptors and 2 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Feb 13 10:21:46 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-02-13 10:21:46 -0500 (Fri, 13 Feb 2009)
New Revision: 7689

Modified:
   core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/DataContainer.java
   core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/DataContainerImpl.java
   core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/UnversionedNode.java
   core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
   core/tags/3.0.3.CR1/src/test/java/org/jboss/cache/DataContainerTest.java
   core/tags/3.0.3.CR1/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
Log:
JBCACHE-1478 Handle querying node count in an unstarted data container

Modified: core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/DataContainer.java
===================================================================
--- core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/DataContainer.java	2009-02-13 14:53:17 UTC (rev 7688)
+++ core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/DataContainer.java	2009-02-13 15:21:46 UTC (rev 7689)
@@ -33,8 +33,7 @@
  * @see DataContainerImpl
  * @since 2.2
  */
-public interface DataContainer
-{
+public interface DataContainer {
    /**
     * Retrieves the root node.
     *
@@ -57,7 +56,8 @@
     *
     * @param fqn Fully qualified name for the corresponding node.
     * @return Node referenced by the given Fqn, or null if the node cannot be found or if there is an exception.
-    * @deprecated Note that this only supports legacy locking schemes (OL and PL) and will be removed when those schemes are removed.
+    * @deprecated Note that this only supports legacy locking schemes (OL and PL) and will be removed when those schemes
+    *             are removed.
     */
    @Deprecated
    NodeSPI peek(Fqn fqn);
@@ -68,20 +68,22 @@
     * @param fqn                 Fqn to find
     * @param includeDeletedNodes if true, deleted nodes are considered
     * @return the node, if found, or null otherwise.
-    * @deprecated Note that this only supports legacy locking schemes (OL and PL) and will be removed when those schemes are removed.
+    * @deprecated Note that this only supports legacy locking schemes (OL and PL) and will be removed when those schemes
+    *             are removed.
     */
    @Deprecated
    NodeSPI peek(Fqn fqn, boolean includeDeletedNodes);
 
    /**
-    * Peeks for a specified node.  This involves a direct walk of the tree, starting at the root, until the required node
-    * is found.  If the node is not found, a null is returned.
+    * Peeks for a specified node.  This involves a direct walk of the tree, starting at the root, until the required
+    * node is found.  If the node is not found, a null is returned.
     *
     * @param fqn                 Fqn of the node to find
     * @param includeDeletedNodes if true, deleted nodes are also considered
     * @param includeInvalidNodes if true, invalid nodes are also considered
     * @return the node, if found, or null otherwise.
-    * @deprecated Note that this only supports legacy locking schemes (OL and PL) and will be removed when those schemes are removed.
+    * @deprecated Note that this only supports legacy locking schemes (OL and PL) and will be removed when those schemes
+    *             are removed.
     */
    @Deprecated
    NodeSPI peek(Fqn fqn, boolean includeDeletedNodes, boolean includeInvalidNodes);
@@ -107,7 +109,8 @@
     *
     * @param list    List of NodeData objects, which will be added to.
     * @param node    node to recursively add to the list
-    * @param mapSafe if true, the node's data map reference is passed to the NodeData instance created.  Otherwise, the map is copied.
+    * @param mapSafe if true, the node's data map reference is passed to the NodeData instance created.  Otherwise, the
+    *                map is copied.
     * @return the same list passed in
     */
    List<NodeData> buildNodeData(List<NodeData> list, NodeSPI node, boolean mapSafe);
@@ -123,10 +126,9 @@
    List<Fqn> getNodesForEviction(Fqn fqn, boolean recursive);
 
    /**
-    * Returns a Set<Fqn> of Fqns of the topmost node of internal regions that
-    * should not included in standard state transfers. Will include
-    * {@link org.jboss.cache.buddyreplication.BuddyManager#BUDDY_BACKUP_SUBTREE} if buddy replication is
-    * enabled.
+    * Returns a Set<Fqn> of Fqns of the topmost node of internal regions that should not included in standard state
+    * transfers. Will include {@link org.jboss.cache.buddyreplication.BuddyManager#BUDDY_BACKUP_SUBTREE} if buddy
+    * replication is enabled.
     *
     * @return an unmodifiable Set<Fqn>.  Will not return <code>null</code>.
     */
@@ -138,23 +140,21 @@
    int getNumberOfLocksHeld();
 
    /**
-    * Returns an <em>approximation</em> of the total number of nodes in the
-    * cache. Since this method doesn't acquire any locks, the number might be
-    * incorrect, or the method might even throw a
-    * ConcurrentModificationException
+    * Returns an <em>approximation</em> of the total number of nodes in the cache. Since this method doesn't acquire any
+    * locks, the number might be incorrect, or the method might even throw a ConcurrentModificationException
     */
    int getNumberOfNodes();
 
+   String getNumberOfNodesString();
+
    /**
-    * Returns an <em>approximation</em> of the total number of attributes in
-    * this sub cache.
+    * Returns an <em>approximation</em> of the total number of attributes in this sub cache.
     */
    int getNumberOfAttributes(Fqn fqn);
 
    /**
-    * Returns an <em>approximation</em> of the total number of attributes in
-    * the cache. Since this method doesn't acquire any locks, the number might
-    * be incorrect, or the method might even throw a
+    * Returns an <em>approximation</em> of the total number of attributes in the cache. Since this method doesn't
+    * acquire any locks, the number might be incorrect, or the method might even throw a
     * ConcurrentModificationException
     *
     * @return number of attribs
@@ -165,7 +165,8 @@
     * Removes the actual node from the tree data structure.
     *
     * @param f               the Fqn of the node to remove
-    * @param skipMarkerCheck if true, skips checking the boolean {@link org.jboss.cache.NodeSPI#isDeleted()} flag and deletes the node anyway.
+    * @param skipMarkerCheck if true, skips checking the boolean {@link org.jboss.cache.NodeSPI#isDeleted()} flag and
+    *                        deletes the node anyway.
     * @return Returns true if the node was found and removed, false if not.
     */
    boolean removeFromDataStructure(Fqn f, boolean skipMarkerCheck);
@@ -178,25 +179,24 @@
    /**
     * <pre>
     * Following scenarios define how eviction works.
-    * 1. If the given node is a leaf then it is entirely removed from the data structure. The node is marked as invalid.</li>
+    * 1. If the given node is a leaf then it is entirely removed from the data structure. The node is marked as
+    * invalid.</li>
     * 2. If the given node is a leaf then only the data map is cleared.
     * 3. If the given node is the root node then the cildren nodes are evicted. For each child node 1. or 2. applies
     * </pre>
     *
-    * @return true if the FQN is leaf and was removed; false if is an intermediate FQN and only contained data
-    *         is droped.
+    * @return true if the FQN is leaf and was removed; false if is an intermediate FQN and only contained data is
+    *         droped.
     */
    boolean evict(Fqn fqn); // TODO: See if this is still needed here
 
    /**
-    * Traverses the tree to the given Fqn, creating nodes if needed.  Returns a list of nodes created, as well as a reference to the last node.
+    * Traverses the tree to the given Fqn, creating nodes if needed.  Returns a list of nodes created, as well as a
+    * reference to the last node.
     * <p/>
-    * E.g.,
-    * <code>
-    * Object[] results = createNode(myFqn);
-    * results[0] // this is a List&lt;NodeSPI&gt; of nodes <i>created</i> in getting to the target node.
-    * results[1] // is a NodeSPI reference to the target node, regardless of whether it was <i>created</i> or just <i>found</i>.
-    * </code>
+    * E.g., <code> Object[] results = createNode(myFqn); results[0] // this is a List&lt;NodeSPI&gt; of nodes
+    * <i>created</i> in getting to the target node. results[1] // is a NodeSPI reference to the target node, regardless
+    * of whether it was <i>created</i> or just <i>found</i>. </code>
     *
     * @param fqn fqn to find
     * @return see above.
@@ -204,7 +204,8 @@
    Object[] createNodes(Fqn fqn);
 
    /**
-    * Similar to {@link #peek(Fqn)} except that the underlying node is NOT wrapped as a {@link org.jboss.cache.NodeSPI}.
+    * Similar to {@link #peek(Fqn)} except that the underlying node is NOT wrapped as a {@link
+    * org.jboss.cache.NodeSPI}.
     *
     * @param f                   fqn to peek
     * @param includeInvalidNodes if true, invalid nodes will be considered as well.
@@ -217,7 +218,8 @@
     *
     * @param fqn                 fqn to find
     * @param includeInvalidNodes if true, invalid nodes are considered.
-    * @return an array of InternalNodes, containing 2 elements.  Element [0] is the node being peeked, and element [1] is its direct parent.
+    * @return an array of InternalNodes, containing 2 elements.  Element [0] is the node being peeked, and element [1]
+    *         is its direct parent.
     */
    public InternalNode[] peekInternalNodeAndDirectParent(Fqn fqn, boolean includeInvalidNodes);
 

Modified: core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/DataContainerImpl.java	2009-02-13 14:53:17 UTC (rev 7688)
+++ core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/DataContainerImpl.java	2009-02-13 15:21:46 UTC (rev 7689)
@@ -44,15 +44,15 @@
 import java.util.Set;
 
 /**
- * A container for the root node in the cache, which also provides helpers for efficiently accessing nodes, walking trees, etc.
+ * A container for the root node in the cache, which also provides helpers for efficiently accessing nodes, walking
+ * trees, etc.
  *
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
 @NonVolatile
 @MBean(objectName = "DataContainer", description = "Core container for all cached items")
-public class DataContainerImpl implements DataContainer
-{
+public class DataContainerImpl implements DataContainer {
    private static final Log log = LogFactory.getLog(DataContainerImpl.class);
    private static boolean trace = log.isTraceEnabled();
 
@@ -63,8 +63,7 @@
    private volatile InternalNode rootInternal;
 
    /**
-    * Set<Fqn> of Fqns of the topmost node of internal regions that should
-    * not included in standard state transfers.
+    * Set<Fqn> of Fqns of the topmost node of internal regions that should not included in standard state transfers.
     */
    private final Set<Fqn> internalFqns = new HashSet<Fqn>();
    private NodeFactory nodeFactory;
@@ -73,10 +72,10 @@
    private Configuration config;
    private boolean usingMvcc;
    private static final InternalNode[] NULL_ARRAY = {null, null};
+   volatile boolean started = false;
 
    @Inject
-   public void injectDependencies(NodeFactory nodeFactory, LockManager lockManager, BuddyFqnTransformer transformer, Configuration configuration)
-   {
+   public void injectDependencies(NodeFactory nodeFactory, LockManager lockManager, BuddyFqnTransformer transformer, Configuration configuration) {
       setDependencies(nodeFactory, lockManager);
 
       // We need to create a root node even at this stage since certain components rely on this being available before
@@ -88,15 +87,13 @@
       config = configuration;
    }
 
-   public void setDependencies(NodeFactory nodeFactory, LockManager lockManager)
-   {
+   public void setDependencies(NodeFactory nodeFactory, LockManager lockManager) {
       this.nodeFactory = nodeFactory;
       this.lockManager = lockManager;
    }
 
    @Start(priority = 12)
-   public void createRootNode()
-   {
+   public void createRootNode() {
       usingMvcc = config != null && config.getNodeLockingScheme() == NodeLockingScheme.MVCC;
       if (trace) log.trace("Starting data container.  Using MVCC? " + usingMvcc);
       // create a new root temporarily.
@@ -107,34 +104,30 @@
       Class currentRootType = root == null ? null : root.getDelegationTarget().getClass();
       Class tempRootType = tempRoot.getDelegationTarget().getClass();
 
-      if (!tempRootType.equals(currentRootType))
-      {
+      if (!tempRootType.equals(currentRootType)) {
          if (trace) log.trace("Setting root node to an instance of " + tempRootType);
          setRoot(tempRoot);
       }
 
       if (usingMvcc && rootInternal == null) setRoot(root); // sets the "internal root"
+      started = true;
    }
 
    @Stop(priority = 100)
-   public void stop()
-   {
+   public void stop() {
+      started = false;
       // empty in-memory state
-      if (root != null)
-      {
+      if (root != null) {
          root.clearDataDirect();
          root.removeChildrenDirect();
-      }
-      else if (rootInternal != null)
-      {
+      } else if (rootInternal != null) {
          rootInternal.clear();
          rootInternal.removeChildren();
       }
    }
 
    @Deprecated
-   public NodeSPI getRoot()
-   {
+   public NodeSPI getRoot() {
       return root;
    }
 
@@ -143,21 +136,16 @@
     *
     * @param root node
     */
-   public void setRoot(Object root)
-   {
+   public void setRoot(Object root) {
       if (root == null) throw new CacheException("Attempting to set a null node as a root node!");
       // Mega-Ugh!
-      if (usingMvcc && root instanceof InternalNode)
-      {
+      if (usingMvcc && root instanceof InternalNode) {
          if (log.isDebugEnabled()) log.debug("Setting rootInternal to " + root);
          rootInternal = (InternalNode) root;
          this.root = null;
-      }
-      else
-      {
+      } else {
          this.root = (NodeSPI) root;
-         if (usingMvcc)
-         {
+         if (usingMvcc) {
             if (log.isDebugEnabled()) log.debug("Setting rootInternal to " + this.root.getDelegationTarget());
             rootInternal = this.root.getDelegationTarget();
             this.root = null;
@@ -165,174 +153,126 @@
       }
    }
 
-   public boolean isResident(Fqn fqn)
-   {
-      if (usingMvcc)
-      {
+   public boolean isResident(Fqn fqn) {
+      if (usingMvcc) {
          InternalNode in = peekInternalNode(fqn, false);
          return in != null && in.isResident();
-      }
-      else
-      {
+      } else {
          NodeSPI<?, ?> nodeSPI = peek(fqn, false, false);
          return nodeSPI != null && nodeSPI.isResident();
       }
    }
 
-   public void registerInternalFqn(Fqn fqn)
-   {
+   public void registerInternalFqn(Fqn fqn) {
       internalFqns.add(fqn);
    }
 
-   public NodeSPI peek(Fqn fqn)
-   {
+   public NodeSPI peek(Fqn fqn) {
       return peek(fqn, false, false);
    }
 
-   public NodeSPI peek(Fqn fqn, boolean includeDeletedNodes)
-   {
+   public NodeSPI peek(Fqn fqn, boolean includeDeletedNodes) {
       return peek(fqn, includeDeletedNodes, false);
    }
 
-   public NodeSPI peek(Fqn fqn, boolean includeDeletedNodes, boolean includeInvalidNodes)
-   {
-      if (trace)
-      {
+   public NodeSPI peek(Fqn fqn, boolean includeDeletedNodes, boolean includeInvalidNodes) {
+      if (trace) {
          log.trace("peek " + fqn + ", includeDeletedNodes:" + includeDeletedNodes + ", includeInvalidNodes:" + includeInvalidNodes);
       }
       if (fqn == null || fqn.size() == 0) return getRoot();
       NodeSPI n = getRoot();
       int fqnSize = fqn.size();
-      for (int i = 0; i < fqnSize; i++)
-      {
+      for (int i = 0; i < fqnSize; i++) {
          Object obj = fqn.get(i);
          n = n.getChildDirect(obj);
-         if (n == null)
-         {
+         if (n == null) {
             return null;
-         }
-         else if (!includeDeletedNodes && n.isDeleted())
-         {
+         } else if (!includeDeletedNodes && n.isDeleted()) {
             return null;
-         }
-         else if (!includeInvalidNodes && !n.isValid())
-         {
+         } else if (!includeInvalidNodes && !n.isValid()) {
             return null;
          }
       }
       return n;
    }
 
-   public boolean exists(Fqn fqn)
-   {
+   public boolean exists(Fqn fqn) {
       return usingMvcc ? peekInternalNode(fqn, false) != null : peek(fqn, false, false) != null;
    }
 
-   public boolean hasChildren(Fqn fqn)
-   {
+   public boolean hasChildren(Fqn fqn) {
       if (fqn == null) return false;
 
-      if (usingMvcc)
-      {
+      if (usingMvcc) {
          InternalNode in = peekInternalNode(fqn, false);
          return in != null && in.hasChildren();
-      }
-      else
-      {
+      } else {
          NodeSPI n = peek(fqn);
          return n != null && n.hasChildrenDirect();
       }
    }
 
-   public List<NodeData> buildNodeData(List<NodeData> list, NodeSPI node, boolean mapSafe)
-   {
-      if (usingMvcc)
-      {
+   public List<NodeData> buildNodeData(List<NodeData> list, NodeSPI node, boolean mapSafe) {
+      if (usingMvcc) {
          return buildNodeData(list, node.getDelegationTarget(), node.getData(), mapSafe);
-      }
-      else
-      {
+      } else {
          return buildNodeDataLegacy(list, node, mapSafe);
       }
    }
 
-   private List<NodeData> buildNodeData(List<NodeData> list, InternalNode<?, ?> node, Map dataInNode, boolean mapSafe)
-   {
+   private List<NodeData> buildNodeData(List<NodeData> list, InternalNode<?, ?> node, Map dataInNode, boolean mapSafe) {
       NodeData data = new NodeData(buddyFqnTransformer.getActualFqn(node.getFqn()), dataInNode, mapSafe);
       list.add(data);
-      for (InternalNode childNode : node.getChildrenMap().values())
-      {
+      for (InternalNode childNode : node.getChildrenMap().values()) {
          buildNodeData(list, childNode, childNode.getData(), true);
       }
       return list;
    }
 
    @Deprecated
-   private List<NodeData> buildNodeDataLegacy(List<NodeData> list, NodeSPI node, boolean mapSafe)
-   {
+   private List<NodeData> buildNodeDataLegacy(List<NodeData> list, NodeSPI node, boolean mapSafe) {
       NodeData data = new NodeData(buddyFqnTransformer.getActualFqn(node.getFqn()), node.getDataDirect(), mapSafe);
       list.add(data);
-      for (Object childNode : node.getChildrenDirect())
-      {
+      for (Object childNode : node.getChildrenDirect()) {
          buildNodeData(list, (NodeSPI) childNode, true);
       }
       return list;
    }
 
-   public List<Fqn> getNodesForEviction(Fqn fqn, boolean recursive)
-   {
+   public List<Fqn> getNodesForEviction(Fqn fqn, boolean recursive) {
       List<Fqn> result = new ArrayList<Fqn>();
-      if (usingMvcc)
-      {
+      if (usingMvcc) {
          InternalNode node = peekInternalNode(fqn, false);
-         if (recursive)
-         {
+         if (recursive) {
             if (node != null) recursiveAddEvictionNodes(node, result);
-         }
-         else
-         {
-            if (node == null)
-            {
+         } else {
+            if (node == null) {
                result.add(fqn);
                return result;
             }
-            if (fqn.isRoot())
-            {
-               for (Object childName : node.getChildrenNames())
-               {
+            if (fqn.isRoot()) {
+               for (Object childName : node.getChildrenNames()) {
                   if (!node.isResident()) result.add(Fqn.fromRelativeElements(fqn, childName));
                }
-            }
-            else if (!node.isResident())
-            {
+            } else if (!node.isResident()) {
                result.add(fqn);
             }
          }
          return result;
-      }
-      else
-      {
+      } else {
          NodeSPI node = peek(fqn, false);
-         if (recursive)
-         {
+         if (recursive) {
             if (node != null) recursiveAddEvictionNodes(node, result);
-         }
-         else
-         {
-            if (node == null)
-            {
+         } else {
+            if (node == null) {
                result.add(fqn);
                return result;
             }
-            if (fqn.isRoot())
-            {
-               for (Object childName : node.getChildrenNamesDirect())
-               {
+            if (fqn.isRoot()) {
+               for (Object childName : node.getChildrenNamesDirect()) {
                   if (!node.isResident()) result.add(Fqn.fromRelativeElements(fqn, childName));
                }
-            }
-            else if (!node.isResident())
-            {
+            } else if (!node.isResident()) {
                result.add(fqn);
             }
          }
@@ -340,40 +280,32 @@
       }
    }
 
-   private void recursiveAddEvictionNodes(NodeSPI<?, ?> node, List<Fqn> result)
-   {
-      for (NodeSPI<?, ?> child : node.getChildrenDirect())
-      {
+   private void recursiveAddEvictionNodes(NodeSPI<?, ?> node, List<Fqn> result) {
+      for (NodeSPI<?, ?> child : node.getChildrenDirect()) {
          recursiveAddEvictionNodes(child, result);
       }
       Fqn fqn = node.getFqn();
-      if (!fqn.isRoot() && !node.isResident())
-      {
+      if (!fqn.isRoot() && !node.isResident()) {
          result.add(fqn);
       }
    }
 
-   private void recursiveAddEvictionNodes(InternalNode<?, ?> node, List<Fqn> result)
-   {
-      for (InternalNode child : node.getChildren())
-      {
+   private void recursiveAddEvictionNodes(InternalNode<?, ?> node, List<Fqn> result) {
+      for (InternalNode child : node.getChildren()) {
          recursiveAddEvictionNodes(child, result);
       }
       Fqn fqn = node.getFqn();
-      if (!fqn.isRoot() && !node.isResident())
-      {
+      if (!fqn.isRoot() && !node.isResident()) {
          result.add(fqn);
       }
    }
 
    @Override
-   public String toString()
-   {
+   public String toString() {
       return toString(false);
    }
 
-   public Set<Fqn> getInternalFqns()
-   {
+   public Set<Fqn> getInternalFqns() {
       return Collections.unmodifiableSet(internalFqns);
    }
 
@@ -384,24 +316,18 @@
     * @return detailed contents of the container
     */
    @SuppressWarnings("deprecation")
-   public String toString(boolean details)
-   {
+   public String toString(boolean details) {
       StringBuilder sb = new StringBuilder();
       int indent = 0;
 
-      if (!details)
-      {
-         sb.append(getClass().getName()).append(" [").append(getNumberOfNodes()).append(" nodes, ");
+      if (!details) {
+         sb.append(getClass().getName()).append(" [").append(getNumberOfNodesString()).append(", ");
          sb.append(getNumberOfLocksHeld()).append(" locks]");
-      }
-      else
-      {
-         if (root == null)
-         {
+      } else {
+         if (root == null) {
             return sb.toString();
          }
-         for (Object n : root.getChildrenDirect())
-         {
+         for (Object n : root.getChildrenDirect()) {
             ((NodeSPI) n).print(sb, indent);
             sb.append("\n");
          }
@@ -409,23 +335,18 @@
       return sb.toString();
    }
 
-   public int getNumberOfLocksHeld()
-   {
+   public int getNumberOfLocksHeld() {
       return numLocks(root);
    }
 
-   private int numLocks(NodeSPI n)
-   {
+   private int numLocks(NodeSPI n) {
       int num = 0;
-      if (n != null)
-      {
-         if (lockManager.isLocked(n))
-         {
+      if (n != null) {
+         if (lockManager.isLocked(n)) {
             num++;
             if (trace) log.trace(n.getFqn() + " locked");
          }
-         for (Object cn : n.getChildrenDirect(true))
-         {
+         for (Object cn : n.getChildrenDirect(true)) {
             num += numLocks((NodeSPI) cn);
          }
       }
@@ -433,33 +354,34 @@
    }
 
    @ManagedOperation(description = "Returns the number of nodes in the data container")
-   public int getNumberOfNodes()
-   {
+   public int getNumberOfNodes() {
+      if (!started) return -1;
       if (!usingMvcc) return numNodes(root) - 1;
       return numNodesMvcc(rootInternal) - 1;
    }
 
-   private int numNodesMvcc(InternalNode node)
-   {
+   @ManagedOperation(description = "Returns the number of nodes in the data container")
+   public String getNumberOfNodesString() {
+      int nON = getNumberOfNodes();
+      if (nON < 0) return "(Cache not started)";
+      return nON + " nodes";
+   }
+
+   private int numNodesMvcc(InternalNode node) {
       int count = 1; //for 'node'
-      if (node != null)
-      {
+      if (node != null) {
          Set<InternalNode> children = node.getChildren();
-         for (InternalNode child : children)
-         {
-            count += numNodesMvcc((InternalNode) child);
+         for (InternalNode child : children) {
+            count += numNodesMvcc(child);
          }
       }
       return count;
    }
 
-   private int numNodes(NodeSPI n)
-   {
+   private int numNodes(NodeSPI n) {
       int count = 1;// for n
-      if (n != null)
-      {
-         for (Object child : n.getChildrenDirect())
-         {
+      if (n != null) {
+         for (Object child : n.getChildrenDirect()) {
             count += numNodes((NodeSPI) child);
          }
       }
@@ -467,22 +389,17 @@
    }
 
    /**
-    * Prints information about the contents of the nodes in the cache's current
-    * in-memory state.  Does not load any previously evicted nodes from a
-    * cache loader, so evicted nodes will not be included.
+    * Prints information about the contents of the nodes in the cache's current in-memory state.  Does not load any
+    * previously evicted nodes from a cache loader, so evicted nodes will not be included.
     *
     * @return details
     */
    @ManagedOperation(description = "Prints details of the data container")
-   public String printDetails()
-   {
+   public String printDetails() {
       StringBuilder sb = new StringBuilder();
-      if (root == null)
-      {
+      if (root == null) {
          rootInternal.printDetails(sb, 0);
-      }
-      else
-      {
+      } else {
          root.printDetails(sb, 0);
       }
       sb.append("\n");
@@ -490,8 +407,7 @@
    }
 
    @ManagedOperation(description = "Prints details of the data container, formatted as an HTML String")
-   public String printDetailsAsHtml()
-   {
+   public String printDetailsAsHtml() {
       return CachePrinter.formatHtml(printDetails());
    }
 
@@ -501,43 +417,35 @@
     *
     * @return lock info
     */
-   public String printLockInfo()
-   {
+   public String printLockInfo() {
       return lockManager.printLockInfo(root);
    }
 
-   public int getNumberOfAttributes(Fqn fqn)
-   {
+   public int getNumberOfAttributes(Fqn fqn) {
       return usingMvcc ? numAttributes(peekInternalNode(fqn, false)) : numAttributes(peek(fqn));
    }
 
-   private int numAttributes(NodeSPI n)
-   {
+   private int numAttributes(NodeSPI n) {
       int count = 0;
-      for (Object child : n.getChildrenDirect())
-      {
+      for (Object child : n.getChildrenDirect()) {
          count += numAttributes((NodeSPI) child);
       }
       count += n.getDataDirect().size();
       return count;
    }
 
-   private int numAttributesMvcc(InternalNode n)
-   {
+   private int numAttributesMvcc(InternalNode n) {
       int count = 0;
-      for (Object child : n.getChildren())
-      {
+      for (Object child : n.getChildren()) {
          count += numAttributesMvcc((InternalNode) child);
       }
       count += n.getData().size();
       return count;
    }
 
-   private int numAttributes(InternalNode n)
-   {
+   private int numAttributes(InternalNode n) {
       int count = 0;
-      for (Object child : n.getChildren())
-      {
+      for (Object child : n.getChildren()) {
          count += numAttributes((NodeSPI) child);
       }
       count += n.getData().size();
@@ -545,29 +453,23 @@
    }
 
    @ManagedOperation(description = "Returns the number of attributes in all nodes in the data container")
-   public int getNumberOfAttributes()
-   {
+   public int getNumberOfAttributes() {
       return usingMvcc ? numAttributesMvcc(rootInternal) : numAttributes(root);
    }
 
-   public boolean removeFromDataStructure(Fqn f, boolean skipMarkerCheck)
-   {
+   public boolean removeFromDataStructure(Fqn f, boolean skipMarkerCheck) {
       return usingMvcc ? removeMvcc(f, skipMarkerCheck) : removeLegacy(f, skipMarkerCheck);
    }
 
-   private boolean removeMvcc(Fqn f, boolean skipMarkerCheck)
-   {
+   private boolean removeMvcc(Fqn f, boolean skipMarkerCheck) {
       InternalNode n = peekInternalNode(f, true);
-      if (n == null)
-      {
+      if (n == null) {
          return false;
       }
 
       if (trace) log.trace("Performing a real remove for node " + f + ", marked for removal.");
-      if (skipMarkerCheck || n.isRemoved())
-      {
-         if (n.getFqn().isRoot())
-         {
+      if (skipMarkerCheck || n.isRemoved()) {
+         if (n.getFqn().isRoot()) {
             // do not actually delete; just remove deletion marker
             n.setRemoved(true);
 
@@ -579,37 +481,29 @@
             // but now remove all children, since the call has been to remove("/")
             n.removeChildren();
             return true;
-         }
-         else
-         {
+         } else {
             // mark the node to be removed (and all children) as invalid so anyone holding a direct reference to it will
             // be aware that it is no longer valid.
             n.setValid(false, true);
             InternalNode parent = peekInternalNode(f.getParent(), true);
             return parent.removeChild(n.getFqn().getLastElement());
          }
-      }
-      else
-      {
+      } else {
          if (log.isDebugEnabled()) log.debug("Node " + f + " NOT marked for removal as expected, not removing!");
          return false;
       }
    }
 
 
-   private boolean removeLegacy(Fqn f, boolean skipMarkerCheck)
-   {
+   private boolean removeLegacy(Fqn f, boolean skipMarkerCheck) {
       NodeSPI n = peek(f, true);
-      if (n == null)
-      {
+      if (n == null) {
          return false;
       }
 
       if (trace) log.trace("Performing a real remove for node " + f + ", marked for removal.");
-      if (skipMarkerCheck || n.isDeleted())
-      {
-         if (n.getFqn().isRoot())
-         {
+      if (skipMarkerCheck || n.isDeleted()) {
+         if (n.getFqn().isRoot()) {
             // do not actually delete; just remove deletion marker
             n.markAsDeleted(true);
 
@@ -621,97 +515,74 @@
             // but now remove all children, since the call has been to remove("/")
             n.removeChildrenDirect();
             return true;
-         }
-         else
-         {
+         } else {
             // mark the node to be removed (and all children) as invalid so anyone holding a direct reference to it will
             // be aware that it is no longer valid.
             n.setValid(false, true);
             NodeSPI parent = peek(f.getParent(), true);
             return parent.removeChildDirect(n.getFqn().getLastElement());
          }
-      }
-      else
-      {
+      } else {
          if (log.isDebugEnabled()) log.debug("Node " + f + " NOT marked for removal as expected, not removing!");
          return false;
       }
    }
 
-   public void evict(Fqn fqn, boolean recursive)
-   {
+   public void evict(Fqn fqn, boolean recursive) {
       List<Fqn> toEvict = getNodesForEviction(fqn, recursive);
-      for (Fqn aFqn : toEvict)
-      {
+      for (Fqn aFqn : toEvict) {
          evict(aFqn);
       }
    }
 
-   public boolean evict(Fqn fqn)
-   {
+   public boolean evict(Fqn fqn) {
       if (!exists(fqn)) return true;
-      if (hasChildren(fqn))
-      {
-         if (trace)
-         {
+      if (hasChildren(fqn)) {
+         if (trace) {
             log.trace("removing DATA as node has children: evict(" + fqn + ")");
          }
-         if (usingMvcc)
-         {
+         if (usingMvcc) {
             removeData(fqn);
-         }
-         else
-         {
+         } else {
             removeDataLegacy(fqn);
          }
          return false;
-      }
-      else
-      {
+      } else {
          if (trace) log.trace("removing NODE as it is a leaf: evict(" + fqn + ")");
-         if (usingMvcc)
-         {
+         if (usingMvcc) {
             removeNode(fqn);
-         }
-         else
-         {
+         } else {
             removeNodeLegacy(fqn);
          }
          return true;
       }
    }
 
-   private void removeNodeLegacy(Fqn fqn)
-   {
+   private void removeNodeLegacy(Fqn fqn) {
       NodeSPI targetNode = peek(fqn, false, true);
       if (targetNode == null) return;
       NodeSPI parentNode = targetNode.getParentDirect();
       targetNode.setValid(false, false);
-      if (parentNode != null)
-      {
+      if (parentNode != null) {
          parentNode.removeChildDirect(fqn.getLastElement());
          parentNode.setChildrenLoaded(false);
       }
    }
 
-   private void removeNode(Fqn fqn)
-   {
+   private void removeNode(Fqn fqn) {
       InternalNode targetNode = peekInternalNode(fqn, true);
       if (targetNode == null) return;
       InternalNode parentNode = peekInternalNode(fqn.getParent(), true);
       targetNode.setValid(false, false);
-      if (parentNode != null)
-      {
+      if (parentNode != null) {
          parentNode.removeChild(fqn.getLastElement());
          parentNode.setChildrenLoaded(false);
       }
    }
 
-   private void removeDataLegacy(Fqn fqn)
-   {
+   private void removeDataLegacy(Fqn fqn) {
       NodeSPI n = peek(fqn);
-      if (n == null)
-      {
+      if (n == null) {
          log.warn("node " + fqn + " not found");
          return;
       }
@@ -719,11 +590,9 @@
       n.setDataLoaded(false);
    }
 
-   private void removeData(Fqn fqn)
-   {
+   private void removeData(Fqn fqn) {
       InternalNode n = peekInternalNode(fqn, false);
-      if (n == null)
-      {
+      if (n == null) {
          log.warn("node " + fqn + " not found");
          return;
       }
@@ -731,8 +600,7 @@
       n.setDataLoaded(false);
    }
 
-   public Object[] createNodes(Fqn fqn)
-   {
+   public Object[] createNodes(Fqn fqn) {
       List<NodeSPI> result = new ArrayList<NodeSPI>(fqn.size());
       Fqn tmpFqn = Fqn.ROOT;
 
@@ -740,8 +608,7 @@
 
       // root node
       NodeSPI n = root;
-      for (int i = 0; i < size; i++)
-      {
+      for (int i = 0; i < size; i++) {
          Object childName = fqn.get(i);
          tmpFqn = Fqn.fromRelativeElements(tmpFqn, childName);
 
@@ -749,8 +616,7 @@
          Map children = n.getChildrenMapDirect();
          childNode = (NodeSPI) children.get(childName);
 
-         if (childNode == null)
-         {
+         if (childNode == null) {
             childNode = n.addChildDirect(Fqn.fromElements(childName));
             result.add(childNode);
          }
@@ -760,52 +626,41 @@
       return new Object[]{result, n};
    }
 
-   public InternalNode peekInternalNode(Fqn fqn, boolean includeInvalidNodes)
-   {
+   public InternalNode peekInternalNode(Fqn fqn, boolean includeInvalidNodes) {
       if (fqn == null || fqn.size() == 0) return rootInternal;
       InternalNode n = rootInternal;
       int fqnSize = fqn.size();
-      for (int i = 0; i < fqnSize; i++)
-      {
+      for (int i = 0; i < fqnSize; i++) {
          Object obj = fqn.get(i);
          n = n.getChild(obj);
-         if (n == null)
-         {
+         if (n == null) {
             return null;
-         }
-         else if (!includeInvalidNodes && !n.isValid())
-         {
+         } else if (!includeInvalidNodes && !n.isValid()) {
             return null;
          }
       }
       return n;
    }
 
-   public InternalNode[] peekInternalNodeAndDirectParent(Fqn fqn, boolean includeInvalidNodes)
-   {
+   public InternalNode[] peekInternalNodeAndDirectParent(Fqn fqn, boolean includeInvalidNodes) {
       if (fqn == null || fqn.size() == 0) return new InternalNode[]{rootInternal, null};
       InternalNode n = rootInternal;
       InternalNode directParent = null;
       int fqnSize = fqn.size();
-      for (int i = 0; i < fqnSize; i++)
-      {
+      for (int i = 0; i < fqnSize; i++) {
          directParent = n;
          Object obj = fqn.get(i);
          n = directParent.getChild(obj);
-         if (n == null)
-         {
+         if (n == null) {
             return NULL_ARRAY;
-         }
-         else if (!includeInvalidNodes && !n.isValid())
-         {
+         } else if (!includeInvalidNodes && !n.isValid()) {
             return NULL_ARRAY;
          }
       }
       return new InternalNode[]{n, directParent};
    }
 
-   public void setBuddyFqnTransformer(BuddyFqnTransformer buddyFqnTransformer)
-   {
+   public void setBuddyFqnTransformer(BuddyFqnTransformer buddyFqnTransformer) {
       this.buddyFqnTransformer = buddyFqnTransformer;
    }
 }

Modified: core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/UnversionedNode.java	2009-02-13 14:53:17 UTC (rev 7688)
+++ core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/UnversionedNode.java	2009-02-13 15:21:46 UTC (rev 7689)
@@ -255,7 +255,8 @@
       } else {
          // singleton maps cannot remove!
          value = data.get(key);
-         if (value != null) data = null;
+         // a null value could still be stored in the map!!
+         if (value != null || data.containsKey(key)) data = null;
       }
       return value;
    }

Modified: core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
===================================================================
--- core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java	2009-02-13 14:53:17 UTC (rev 7688)
+++ core/tags/3.0.3.CR1/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java	2009-02-13 15:21:46 UTC (rev 7689)
@@ -42,8 +42,7 @@
  * @author Jerry Gauthier
  * @version $Id$
  */
-public class CacheMgmtInterceptor extends JmxStatsCommandInterceptor
-{
+public class CacheMgmtInterceptor extends JmxStatsCommandInterceptor {
    private long hitTimes = 0;
    private long missTimes = 0;
    private long storeTimes = 0;
@@ -57,32 +56,26 @@
    private DataContainer dataContainer;
 
    @Inject
-   public void setDependencies(DataContainer dataContainer)
-   {
+   public void setDependencies(DataContainer dataContainer) {
       this.dataContainer = dataContainer;
    }
 
    @Override
-   public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
-   {
+   public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable {
       Object returnValue = invokeNextInterceptor(ctx, command);
       evictions++;
       return returnValue;
    }
 
    @Override
-   public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
-   {
+   public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable {
       long t1 = System.currentTimeMillis();
       Object retval = invokeNextInterceptor(ctx, command);
       long t2 = System.currentTimeMillis();
-      if (retval == null)
-      {
+      if (retval == null) {
          missTimes = missTimes + (t2 - t1);
          misses++;
-      }
-      else
-      {
+      } else {
          hitTimes = hitTimes + (t2 - t1);
          hits++;
       }
@@ -90,15 +83,13 @@
    }
 
    @Override
-   public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
-   {
+   public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable {
       Map data = command.getData();
       long t1 = System.currentTimeMillis();
       Object retval = invokeNextInterceptor(ctx, command);
       long t2 = System.currentTimeMillis();
 
-      if (data != null && data.size() > 0)
-      {
+      if (data != null && data.size() > 0) {
          storeTimes = storeTimes + (t2 - t1);
          stores = stores + data.size();
       }
@@ -107,14 +98,12 @@
 
 
    @Override
-   public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
-   {
+   public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable {
       return visitPutKeyValueCommand(ctx, command);
    }
 
    @Override
-   public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
-   {
+   public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable {
       long t1 = System.currentTimeMillis();
       Object retval = invokeNextInterceptor(ctx, command);
       long t2 = System.currentTimeMillis();
@@ -124,105 +113,93 @@
    }
 
    @ManagedAttribute(description = "number of cache attribute hits")
-   public long getHits()
-   {
+   public long getHits() {
       return hits;
    }
 
    @ManagedAttribute(description = "number of cache attribute misses")
-   public long getMisses()
-   {
+   public long getMisses() {
       return misses;
    }
 
    @ManagedAttribute(description = "number of cache attribute put operations")
-   public long getStores()
-   {
+   public long getStores() {
       return stores;
    }
 
    @ManagedAttribute(description = "number of cache eviction operations")
-   public long getEvictions()
-   {
+   public long getEvictions() {
       return evictions;
    }
 
    @ManagedAttribute(description = "hit/miss ratio for the cache")
-   public double getHitMissRatio()
-   {
+   public double getHitMissRatio() {
       double total = hits + misses;
-      if (total == 0)
-      {
+      if (total == 0) {
          return 0;
       }
       return (hits / total);
    }
 
    @ManagedAttribute(description = "read/writes ratio for the cache")
-   public double getReadWriteRatio()
-   {
-      if (stores == 0)
-      {
+   public double getReadWriteRatio() {
+      if (stores == 0) {
          return 0;
       }
       return (((double) (hits + misses) / (double) stores));
    }
 
    @ManagedAttribute(description = "average number of milliseconds for a read operation")
-   public long getAverageReadTime()
-   {
+   public long getAverageReadTime() {
       long total = hits + misses;
-      if (total == 0)
-      {
+      if (total == 0) {
          return 0;
       }
       return (hitTimes + missTimes) / total;
    }
 
    @ManagedAttribute(description = "average number of milliseconds for a write operation")
-   public long getAverageWriteTime()
-   {
-      if (stores == 0)
-      {
+   public long getAverageWriteTime() {
+      if (stores == 0) {
          return 0;
       }
       return (storeTimes) / stores;
    }
 
    @ManagedAttribute(description = "number of cache attributes")
-   public int getNumberOfAttributes()
-   {
+   public int getNumberOfAttributes() {
       return dataContainer.getNumberOfAttributes();
    }
 
    @ManagedAttribute(description = "number of nodes in the cache")
-   public int getNumberOfNodes()
-   {
+   public int getNumberOfNodes() {
       return dataContainer.getNumberOfNodes();
    }
 
+   @ManagedAttribute(description = "number of nodes in the cache")
+   public String getNumberOfNodesString() {
+      return dataContainer.getNumberOfNodesString();
+   }
+
    @ManagedAttribute(description = "seconds since cache started")
-   public long getElapsedTime()
-   {
+   public long getElapsedTime() {
       return (System.currentTimeMillis() - start) / 1000;
    }
 
    @ManagedAttribute(description = "number of seconds since the cache statistics were last reset")
-   public long getTimeSinceReset()
-   {
+   public long getTimeSinceReset() {
       return (System.currentTimeMillis() - reset) / 1000;
    }
 
    @ManagedOperation
-   public Map<String, Object> dumpStatistics()
-   {
+   public Map<String, Object> dumpStatistics() {
       Map<String, Object> retval = new HashMap<String, Object>();
       retval.put("Hits", hits);
       retval.put("Misses", misses);
       retval.put("Stores", stores);
       retval.put("Evictions", evictions);
       retval.put("NumberOfAttributes", dataContainer.getNumberOfAttributes());
-      retval.put("NumberOfNodes", dataContainer.getNumberOfNodes());
+      retval.put("NumberOfNodes", dataContainer.getNumberOfNodesString());
       retval.put("ElapsedTime", getElapsedTime());
       retval.put("TimeSinceReset", getTimeSinceReset());
       retval.put("AverageReadTime", getAverageReadTime());
@@ -233,8 +210,7 @@
    }
 
    @ManagedOperation
-   public void resetStatistics()
-   {
+   public void resetStatistics() {
       hits = 0;
       misses = 0;
       stores = 0;

Modified: core/tags/3.0.3.CR1/src/test/java/org/jboss/cache/DataContainerTest.java
===================================================================
--- core/tags/3.0.3.CR1/src/test/java/org/jboss/cache/DataContainerTest.java	2009-02-13 14:53:17 UTC (rev 7688)
+++ core/tags/3.0.3.CR1/src/test/java/org/jboss/cache/DataContainerTest.java	2009-02-13 15:21:46 UTC (rev 7689)
@@ -3,12 +3,12 @@
 import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
 import org.jboss.cache.marshall.NodeData;
 import org.jboss.cache.mock.MockNodesFixture;
+import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.testng.annotations.AfterMethod;
 
 /**
  * Tests functionality from DataContainer.
@@ -17,16 +17,14 @@
  * @since 2.2
  */
 @Test(groups = "unit", sequential = true, testName = "DataContainerTest")
-public class DataContainerTest
-{
+public class DataContainerTest {
    private DataContainerImpl container;
    private MockNodesFixture nodes;
 
    //end of node structure.
 
    @BeforeMethod
-   public void setUp()
-   {
+   public void setUp() {
       nodes = new MockNodesFixture();
       container = new DataContainerImpl();
       container.setRoot(nodes.root);
@@ -34,16 +32,15 @@
    }
 
    @AfterMethod
-   public void tearDown()
-   {
+   public void tearDown() {
       container = null;
       nodes = null;
    }
+
    /**
     * tests {@link DataContainerImpl#peek(Fqn, boolean, boolean)} method
     */
-   public void testPeekNodesSimple()
-   {
+   public void testPeekNodesSimple() {
       assert nodes.root == container.peek(Fqn.ROOT, true, true);
       assert nodes.adfgNode == container.peek(nodes.adfg, false, false);
       assert nodes.adfgNode == container.peek(nodes.adfg, false, true);
@@ -53,8 +50,7 @@
    /**
     * tests {@link DataContainerImpl#peek(Fqn, boolean, boolean)} for invalid nodes.
     */
-   public void testPeekInvalidNodes()
-   {
+   public void testPeekInvalidNodes() {
       nodes.adfgNode.setValid(false, false);
       assert null == container.peek(nodes.adfg, true, false);
       assert nodes.adfgNode == container.peek(nodes.adfg, true, true);
@@ -63,8 +59,7 @@
    /**
     * tests {@link DataContainerImpl#peek(Fqn, boolean, boolean)} method for deleted nodes.
     */
-   public void testPeekDeletedNodes()
-   {
+   public void testPeekDeletedNodes() {
       nodes.adfgNode.markAsDeleted(true);
       assert null == container.peek(nodes.adfg, false, false);
       assert nodes.adfgNode == container.peek(nodes.adfg, true, false);
@@ -73,8 +68,7 @@
    /**
     * tests {@link DataContainerImpl#exists(Fqn)}
     */
-   public void testsExists()
-   {
+   public void testsExists() {
       assert container.exists(nodes.ab) : "ab exists";
       nodes.abNode.markAsDeleted(true);
       assert !container.exists(nodes.ab) : "ab marked as deleted";
@@ -86,8 +80,7 @@
    /**
     * tests {@link DataContainerImpl#hasChildren(Fqn)}
     */
-   public void testHasChildren()
-   {
+   public void testHasChildren() {
       assert container.hasChildren(nodes.ad) : " ade is a child of ad";
       assert !container.hasChildren(nodes.notExistent) : " this one does not exist";
       assert !container.hasChildren(nodes.adfg) : "this one exists but does not have children";
@@ -98,8 +91,7 @@
    /**
     * test {@link DataContainer#buildNodeData(java.util.List}
     */
-   public void testBuildNodeData()
-   {
+   public void testBuildNodeData() {
       nodes.abNode.put("ab", "ab");
       nodes.abcNode.put("abc", "abc");
       List<NodeData> result = new ArrayList<NodeData>();
@@ -112,8 +104,7 @@
    /**
     * tests {@link DataContainerImpl#getNodesForEviction(Fqn, boolean)} in a nonrecursive scenario.
     */
-   public void testGetNodesForEvictionNonrecursive()
-   {
+   public void testGetNodesForEvictionNonrecursive() {
       //check for root first
       List<Fqn> result = container.getNodesForEviction(Fqn.ROOT, false);
       assert result.size() == 1 : "for root the direct children are considered for eviction";
@@ -133,8 +124,7 @@
    /**
     * tests {@link DataContainerImpl#getNodesForEviction(Fqn, boolean)} in a recursive scenario.
     */
-   public void testGetNodesForEvictionRecursive()
-   {
+   public void testGetNodesForEvictionRecursive() {
       //check for root first
       List<Fqn> result = container.getNodesForEviction(Fqn.ROOT, true);
       assert result.size() == 8 : "all children are considered for eviction";
@@ -161,8 +151,7 @@
    /**
     * tests {@link DataContainerImpl#getNodesForEviction(Fqn, boolean)} in a recursive scenario.
     */
-   public void testGetNodesForEvictionRecursiveNullNodes()
-   {
+   public void testGetNodesForEvictionRecursiveNullNodes() {
       container.removeFromDataStructure(nodes.ad, true);
       //check for root first
       List<Fqn> result = container.getNodesForEviction(Fqn.ROOT, true);
@@ -178,16 +167,16 @@
    /**
     * tests {@link DataContainerImpl#getNumberOfNodes()}
     */
-   public void testGetNumberOfNodes()
-   {
-      assert container.getNumberOfNodes() == 8 : "eoght nodes expected";
+   public void testGetNumberOfNodes() {
+      assert container.getNumberOfNodes() == -1 : "eight nodes expected";
+      container.started = true;
+      assert container.getNumberOfNodes() == 8 : "eight nodes expected";
    }
 
    /**
     * tests {@link DataContainerImpl#removeFromDataStructure(Fqn, boolean)} having skipMarkerCheck set to false.
     */
-   public void removeFromDataStructureNoSkip1()
-   {
+   public void removeFromDataStructureNoSkip1() {
       //check inexisten node
       assert !container.removeFromDataStructure(nodes.notExistent, false);
 
@@ -208,8 +197,7 @@
    /**
     * tests {@link DataContainerImpl#removeFromDataStructure(Fqn, boolean)} having skipMarkerCheck set to false.
     */
-   public void removeFromDataStructureNoSkip2()
-   {
+   public void removeFromDataStructureNoSkip2() {
       //check root - all the subnodes should be deleted and marked as invalid, but the root itself
       nodes.root.markAsDeleted(false);
       assert !container.removeFromDataStructure(Fqn.ROOT, false);
@@ -226,8 +214,7 @@
    /**
     * tests {@link DataContainerImpl#removeFromDataStructure(Fqn, boolean)} having skipMarkerCheck set to true.
     */
-   public void removeFromDataStructureWithSkip()
-   {
+   public void removeFromDataStructureWithSkip() {
       //check inexisten node
       assert !container.removeFromDataStructure(nodes.notExistent, false);
 
@@ -247,8 +234,7 @@
    /**
     * tests {@link DataContainerImpl#evict(Fqn)}
     */
-   public void testEvict()
-   {
+   public void testEvict() {
       //tests eviction of leaf nodes
       assert container.evict(nodes.abc);
       assert !nodes.abcNode.isValid();
@@ -266,8 +252,7 @@
    /**
     * test {@link DataContainerImpl#createNodes(Fqn)}
     */
-   public void testCreateNodes()
-   {
+   public void testCreateNodes() {
       Object[] objects = container.createNodes(Fqn.fromString("/a/x/y/z"));
       List result = (List) objects[0];
       assert result.size() == 3;

Modified: core/tags/3.0.3.CR1/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/tags/3.0.3.CR1/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java	2009-02-13 14:53:17 UTC (rev 7688)
+++ core/tags/3.0.3.CR1/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java	2009-02-13 15:21:46 UTC (rev 7689)
@@ -25,22 +25,18 @@
  * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
  */
 @Test(groups = {"functional"}, testName = "marshall.VersionAwareMarshallerTest")
-public class VersionAwareMarshallerTest extends AbstractVersionAwareMarshallerTest
-{
+public class VersionAwareMarshallerTest extends AbstractVersionAwareMarshallerTest {
    @BeforeMethod
-   public void setUp()
-   {
+   public void setUp() {
       this.cr = new ComponentRegistry(new Configuration(), new CacheInvocationDelegate());
    }
 
    @AfterMethod
-   public void tearDown()
-   {
+   public void tearDown() {
       cr = null;
    }
 
-   public void testMarshallerSelection()
-   {
+   public void testMarshallerSelection() {
       VersionAwareMarshaller marshaller = createVAMandRestartCache("2.2.0.GA");
       assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
 
@@ -72,17 +68,15 @@
       assertEquals(CacheMarshaller300.class, marshaller.defaultMarshaller.getClass());
    }
 
-   public void testVersionHeaderDefaultCurrent() throws Exception
-   {
+   public void testVersionHeaderDefaultCurrent() throws Exception {
       VersionAwareMarshaller marshaller = createVAMandRestartCache(Version.getVersionString(Version.getVersionShort()));
 
       byte[] bytes = marshaller.objectToByteBuffer("Hello");
       ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes));
-      assertEquals("Version header short should be '30'", 31, in.readShort());
+      assertEquals("Version header short should be '30'", 30, in.readShort());
    }
 
-   public void testVersionHeader210() throws Exception
-   {
+   public void testVersionHeader210() throws Exception {
       VersionAwareMarshaller marshaller = createVAMandRestartCache("2.1.0.GA");
 
       byte[] bytes = marshaller.objectToByteBuffer("Hello");
@@ -90,8 +84,7 @@
       assertEquals("Version header short should be '21'", 21, in.readShort());
    }
 
-   public void testVersionHeader200() throws Exception
-   {
+   public void testVersionHeader200() throws Exception {
       VersionAwareMarshaller marshaller = createVAMandRestartCache("2.0.0.GA");
 
       byte[] bytes = marshaller.objectToByteBuffer("Hello");




More information about the jbosscache-commits mailing list