package org.jboss.cache.aop.loader;

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

/**
 */
public class FileCacheLoaderAopTest extends CacheLoaderTestsBase {


    protected Element getCacheLoaderConfig(String loc) throws Exception
    {
        String xml = "            <config>\n" +
                "                \n" +
                "                <passivation>false</passivation>\n" +
                "                <preload></preload>\n" +
                "\n" +
                "                <cacheloader>\n" +
                "                    <class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
                "                    <properties>\n" +
                "                        location=" + loc + "\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 {
       String tmp_location = System.getProperty("java.io.tmpdir", "c:\\tmp");
       cache.setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.FileCacheLoader", "", false, true, false));
//       cache.setCacheLoaderConfiguration(getCacheLoaderConfig(tmp_location));
   }

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

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

}
