Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 90   Methods: 7
NCLOC: 57   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NodeManager.java 75% 100% 100% 97%
coverage coverage
 1    /*
 2    * JBoss, the OpenSource J2EE webOS
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7    package org.jboss.cache.pojo.test;
 8   
 9    import java.util.HashMap;
 10    import java.util.List;
 11    import java.util.Map;
 12   
 13   
 14    /**
 15    * Test class for PojoCache for circular references.
 16    * Link is a POJO that will be instrumentet with CacheFieldInterceptor
 17    *
 18    * @version $Revision: 1.1 $
 19    * <p>Below is the annotation that signifies this class is "prepared" under JBossAop. This is used in
 20    * conjunction with a special jboss-aop.xml (supplied by JBossCache). In addition, this is JDK1.4 style,
 21    * so a annoc Ant build target is needed to pre-compile it.</p>
 22    * <p>To use this approach, just apply this line to your pojo and run annoc (and possibly aopc).</p>
 23    */
 24    // We are using JDK1.5 annotation.
 25    @org.jboss.cache.pojo.annotation.Replicable
 26    public class NodeManager
 27    {
 28    private TestNode rootNode_;
 29   
 30    private Map nodeMap_ = new HashMap();
 31   
 32  5 public NodeManager()
 33    {
 34    }
 35   
 36  4 public void setRootNode(String rdn)
 37    {
 38  4 this.rootNode_ = new TestNode();
 39  4 rootNode_.setNodeFDN(rdn);
 40  4 rootNode_.setNodeRDN(rdn);
 41   
 42  4 registMap(rootNode_);
 43    }
 44   
 45  13 public void addNode(String parentFdn, String rdn)
 46    {
 47  13 TestNode parent = findNode(parentFdn);
 48  13 if (parent != null)
 49    {
 50  13 TestNode node = new TestNode();
 51  13 node.setNodeFDN(parentFdn + "." + rdn);
 52  13 node.setNodeRDN(rdn);
 53   
 54  13 node.setParentNode(parent);
 55  13 parent.addChildNode(node);
 56   
 57  13 registMap(node);
 58    }
 59    }
 60   
 61  24 public TestNode findNode(String fdn)
 62    {
 63  24 return (TestNode) nodeMap_.get(fdn);
 64    }
 65   
 66  17 private void registMap(TestNode node)
 67    {
 68  17 this.nodeMap_.put(node.getNodeFDN(), node);
 69    }
 70   
 71  1 public void printNodes()
 72    {
 73  1 printNode(rootNode_, "");
 74    }
 75   
 76  5 private void printNode(TestNode node, String prefix)
 77    {
 78  5 System.out.println(prefix + node.getNodeRDN());
 79   
 80  5 String childPrefix = prefix + " + ";
 81  5 List children = node.getChildren();
 82  5 int size = children.size();
 83  5 for (int idx = 0; idx < size; idx++)
 84    {
 85  4 TestNode child = (TestNode) children.get(idx);
 86  4 printNode(child, childPrefix);
 87    }
 88    }
 89   
 90    }