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

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

/**
 * Tests passivation using JDBC Cache Loader.
 * This test has MySQL hard-coded. To run it, run MySQL first: mysqld -u=root
 * 
 * @author <a href="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
 * @version $Id: PassivationToJDBCCacheLoaderTestCase.java,v 1.4 2006/01/10 23:41:18 msurtani Exp $
 */
public class PassivationToJDBCCacheLoaderTestCase extends PassivationTestsBase
{


    protected Element getCacheLoaderConfig() throws Exception
    {
        String xml = "            <config>\n" +
                "                \n" +
                "                <passivation>true</passivation>\n" +
                "                <preload></preload>\n" +
                "\n" +
                "                <cacheloader>\n" +
                "                    <class>org.jboss.cache.loader.JDBCCacheLoader</class>\n" +
                "                    <properties>\n" +
                "                        cache.jdbc.driver=com.mysql.jdbc.Driver\n" +
                "                        cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb\n" +
                "                        cache.jdbc.user=root\n" +
                "                        cache.jdbc.password=\n" +
                "                    </properties>\n" +
                "                    <async>false</async>\n" +
                "                    <fetchPersistentState>false</fetchPersistentState>\n" +
                "                    <ignoreModifications>false</ignoreModifications>\n" +
                "                </cacheloader>\n" +
                "                \n" +
                "            </config>";
        return XmlHelper.stringToElement(xml);
    }

    protected void configureCache() throws Exception
    {
        cache.setCacheLoaderConfiguration(getCacheLoaderConfig());
    }

   public static Test suite()
   {
      return new TestSuite(PassivationToJDBCCacheLoaderTestCase.class);
   }

   public static void main(String[] args) {
      junit.textui.TestRunner.run(suite());
   }
}
