Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 124   Methods: 11
NCLOC: 80   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LRUConfiguration.java 50% 68% 81.8% 70%
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.eviction;
 8   
 9    import org.jboss.cache.config.ConfigurationException;
 10    import org.jboss.cache.config.Dynamic;
 11   
 12    /**
 13    * Configuration implementation for {@link LRUPolicy}.
 14    * <p/>
 15    * If configured via XML, expects the following:
 16    * <p/>
 17    * <pre>
 18    * <region name="/maxAgeTest/">
 19    * <attribute name="maxNodes">10000</attribute>
 20    * <attribute name="timeToLiveSeconds">8</attribute>
 21    * <attribute name="maxAgeSeconds">10</attribute>
 22    * </region>
 23    * </pre>
 24    *
 25    * @author Daniel Huang (dhuang@jboss.org)
 26    * @version $Revision: 1.6 $
 27    */
 28    public class LRUConfiguration extends EvictionPolicyConfigBase
 29    {
 30    /** The serialVersionUID */
 31    private static final long serialVersionUID = -3426716488271559729L;
 32   
 33    @Dynamic
 34    private int timeToLiveSeconds;
 35    @Dynamic
 36    private int maxAgeSeconds;
 37   
 38  2985 public LRUConfiguration()
 39    {
 40  2985 super();
 41    // Force config of ttls
 42  2985 setTimeToLiveSeconds(-1);
 43    }
 44   
 45  5961 @Override
 46    protected void setEvictionPolicyClassName()
 47    {
 48  5961 setEvictionPolicyClass(LRUPolicy.class.getName());
 49    }
 50   
 51   
 52  19187 public int getTimeToLiveSeconds()
 53    {
 54  19187 return timeToLiveSeconds;
 55    }
 56   
 57  8954 public void setTimeToLiveSeconds(int timeToLiveSeconds)
 58    {
 59  8954 testImmutability("timeToLiveSeconds");
 60  8954 this.timeToLiveSeconds = timeToLiveSeconds;
 61    }
 62   
 63  517 public int getMaxAgeSeconds()
 64    {
 65  517 return maxAgeSeconds;
 66    }
 67   
 68  39 public void setMaxAgeSeconds(int maxAgeSeconds)
 69    {
 70  39 testImmutability("maxAgeSeconds");
 71  39 this.maxAgeSeconds = maxAgeSeconds;
 72    }
 73   
 74    /**
 75    * Requires a positive timeToLiveSeconds value or ConfigurationException
 76    * is thrown.
 77    */
 78  7018 @Override
 79    public void validate() throws ConfigurationException
 80    {
 81  7018 if (timeToLiveSeconds < 0)
 82    {
 83  1 throw new ConfigurationException("timeToLiveSeconds must be " +
 84    "configured to a value greater than or equal to 0");
 85    }
 86    }
 87   
 88  0 public String toString()
 89    {
 90  0 StringBuffer str = new StringBuffer();
 91  0 str.append("LRUConfiguration: timeToLiveSeconds = ").append(getTimeToLiveSeconds()).append(" maxAgeSeconds =");
 92  0 str.append(getMaxAgeSeconds()).append(" maxNodes =").append(getMaxNodes());
 93  0 return str.toString();
 94    }
 95   
 96  0 @Override
 97    public boolean equals(Object obj)
 98    {
 99  0 if (obj instanceof LRUConfiguration && super.equals(obj))
 100    {
 101  0 LRUConfiguration other = (LRUConfiguration) obj;
 102  0 return maxAgeSeconds == other.maxAgeSeconds
 103    && timeToLiveSeconds == other.timeToLiveSeconds;
 104    }
 105  0 return false;
 106    }
 107   
 108  4052 @Override
 109    public int hashCode()
 110    {
 111  4052 int result = super.hashCode();
 112  4052 result = 31 * result + maxAgeSeconds;
 113  4052 result = 31 * result + timeToLiveSeconds;
 114  4052 return result;
 115    }
 116   
 117  2976 @Override
 118    public void reset()
 119    {
 120  2976 super.reset();
 121  2976 setTimeToLiveSeconds(-1);
 122    }
 123   
 124    }