/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.cache.eviction;

import junit.framework.TestCase;
import org.jboss.cache.xml.XmlHelper;
import org.w3c.dom.Element;

/**
 * LFU Configuration test.
 *
 * @author Daniel Huang (dhuang@jboss.org)
 * @version $Revision: 1852 $
 */
public class LFUConfigurationTest extends TestCase
{

   public void testXMLParsing() throws Exception
   {
      LFUConfiguration config = new LFUConfiguration();
      String xml =
            "<region name=\"abc\">" +
                  "<attribute name=\"minNodes\">10</attribute>" +
                  "<attribute name=\"maxNodes\">20</attribute>" +
                  "</region>";

      Element element = XmlHelper.stringToElement(xml);
      config.parseXMLConfig(element);

      assertEquals(10, config.getMinNodes());
      assertEquals(20, config.getMaxNodes());
   }

   public void testXMLParsing2() throws Exception
   {
      LFUConfiguration config = new LFUConfiguration();
      String xml =
            "<region name=\"abc\">" +
                  "<attribute name=\"minNodes\">10</attribute>" +
                  "</region>";
      Element element = XmlHelper.stringToElement(xml);
      config.parseXMLConfig(element);

      assertEquals(10, config.getMinNodes());
      assertEquals(0, config.getMaxNodes());
   }

   public void testXMLParsing3() throws Exception
   {
      LFUConfiguration config = new LFUConfiguration();
      String xml =
            "<region name=\"abc\">" +
                  "<attribute name=\"maxNodes\">20</attribute>" +
                  "</region>";
      Element element = XmlHelper.stringToElement(xml);
      config.parseXMLConfig(element);

      assertEquals(0, config.getMinNodes());
      assertEquals(20, config.getMaxNodes());

   }
}
